Skip to content

Commit

Permalink
fix metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Dec 14, 2023
1 parent 2414dc7 commit 52ca346
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions quartz_solar_forecast/eval/metrics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
def metrics(results_df):
import numpy as np
import pandas as pd


def metrics(results_df: pd.DataFrame):
"""
Calculate and print metrics: MAE
Expand All @@ -11,7 +15,7 @@ def metrics(results_df):
"""

mae = (results_df["forecast_power"] - results_df['generation_power']).abs().mean().round(4)
mae = np.round((results_df["forecast_power"] - results_df["generation_power"]).abs().mean(), 4)
print(f"MAE: {mae}")

# calculate metrics over the different horizons hours
Expand All @@ -20,12 +24,22 @@ def metrics(results_df):
for horizon_hour in horizon_hours:
# filter results_df to only include the horizon_hour
results_df_horizon = results_df[results_df["horizon_hour"] == horizon_hour]
mae = (results_df_horizon["forecast_power"] - results_df_horizon['generation_power']).abs().mean().round(3)
sem = ((results_df_horizon["forecast_power"] - results_df_horizon['generation_power']).abs().std() / len(results_df_horizon)**0.5).round(3)
mae = np.round(
(results_df_horizon["forecast_power"] - results_df_horizon["generation_power"])
.abs()
.mean(),
3,
)
sem = np.round(
(
(results_df_horizon["forecast_power"] - results_df_horizon["generation_power"])
.abs()
.std()
/ len(results_df_horizon) ** 0.5
),
3,
)

print(f"MAE for horizon {horizon_hour}: {mae} +- {1.96*sem}")

# TODO add more metrics using ocf_ml_metrics



0 comments on commit 52ca346

Please sign in to comment.