feat(Tests): added basic unit tests for walk_forward_train_test() (#22)

* feat(Tests): added basic unit tests for walk_forward_train_test()

* fix(Tests): inherit from BaseEstimator, fix index problems in walk_forward_train_test

* fix(WalkForward): predictions were mistakenly removed, oops

* fix(WalkForward): mistakenly re-assiging model
This commit is contained in:
Mark Aron Szulyovszky
2021-12-15 17:54:03 +01:00
committed by GitHub
parent 64721330a3
commit 6440ced32c
5 changed files with 47 additions and 4 deletions
+3 -3
View File
@@ -12,8 +12,8 @@ def walk_forward_train_test(
retrain_every: int
) -> tuple[pd.Series, pd.Series]:
predictions = pd.Series(index=y.index)
models = pd.Series(index=y.index)
predictions = pd.Series(index=y.index).rename(model_name)
models = pd.Series(index=y.index).rename(model_name)
train_from = window_size
train_till = y.index[-1]
@@ -30,7 +30,7 @@ def walk_forward_train_test(
if iterations_since_retrain >= retrain_every or pd.isna(models[i-1]):
current_model = clone(model)
current_model.fit(X_slice.to_numpy(), y_slice)
current_model.fit(X_slice.to_numpy(), y_slice.to_numpy())
iterations_since_retrain = 0
else:
current_model = models[i-1]