示例#1
0
 def test_duplicate_non_winner(self):
     softmax_values = np.array([[0.1, 0.8, 0.05, 0.05],
                                [0.2, 0.09, 0.7, 0.01]])
     prediction, pcs = PredictionConfidenceScore.calculate(softmax_values)
     self.assertEqual((2, ), prediction.shape)
     self.assertEqual((2, ), pcs.shape)
     self.assertEqual(1, prediction[0])
     self.assertAlmostEqual(0.7, pcs[0])
     self.assertEqual(2, prediction[1])
     self.assertAlmostEqual(0.5, pcs[1])
示例#2
0
 def test_happy_path_batch(self):
     softmax_values = np.array([[0.1, 0.8, 0.08, 0.02],
                                [0.1, 0.8, 0.08, 0.02],
                                [0.2, 0.09, 0.7, 0.01]])
     prediction, pcs = PredictionConfidenceScore.calculate(softmax_values)
     self.assertEqual((3, ), prediction.shape)
     self.assertEqual((3, ), pcs.shape)
     self.assertEqual(1, prediction[0])
     self.assertAlmostEqual(0.7, pcs[0])
     self.assertEqual(1, prediction[1])
     self.assertAlmostEqual(0.7, pcs[1])
     self.assertEqual(2, prediction[2])
     self.assertAlmostEqual(0.5, pcs[2])
示例#3
0
 def test_duplicate_winner(self):
     softmax_values = np.array([[0.4, 0.4, 0.1, 0.1],
                                [0.2, 0.09, 0.7, 0.01]])
     prediction, pcs = PredictionConfidenceScore.calculate(softmax_values)
     self.assertEqual((2, ), prediction.shape)
     self.assertEqual((2, ), pcs.shape)
     self.assertTrue(
         0 == prediction[0] or 1 == prediction[0],
         "Prediction must be index 0 or 1, but was {0}".format(
             prediction[0]),
     )
     self.assertAlmostEqual(0, pcs[0])
     self.assertEqual(2, prediction[1])
     self.assertAlmostEqual(0.5, pcs[1])
示例#4
0
 def test_happy_path_single(self):
     softmax_values = np.array([0.1, 0.8, 0.08, 0.02])
     softmax_values = np.expand_dims(softmax_values, 0)
     prediction, pcs = PredictionConfidenceScore.calculate(softmax_values)
     self.assertEqual(1, prediction[0])
     self.assertAlmostEqual(0.7, pcs[0])
示例#5
0
 def test_problem_type(self):
     self.assertEqual(PredictionConfidenceScore.problem_type(),
                      ProblemType.CLASSIFICATION)
示例#6
0
 def test_samples_type_declaration(self):
     self.assertFalse(PredictionConfidenceScore.takes_samples())
示例#7
0
 def test_is_confidence(self):
     self.assertTrue(PredictionConfidenceScore.is_confidence())
     self.assertTrue(PredictionConfidenceScore().is_confidence())