major overhaul of forecast pipeline #21

Merged
foefl merged 15 commits from prediction_to_future into main 2025-04-16 09:24:34 +00:00
Showing only changes of commit 14c4efedf7 - Show all commits

View File

@ -238,6 +238,7 @@ def _process_sales(
too_few_month_points: bool = True too_few_month_points: bool = True
forecast: pd.DataFrame | None = None forecast: pd.DataFrame | None = None
# change sliding window to monthly basis
for start_year in range(current_year - 4, first_year - 1, -1): for start_year in range(current_year - 4, first_year - 1, -1):
train = cast( train = cast(
pd.DataFrame, pd.DataFrame,
@ -274,9 +275,10 @@ def _process_sales(
best_score_mae = error best_score_mae = error
best_score_r2 = cast(float, r2_score(y_test, y_pred)) best_score_r2 = cast(float, r2_score(y_test, y_pred))
best_start_year = start_year best_start_year = start_year
# overwrite with pre-defined prognosis DF
forecast = test.copy() forecast = test.copy()
forecast.loc[:, "vorhersage"] = y_pred forecast.loc[:, "vorhersage"] = y_pred
# remove
if forecast is not None: if forecast is not None:
forecast = forecast.drop(SALES_FEAT, axis=1).reset_index(drop=True) forecast = forecast.drop(SALES_FEAT, axis=1).reset_index(drop=True)
best_score_mae = best_score_mae if not math.isinf(best_score_mae) else None best_score_mae = best_score_mae if not math.isinf(best_score_mae) else None