metrics_utils.py 451 B

123456789101112
  1. import numpy as np
  2. from sklearn.metrics import mean_squared_error, mean_absolute_error, mean_absolute_percentage_error
  3. def calculate_rmse(list_a, list_b):
  4. assert len(list_a) == len(list_b) and len(list_a) > 0 and len(list_b) > 0
  5. return np.sqrt(mean_squared_error(list_a, list_b))
  6. def calculate_mae(list_a, list_b):
  7. assert len(list_a) == len(list_b) and len(list_a) > 0 and len(list_b) > 0
  8. return mean_absolute_error(list_a, list_b)