예제 #1
0
    def __init__(self, p):
        self.params = p
        assert p.metadata is not None
        self._histogram = np.zeros(shape=(self.NumBinsOfHistogram(),
                                          p.metadata.NumClasses()),
                                   dtype=np.int32)
        self._values = np.zeros(shape=(self.NumBinsOfHistogram(), 1),
                                dtype=np.float32)
        self._cumulative_distribution = {}
        for l in range(p.metadata.NumClasses()):
            self._cumulative_distribution[l] = []
        self._average_precisions = {}
        self._precision_recall = {}
        self._calibration = {}
        self._classnames = p.metadata.ClassNames()
        self._classids = p.metadata.EvalClassIndices()

        # We only want to calculate calibration for the lowest difficulty setting
        # which will include *all* data. Including all data is due to the way
        # _GetData() works in the kitti_ap_metric.
        difficulties = p.metadata.DifficultyLevels()
        lowest_difficulty_str = min(difficulties,
                                    key=lambda k: difficulties[k])
        self._calibration[lowest_difficulty_str] = (
            calibration.CalibrationCalculator(p.metadata))
 def testCalibrationCalculator(self):
     # End to end test for the calibration calculator.
     metadata = kitti_metadata.KITTIMetadata()
     calculator = calibration_processing.CalibrationCalculator(metadata)
     scores_and_hits = np.array([[0.3, 1], [0.5, 1], [0.7, 1]])
     metrics = {}
     metrics['calibrations'] = [{'calibrations': scores_and_hits}]
     calculator.Calculate(metrics)
     summaries = calculator.Summary('Test')
     self.assertEqual(len(summaries), 2)
     ece_summary = summaries[1]
     self.assertEqual(0.5, ece_summary.value[0].simple_value)
예제 #3
0
    def __init__(self, p):
        self.params = p
        assert p.metadata is not None
        self._histogram = np.zeros(shape=(self.NumBinsOfHistogram(),
                                          p.metadata.NumClasses()),
                                   dtype=np.int32)
        self._values = np.zeros(shape=(self.NumBinsOfHistogram(), 1),
                                dtype=np.float32)
        self._cumulative_distribution = {}
        for l in range(p.metadata.NumClasses()):
            self._cumulative_distribution[l] = []
        self._average_precisions = {}
        self._precision_recall = {}
        self._calibration = {}
        self._classnames = p.metadata.ClassNames()
        self._classids = p.metadata.EvalClassIndices()

        for difficulty in p.metadata.DifficultyLevels():
            self._calibration[difficulty] = calibration.CalibrationCalculator(
                p.metadata)