Skip to content

Commit

Permalink
retain comments of former copies in split
Browse files Browse the repository at this point in the history
  • Loading branch information
ourownstory committed Sep 13, 2024
1 parent d660a68 commit 40746e2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions neuralprophet/df_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,11 @@ def _crossvalidation_with_time_threshold(df, n_lags, n_forecasts, k, fold_pct, f
threshold_time_stamp = df_merged["ds"].iloc[-1]
df_fold_aux = pd.DataFrame()
for df_name, df_i in df.groupby("ID"):
# df_i = df_i.copy(deep=True)
df_aux = df_i.iloc[: len(df_i[df_i["ds"] < threshold_time_stamp]) + 1].reset_index(drop=True)
df_fold_aux = pd.concat((df_fold_aux, df_aux), ignore_index=True)
df = df_fold_aux
# df = df.copy(deep=True)
folds = folds[::-1]
return folds

Expand Down Expand Up @@ -827,11 +829,14 @@ def split_considering_timestamp(df, n_lags, n_forecasts, inputs_overbleed, thres
df_val = pd.DataFrame()
for df_name, df_i in df.groupby("ID"):
if df[df["ID"] == df_name]["ds"].max() < threshold_time_stamp:
# df_i = df_i.copy(deep=True)
df_train = pd.concat((df_train, df_i), ignore_index=True)
elif df[df["ID"] == df_name]["ds"].min() > threshold_time_stamp:
# df_i = df_i.copy(deep=True)
df_val = pd.concat((df_val, df_i), ignore_index=True)
else:
df_aux = df_i
# df_i = df_i.copy(deep=True)
n_train = len(df_aux[df_aux["ds"] < threshold_time_stamp])
split_idx_train = n_train + n_lags + n_forecasts - 1
split_idx_val = split_idx_train - n_lags if inputs_overbleed else split_idx_train
Expand Down

0 comments on commit 40746e2

Please sign in to comment.