Skip to content

Commit

Permalink
[single_assessment] feat: add a base class for prediction evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmamica committed Jan 26, 2024
1 parent 65a4a3b commit 5c3f501
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions climate_health/single_assessment/prediction_evaluator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score

class PredictionsEvaluator:
def __init__(self, predictions, ground_truths):
self.predictions = predictions
self.ground_truths = ground_truths
self.metrics = self._evaluate_predictions()

def _evaluate_predictions(self):
metrics = {}
metrics['mse'] = mean_squared_error(self.ground_truths, self.predictions)
metrics['mae'] = mean_absolute_error(self.ground_truths, self.predictions)
metrics['r2'] = r2_score(self.ground_truths, self.predictions)
return metrics

def get_metrics(self):
return self.metrics

0 comments on commit 5c3f501

Please sign in to comment.