示例#1
0
 def test_confusion_matrix_vmin_too_high_and_vmax_too_low(self):
     b = qiime2.CategoricalMetadataColumn(self.a)
     with self.assertRaisesRegex(
             ValueError, r'vmin must be less than.*\s'
             r'\s0\.5.*greater.*0\.0\s.*vmax must be '
             r'greater than.*\s\s0\.5.*less.*1\.0'):
         confusion_matrix(self.tmpd, self.a, b, vmin=.5, vmax=.5)
 def test_confusion_matrix_class_overlap_error(self):
     b = pd.Series([1, 2, 3, 4, 5, 6], name='site',
                   index=['a1', 'a2', 'b1', 'b2', 'c1', 'c2'])
     b.index.name = 'id'
     b = qiime2.NumericMetadataColumn(b)
     with self.assertRaisesRegex(ValueError, "do not overlap"):
         confusion_matrix(self.tmpd, self.a, b)
    def test_confusion_matrix_dtype_coercion(self):
        predictions = pd.Series([1, 1, 1, 2, 2, 2],
                                index=pd.Index(['a', 'b', 'c', 'd', 'e', 'f'],
                                name='sample_id'), name='features')

        # NOTE: the targets are numbers but represented as str
        truth = qiime2.CategoricalMetadataColumn(pd.Series(
            ['1', '2', '1', '2', '1', '2'],
            index=pd.Index(['a', 'b', 'c', 'd', 'e', 'f'], name='sample-id'),
            name='target'))

        confusion_matrix(self.tmpd, predictions, truth)

        self.assertTrue('index.html' in listdir(self.tmpd))
示例#4
0
 def test_confusion_matrix_vmax_too_low(self):
     b = qiime2.CategoricalMetadataColumn(self.a)
     with self.assertRaisesRegex(
             ValueError, r'vmax must be greater than.*'
             r'\s\s0\.5.*less.*1\.0'):
         confusion_matrix(self.tmpd, self.a, b, vmin=None, vmax=.5)
示例#5
0
 def test_confusion_matrix_vmin_too_high(self):
     b = qiime2.CategoricalMetadataColumn(self.a)
     with self.assertRaisesRegex(
             ValueError, r'vmin must be less than.*\s\s'
             r'0\.5.*greater.*0\.0'):
         confusion_matrix(self.tmpd, self.a, b, vmin=.5, vmax=None)
示例#6
0
 def test_confusion_matrix(self):
     b = qiime2.CategoricalMetadataColumn(self.a)
     confusion_matrix(self.tmpd, self.a, b)