Skip to content

Commit

Permalink
load more data to be sure the rolling window is full
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinetavant committed Jan 13, 2025
1 parent 68db227 commit f612cfc
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 40 deletions.
76 changes: 43 additions & 33 deletions data/gold/our_tempo_prediction.csv
Original file line number Diff line number Diff line change
Expand Up @@ -72,58 +72,68 @@
2024-11-10,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-11-11,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-11-12,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-11-13,BLEU,prediction_bleu,prediction_bleu,prediction_blanc
2024-11-14,BLANC,prediction_bleu,prediction_blanc,prediction_blanc
2024-11-15,BLANC,prediction_bleu,prediction_blanc,prediction_blanc
2024-11-13,BLEU,prediction_blanc,prediction_bleu,prediction_blanc
2024-11-14,BLANC,prediction_blanc,prediction_blanc,prediction_blanc
2024-11-15,BLANC,prediction_blanc,prediction_blanc,prediction_blanc
2024-11-16,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-11-17,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-11-18,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-11-19,BLEU,prediction_bleu,,prediction_bleu
2024-11-20,BLANC,prediction_bleu,prediction_blanc,
2024-11-21,BLANC,prediction_bleu,prediction_blanc,prediction_blanc
2024-11-22,BLANC,prediction_bleu,,prediction_blanc
2024-11-20,BLANC,prediction_blanc,prediction_blanc,
2024-11-21,BLANC,prediction_rouge,prediction_blanc,prediction_blanc
2024-11-22,BLANC,prediction_blanc,,prediction_blanc
2024-11-23,BLEU,prediction_bleu,,
2024-11-24,BLEU,prediction_bleu,,
2024-11-25,BLEU,prediction_bleu,,
2024-11-26,BLEU,prediction_bleu,prediction_blanc,
2024-11-27,BLEU,prediction_bleu,prediction_blanc,prediction_blanc
2024-11-28,BLANC,prediction_bleu,prediction_blanc,prediction_blanc
2024-11-29,BLEU,prediction_bleu,prediction_blanc,prediction_blanc
2024-11-30,BLEU,prediction_bleu,prediction_blanc,prediction_blanc
2024-11-28,BLANC,prediction_blanc,prediction_blanc,prediction_blanc
2024-11-29,BLEU,prediction_blanc,prediction_blanc,prediction_blanc
2024-11-30,BLEU,prediction_blanc,prediction_blanc,prediction_blanc
2024-12-01,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-12-02,BLEU,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-03,ROUGE,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-04,BLANC,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-02,BLEU,prediction_blanc,prediction_blanc,prediction_blanc
2024-12-03,ROUGE,prediction_rouge,prediction_blanc,prediction_blanc
2024-12-04,BLANC,prediction_rouge,prediction_blanc,prediction_blanc
2024-12-05,BLEU,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-06,BLEU,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-07,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-12-08,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-12-09,BLANC,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-10,ROUGE,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-11,ROUGE,prediction_bleu,prediction_rouge,prediction_blanc
2024-12-12,ROUGE,prediction_bleu,prediction_rouge,prediction_rouge
2024-12-13,ROUGE,prediction_bleu,,prediction_rouge
2024-12-14,BLANC,prediction_bleu,prediction_blanc,
2024-12-09,BLANC,prediction_blanc,prediction_blanc,prediction_blanc
2024-12-10,ROUGE,prediction_rouge,prediction_blanc,prediction_blanc
2024-12-11,ROUGE,prediction_rouge,prediction_rouge,prediction_blanc
2024-12-12,ROUGE,prediction_rouge,prediction_rouge,prediction_rouge
2024-12-13,ROUGE,prediction_rouge,,prediction_rouge
2024-12-14,BLANC,prediction_blanc,prediction_blanc,
2024-12-15,BLEU,prediction_bleu,,prediction_bleu
2024-12-16,ROUGE,prediction_bleu,,
2024-12-17,BLANC,prediction_bleu,prediction_blanc,
2024-12-16,ROUGE,prediction_rouge,,
2024-12-17,BLANC,prediction_rouge,prediction_blanc,
2024-12-18,BLEU,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-19,BLEU,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-20,BLANC,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-20,BLANC,prediction_blanc,prediction_blanc,prediction_blanc
2024-12-21,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-12-22,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-12-23,BLANC,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-24,BLANC,prediction_bleu,prediction_rouge,prediction_rouge
2024-12-23,BLANC,prediction_blanc,prediction_blanc,prediction_blanc
2024-12-24,BLANC,prediction_blanc,prediction_rouge,prediction_rouge
2024-12-25,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2024-12-26,BLANC,prediction_bleu,prediction_rouge,prediction_blanc
2024-12-27,ROUGE,prediction_bleu,prediction_rouge,prediction_rouge
2024-12-28,BLANC,prediction_bleu,,prediction_blanc
2024-12-26,BLANC,prediction_rouge,prediction_rouge,prediction_blanc
2024-12-27,ROUGE,prediction_rouge,prediction_rouge,prediction_rouge
2024-12-28,BLANC,prediction_blanc,,prediction_blanc
2024-12-29,BLEU,prediction_bleu,prediction_bleu,
2024-12-30,ROUGE,prediction_bleu,prediction_rouge,prediction_rouge
2024-12-31,BLANC,prediction_bleu,prediction_blanc,prediction_blanc
2024-12-30,ROUGE,prediction_rouge,prediction_rouge,prediction_rouge
2024-12-31,BLANC,prediction_rouge,prediction_blanc,prediction_blanc
2025-01-01,BLEU,prediction_bleu,prediction_bleu,prediction_bleu
2025-01-02,ROUGE,prediction_bleu,prediction_rouge,prediction_rouge
2025-01-03,ROUGE,prediction_bleu,,prediction_rouge
2025-01-04,,prediction_bleu,,
2025-01-05,,,prediction_bleu,
2025-01-06,,,,prediction_bleu
2025-01-02,ROUGE,prediction_rouge,prediction_rouge,prediction_rouge
2025-01-03,ROUGE,prediction_rouge,,prediction_rouge
2025-01-04,BLANC,prediction_blanc,,
2025-01-05,BLEU,prediction_bleu,prediction_bleu,
2025-01-06,BLEU,prediction_bleu,,prediction_bleu
2025-01-07,BLANC,prediction_blanc,,
2025-01-08,BLANC,prediction_blanc,,
2025-01-09,BLANC,prediction_rouge,,
2025-01-10,ROUGE,prediction_rouge,,
2025-01-11,BLANC,prediction_blanc,,
2025-01-12,BLEU,prediction_bleu,,
2025-01-13,ROUGE,prediction_rouge,,
2025-01-14,,prediction_rouge,,
2025-01-15,,,prediction_rouge,
2025-01-16,,,,prediction_rouge
19 changes: 13 additions & 6 deletions scripts/tempo_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def fetch_history_data() -> pd.DataFrame:
WARNING : the API is not very reliable and the data is not always returend.
TODO : add validation to check if the data is returned.
"""
one_year_ago = TODAY - pd.DateOffset(years=1) - pd.DateOffset(month=9, day=1)
one_year_ago = TODAY - pd.DateOffset(years=2) - pd.DateOffset(month=9, day=1)
print(one_year_ago)
ecomix_data = get_eco2mix_data(start=one_year_ago, end=TODAY)[["consommation", "eolien", "solaire"]]
ecomix_data_no_duplicates = ecomix_data[~ecomix_data.index.duplicated()]
Expand Down Expand Up @@ -102,16 +102,15 @@ def compute_our_enr_forecast():
return our_enr_forecast.tz_localize("UTC")


@memory.cache(cache_validation_callback=expires_after(hours=2))
#@memory.cache(cache_validation_callback=expires_after(hours=2))
def fetch_temperature():
"""Limitation : there only the observed temperature is used.
TODO : add the forecasted mean daily temperature.
TODO : make sure the last day is complete (the observations are not always available for the current day).
"""
files = download_observations_all_departments()
cut_before = TODAY - pd.DateOffset(years=1) - pd.DateOffset(month=9, day=1)
cut_before = TODAY - pd.DateOffset(years=1) - pd.DateOffset(month=9, day=1)
cut_before = TODAY - pd.DateOffset(years=2) - pd.DateOffset(month=9, day=1)
daily_temperature = aggregates_observations(files, cut_before=cut_before).tz_localize("Europe/Paris")
return daily_temperature

Expand Down Expand Up @@ -143,7 +142,7 @@ def get_all_data():
tempos["value"].rename("Type_de_jour_TEMPO"),
daily_temperature.rename("temperature")
],
axis=1)
axis=1).bfill() # backfill for missing temperatures
return data


Expand Down Expand Up @@ -232,10 +231,18 @@ def main():
logger.info("Starting the prediction")
data = get_all_data()
data = generate_features(data)

first_day_of_tempo = (TODAY - pd.DateOffset(month=9, day=1)).tz_localize("Europe/Paris")
if first_day_of_tempo.date() >= TODAY:
first_day_of_tempo -= pd.DateOffset(years=1)
predictor = TempoPredictor(data[first_day_of_tempo:].copy())
selected_data = data[first_day_of_tempo:].copy()
print(selected_data)
predictor = TempoPredictor(selected_data)
import matplotlib.pyplot as plt
selected_data["production_norm"].plot()
selected_data["seuil_rouge"].plot()
selected_data["seuil_blanc_rouge"].plot()
plt.savefig("tempo.png")
tempo_dummies = predictor.predict()
our_tempo = pd.from_dummies(tempo_dummies).tz_convert("Europe/Paris").tz_localize(None)
our_tempo.columns = ["our_tempo"]
Expand Down
2 changes: 1 addition & 1 deletion src/energy_forecast/tempo_rte.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def predict(self):
"""
self.prediction_rouge = self.data[self.production_normed_f] > self.data["seuil_rouge"]
start_ROUGE_allowed = (self.prediction_rouge.index[0] + pd.DateOffset(month=10, day=31)) # "2015-10-31"
end_ROUGE_allowed = (self.prediction_rouge.index[-1] + pd.DateOffset(years=1,month=4, day=1) ) #"2016-04-01"
end_ROUGE_allowed = (self.prediction_rouge.index[-1] + pd.DateOffset(years=1, month=4, day=1) ) #"2016-04-01"
self.prediction_rouge[:start_ROUGE_allowed] = False
self.prediction_rouge[end_ROUGE_allowed:] = False
self.prediction_rouge[self.data["stock_rouge"] < 0] = False
Expand Down

0 comments on commit f612cfc

Please sign in to comment.