Skip to content

Timeseries Cross Validation #200

@jmrichardson

Description

@jmrichardson

Hi,

So far loving this package! Question, I am using time series data and would like to use a more sophisticated cross validation than TimeSeriesSplit offered by sklearn. Specifically, I am interested in using the following CV which has a similar API to sklearn:

https://github.com/sam31415/timeseriescv

Here is a snip of my code:

env = Environment(
    train_dataset=X_train,
    test_dataset=X_test,
    target_column='bin',
    results_path='HyperparameterHunterAssets',  # Where your result files will go
    metrics=['roc_auc_score'],  # Callables, or strings referring to `sklearn.metrics`
    cv_type=PurgedWalkForwardCV,
    cv_params=dict(n_splits=10, pred_times=pd.Series(times.index), eval_times=['t1']),
    verbose=1,
    # cv_type=TimeSeriesSplit,  # Class, or string in `sklearn.model_selection`
    # cv_params=dict(n_splits=5)
)

experiment = CVExperiment(
    model_initializer=XGBClassifier,
    model_init_params=dict(
        objective="reg:squarederror", max_depth=3, n_estimators=100, subsample=0.5
    ),
)

Here is the error output:

<11:23:49> Cross-Experiment Key:   'VfQ6_-2CMEXKfgeAQJXwJmO2KTTdPhBamZ4m9VqJaF4='
<11:23:49> Validated Environment:  'VfQ6_-2CMEXKfgeAQJXwJmO2KTTdPhBamZ4m9VqJaF4='
<11:23:49> Initialized Experiment: '4c491538-1ec9-49b6-8dca-380994441846'
<11:23:49> Hyperparameter Key:     'DD6sYbmG4UVOUoHZRxbuJUcovYaWVcZbXcP4dVGQacI='
<11:23:49> Uncaught exception!   TypeError: __init__() got an unexpected keyword argument 'pred_times'
Traceback (most recent call last):
  File "D:\Anaconda3\envs\alpha\lib\code.py", line 91, in runcode
    exec(code, self.locals)
  File "<input>", line 18, in <module>
  File "D:\Anaconda3\envs\alpha\lib\site-packages\hyperparameter_hunter\experiment_core.py", line 165, in __call__
    return super().__call__(*args, **kwargs)
  File "D:\Anaconda3\envs\alpha\lib\site-packages\hyperparameter_hunter\experiments.py", line 752, in __init__
    target_metric=target_metric,
  File "D:\Anaconda3\envs\alpha\lib\site-packages\hyperparameter_hunter\experiments.py", line 598, in __init__
    target_metric=target_metric,
  File "D:\Anaconda3\envs\alpha\lib\site-packages\hyperparameter_hunter\experiments.py", line 304, in __init__
    self.preparation_workflow()
  File "D:\Anaconda3\envs\alpha\lib\site-packages\hyperparameter_hunter\experiments.py", line 357, in preparation_workflow
    self._additional_preparation_steps()
  File "D:\Anaconda3\envs\alpha\lib\site-packages\hyperparameter_hunter\experiments.py", line 603, in _additional_preparation_steps
    self._initialize_folds()
  File "D:\Anaconda3\envs\alpha\lib\site-packages\hyperparameter_hunter\experiments.py", line 768, in _initialize_folds
    self.folds = cv_type(**self.cv_params)
TypeError: __init__() got an unexpected keyword argument 'pred_times'

It looks as though HH doesn't like the "pred_times" and "eval_times" arguments required by PurgedWalkForwardCV. Any way to allow the arguments to be passed?

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions