Skip to content

Commit

Permalink
fix for pycaret#2480 and expanded unit tests to check all split types
Browse files Browse the repository at this point in the history
  • Loading branch information
ngupta23 committed Aug 6, 2022
1 parent 38ab3fc commit 5f93256
Show file tree
Hide file tree
Showing 2 changed files with 374 additions and 22 deletions.
20 changes: 14 additions & 6 deletions pycaret/internal/pycaret_experiment/pycaret_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,16 @@ def test(self):
if self._ml_usecase != MLUsecase.TIME_SERIES:
return self.dataset.loc[self.idx[1], :]
else:
# Return the X_test indices not y_test indices since X_test indices
# are the expanded indices for handling FH with gaps.
# Return the y_test indices not X_test indices.
# X_test indices are expanded indices for handling FH with gaps.
# But if we return X_test indices, then we will get expanded test
# indices even for univariate time series without exogenous variables
# which would be confusing. Hence, we return y_test indices here and if
# we want to get X_test indices, then we use self.X_test directly.
# Refer:
# https://github.com/alan-turing-institute/sktime/issues/2598#issuecomment-1203308542
# https://github.com/alan-turing-institute/sktime/blob/4164639e1c521b112711c045d0f7e63013c1e4eb/sktime/forecasting/model_evaluation/_functions.py#L196
return self.dataset.loc[self.idx[2], :]
return self.dataset.loc[self.idx[1], :]

@property
def X(self):
Expand Down Expand Up @@ -610,12 +614,16 @@ def test_transformed(self):
],
axis=1,
)
# Return the X_test indices not y_test indices since X_test indices
# are the expanded indices for handling FH with gaps.
# Return the y_test indices not X_test indices.
# X_test indices are expanded indices for handling FH with gaps.
# But if we return X_test indices, then we will get expanded test
# indices even for univariate time series without exogenous variables
# which would be confusing. Hence, we return y_test indices here and if
# we want to get X_test indices, then we use self.X_test directly.
# Refer:
# https://github.com/alan-turing-institute/sktime/issues/2598#issuecomment-1203308542
# https://github.com/alan-turing-institute/sktime/blob/4164639e1c521b112711c045d0f7e63013c1e4eb/sktime/forecasting/model_evaluation/_functions.py#L196
return all_data.loc[self.idx[2]]
return all_data.loc[self.idx[1]]

@property
def X_transformed(self):
Expand Down
Loading

0 comments on commit 5f93256

Please sign in to comment.