major overhaul of forecast pipeline #21
@ -223,7 +223,7 @@ def _process_sales(
|
|||||||
future_dates = pd.date_range(
|
future_dates = pd.date_range(
|
||||||
start=last_date + pd.DateOffset(months=1), periods=6, freq="MS"
|
start=last_date + pd.DateOffset(months=1), periods=6, freq="MS"
|
||||||
)
|
)
|
||||||
forecast = pd.DataFrame({"datum": future_dates.strftime("%m.%Y")}).set_index("datum")
|
forecast = pd.DataFrame({"datum": future_dates}).set_index("datum")
|
||||||
|
|
||||||
# Randomized Search
|
# Randomized Search
|
||||||
kfold = KFold(n_splits=5, shuffle=True)
|
kfold = KFold(n_splits=5, shuffle=True)
|
||||||
@ -255,8 +255,8 @@ def _process_sales(
|
|||||||
# print("dates: ", dates)
|
# print("dates: ", dates)
|
||||||
# ?? --- new: use monthly basis for time windows
|
# ?? --- new: use monthly basis for time windows
|
||||||
# baseline: 3 years - 36 months
|
# baseline: 3 years - 36 months
|
||||||
starting_date = datetime.datetime.now() - relativedelta(months=36)
|
# starting_date = datetime.datetime.now() - relativedelta(months=36)
|
||||||
# starting_date = dates.max() - relativedelta(months=36)
|
starting_date = dates.max() - relativedelta(months=36)
|
||||||
start_index = next(
|
start_index = next(
|
||||||
(i for i, date in enumerate(dates) if date >= starting_date), len(dates) - 1
|
(i for i, date in enumerate(dates) if date >= starting_date), len(dates) - 1
|
||||||
)
|
)
|
||||||
@ -319,6 +319,9 @@ def _process_sales(
|
|||||||
)
|
)
|
||||||
y_future = best_estimator.predict(X_future) # type: ignore
|
y_future = best_estimator.predict(X_future) # type: ignore
|
||||||
forecast["vorhersage"] = y_future
|
forecast["vorhersage"] = y_future
|
||||||
|
forecast["jahr"] = forecast.index.year # type: ignore
|
||||||
|
forecast["monat"] = forecast.index.month # type: ignore
|
||||||
|
forecast = forecast.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
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user