Example #1
0
 def test_values(self):
     # first bin maps the ±0.5 interval error, the second the 0
     bins = _histogram_bins(2)
     ann = np.asarray([0, 1, 2, 3])
     # A) identical detections map to the 0 error bin
     hist = _error_histogram(np.asarray([0, 1, 2, 3]), ann, bins)
     self.assertTrue(np.allclose(hist, [0, 4]))
     # bins maps the ±0.5, -0.25, 0, 0.25 interval errors
     bins = _histogram_bins(4)
     # B) identical detections map to the 0 error bin
     hist = _error_histogram(ann, ann, bins)
     self.assertTrue(np.allclose(hist, [0, 0, 4, 0]))
     # C) offbeat detections map to the ±0.5 error bin
     hist = _error_histogram(np.asarray([0.5, 1.5, 2.5, 3.5]), ann, bins)
     self.assertTrue(np.allclose(hist, [4, 0, 0, 0]))
     # D) smaller deviations mapping to the 0 and 0.125 error bins
     hist = _error_histogram(np.asarray([0.125, 0.875, 2.1, 3]), ann, bins)
     self.assertTrue(np.allclose(hist, [0, 0, 3, 1]))
     # E) default annotations and detections with 40 bins
     bins = _histogram_bins(40)
     hist = _error_histogram(DETECTIONS, ANNOTATIONS, bins)
     self.assertTrue(np.allclose(hist, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                        0, 0, 0, 0, 0, 0, 1, 0, 8, 0, 0, 0,
                                        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                        0, 0, 0, 0]))
Example #2
0
 def test_values(self):
     # first bin maps the ±0.5 interval error, the second the 0
     bins = _histogram_bins(2)
     ann = np.asarray([0, 1, 2, 3])
     # A) identical detections map to the 0 error bin
     hist = _error_histogram(np.asarray([0, 1, 2, 3]), ann, bins)
     self.assertTrue(np.allclose(hist, [0, 4]))
     # bins maps the ±0.5, -0.25, 0, 0.25 interval errors
     bins = _histogram_bins(4)
     # B) identical detections map to the 0 error bin
     hist = _error_histogram(ann, ann, bins)
     self.assertTrue(np.allclose(hist, [0, 0, 4, 0]))
     # C) offbeat detections map to the ±0.5 error bin
     hist = _error_histogram(np.asarray([0.5, 1.5, 2.5, 3.5]), ann, bins)
     self.assertTrue(np.allclose(hist, [4, 0, 0, 0]))
     # D) smaller deviations mapping to the 0 and 0.125 error bins
     hist = _error_histogram(np.asarray([0.125, 0.875, 2.1, 3]), ann, bins)
     self.assertTrue(np.allclose(hist, [0, 0, 3, 1]))
     # E) default annotations and detections with 40 bins
     bins = _histogram_bins(40)
     hist = _error_histogram(DETECTIONS, ANNOTATIONS, bins)
     self.assertTrue(
         np.allclose(hist, [
             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 8,
             0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
         ]))
Example #3
0
 def test_types(self):
     bins = _histogram_bins(4)
     hist = _error_histogram(DETECTIONS, ANNOTATIONS, bins)
     ig = _information_gain(hist)
     self.assertIsInstance(ig, float)
Example #4
0
 def test_types(self):
     bins = _histogram_bins(4)
     hist = _error_histogram(DETECTIONS, ANNOTATIONS, bins)
     self.assertIsInstance(hist, np.ndarray)
     self.assertTrue(hist.dtype == np.float)
Example #5
0
 def test_types(self):
     bins = _histogram_bins(4)
     hist = _error_histogram(DETECTIONS, ANNOTATIONS, bins)
     ig = _information_gain(hist)
     self.assertIsInstance(ig, float)
Example #6
0
 def test_types(self):
     bins = _histogram_bins(4)
     hist = _error_histogram(DETECTIONS, ANNOTATIONS, bins)
     self.assertIsInstance(hist, np.ndarray)
     self.assertTrue(hist.dtype == np.float)