Beispiel #1
0
    def test_mean_absolute_error(self):
        eva = Evaluation()
        y_true = [3, -0.5, 2, 7]
        y_pred = [2.5, 0.0, 2, 8]
        self.assertFloatEqual(eva.mean_absolute_error(y_true, y_pred), 0.5)

        y_true = [[0.5, 1], [-1, 1], [7, -6]]
        y_pred = [[0, 2], [-1, 2], [8, -5]]
        self.assertFloatEqual(eva.mean_absolute_error(y_true, y_pred), 0.75)
Beispiel #2
0
    def test_mean_absolute_error(self):
        eva = Evaluation()
        eva._init_model(EvaluateParam(eval_type=consts.REGRESSION,
                                      pos_label=1))
        y_true = [3, -0.5, 2, 7]
        y_pred = [2.5, 0.0, 2, 8]
        self.assertFloatEqual(eva.mean_absolute_error(y_true, y_pred), 0.5)

        y_true = [[0.5, 1], [-1, 1], [7, -6]]
        y_pred = [[0, 2], [-1, 2], [8, -5]]
        self.assertFloatEqual(eva.mean_absolute_error(y_true, y_pred), 0.75)