def test_confusion_matrix(self): conf_mat = metrics.confusion_matrix([1,2],[1,2]) self.assertEqual(conf_mat,[[1,0],[0,1]]) conf_mat = metrics.confusion_matrix([1,2],[1,2],0,2) self.assertEqual(conf_mat,[[0,0,0],[0,1,0],[0,0,1]]) conf_mat = metrics.confusion_matrix([1,1,2,2,4],[1,1,3,3,5]) self.assertEqual(conf_mat,[[2,0,0,0,0],[0,0,2,0,0],[0,0,0,0,0], [0,0,0,0,1],[0,0,0,0,0]]) conf_mat = metrics.confusion_matrix([1,2],[1,2],1,4) self.assertEqual(conf_mat,[[1,0,0,0],[0,1,0,0],[0,0,0,0],[0,0,0,0]])
def test_confusion_matrix(self): conf_mat = metrics.confusion_matrix([1, 2], [1, 2]) self.assertEqual(conf_mat, [[1, 0], [0, 1]]) conf_mat = metrics.confusion_matrix([1, 2], [1, 2], 0, 2) self.assertEqual(conf_mat, [[0, 0, 0], [0, 1, 0], [0, 0, 1]]) conf_mat = metrics.confusion_matrix([1, 1, 2, 2, 4], [1, 1, 3, 3, 5]) self.assertEqual(conf_mat, [[2, 0, 0, 0, 0], [0, 0, 2, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0]]) conf_mat = metrics.confusion_matrix([1, 2], [1, 2], 1, 4) self.assertEqual( conf_mat, [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])
def confusion_matrix(self, labels, predicts): return metrics.confusion_matrix(labels, predicts)