Exemplo n.º 1
0
 def test_binary_1d(self):
   probs = np.array([.91, .32, .66, .67, .57, .98, .41, .19])
   labels = np.array([1, 0, 1, 1, 0, 1, 0, 0])
   calibration_error = um.gce(
       labels, probs, num_bins=30, binning_scheme='even',
       class_conditional=False, max_prob=True, norm='l1')
   self.assertAlmostEqual(calibration_error, 0.18124999999999997)
Exemplo n.º 2
0
 def test_consistency(self):
   probs = np.array([[0.42610548, 0.41748077, 0.15641374],
                     [0.44766216, 0.47721294, 0.0751249],
                     [0.1862702, 0.15139402, 0.66233578],
                     [0.05753544, 0.8561222, 0.08634236],
                     [0.18697925, 0.29836466, 0.51465609]])
   labels = np.array([0, 1, 2, 1, 2])
   calibration_error = um.gce(
       labels, probs, num_bins=30, binning_scheme='even',
       class_conditional=False, max_prob=True, norm='l1')
   self.assertAlmostEqual(calibration_error, 0.412713502)