Skip to content

Commit

Permalink
MAPE metric: output number range changed, unit tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
gyrdym committed Sep 10, 2020
1 parent 09c3f7f commit 33fccda
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
@@ -1,7 +1,7 @@
# Changelog

## 15.1.0
- Metrics: output range squeezed to [0, 1]
- MAPE metric: output range squeezed to [0, 1]

## 15.0.1
- RegressorAssessor: unit tests added
Expand Down
2 changes: 1 addition & 1 deletion e2e/knn_regressor_test.dart
Expand Up @@ -36,7 +36,7 @@ void main() {
'metric, dtype=DType.float64', () async {
final scores = await evaluateKnnRegressor(MetricType.mape, DType.float64);

expect(scores.mean(), lessThan(50));
expect(scores.mean(), lessThan(0.5));
});
});
}
4 changes: 2 additions & 2 deletions e2e/lasso_regressor.dart
Expand Up @@ -33,15 +33,15 @@ void main() {
final scores = await evaluateLassoRegressor(MetricType.mape,
DType.float32);

expect(scores.mean(), lessThan(50));
expect(scores.mean(), lessThan(0.5));
});

test('should return adequate error on mape metric, '
'dtype=DType.float64', () async {
final scores = await evaluateLassoRegressor(MetricType.mape,
DType.float64);

expect(scores.mean(), lessThan(50));
expect(scores.mean(), lessThan(0.5));
});
});
}
4 changes: 2 additions & 2 deletions e2e/linear_regressor_test.dart
Expand Up @@ -35,15 +35,15 @@ void main() async {
'dtype=DType.float32', () async {
expect(
(await evaluateLinearRegressor(MetricType.mape, DType.float32)).mean(),
lessThan(50),
lessThan(0.5),
);
});

test('should return adequate error on mape metric, '
'dtype=DType.float64', () async {
expect(
(await evaluateLinearRegressor(MetricType.mape, DType.float64)).mean(),
lessThan(50),
lessThan(0.5),
);
});
});
Expand Down
26 changes: 25 additions & 1 deletion lib/src/metric/metric_type.dart
@@ -1 +1,25 @@
enum MetricType { mape, rmse, accuracy, precision }
/// Metrics for measuring the quality of the prediction.
enum MetricType {
/// Mean percentage absolute error (MAPE), a regression metric. The less the
/// score produced by the metric, the better the prediction's quality is. Can
/// lead to error if there are zero values among the original values. Normally,
/// the metric produces scores within the range [0, 1], but extremely high
/// predicted values (>> original values) can produce scores which are
/// greater than 1.
mape,

/// Root mean squared error, a regression metric. The less the score produced
/// by the metric, the better the prediction's quality is. The metric produces
/// scores within the range [0, +Infinity]
rmse,

/// A classification metric. The greater the score produced by the metric, the
/// better the prediction's quality is. The metric produces scores within the
/// range [0, 1]
accuracy,

/// A classification metric. The greater the score produced by the metric, the
/// better the prediction's quality is. The metric produces scores within the
/// range [0, 1]
precision,
}

0 comments on commit 33fccda

Please sign in to comment.