-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b64c0c
commit d5bac61
Showing
4 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
def metrics(results_df): | ||
""" | ||
Calculate and print metrics: MAE | ||
results_df dataframe with the following columns | ||
- timestamp | ||
- pv_id | ||
- horizon_hours | ||
- forecast_power | ||
- generation_power | ||
""" | ||
|
||
mae = (results_df["forecast_power"] - results_df['generation_power']).abs().mean() | ||
print(f"MAE: {mae}") | ||
|
||
# calculate metrics over the different horizons hours | ||
# find all unique horizon_hours | ||
horizon_hours = results_df["horizon_hours"].unique() | ||
for horizon_hour in horizon_hours: | ||
# filter results_df to only include the horizon_hour | ||
results_df_horizon = results_df[results_df["horizon_hours"] == horizon_hour] | ||
mae = (results_df_horizon["forecast_power"] - results_df_horizon['generation_power']).abs().mean() | ||
print(f"MAE for horizon {horizon_hour}: {mae}") | ||
|
||
# TODO add more metrics using ocf_ml_metrics | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from quartz_solar_forecast.eval.metrics import metrics | ||
import pandas as pd | ||
import numpy as np | ||
|
||
|
||
def test_metrics(): | ||
|
||
# create a fake dataframe | ||
|
||
results_df = pd.DataFrame( | ||
columns=[ | ||
"id", | ||
"timestamp", | ||
"horizon_hours", | ||
"forecast_power", | ||
"generation_power", | ||
], data=np.random.random((100,5))) | ||
|
||
# call the metrics function | ||
metrics(results_df) |