Skip to content

Walk-forward CV/optimization #3202

Closed
Closed

Description

@mjbommar

To my knowledge, sklearn does not currently support rigorous cross-validation of time-dependent problems. All out-of-the-box cross-validation routines will construct training folds that include future information relative to test folds.

One approach is to implement walk-forward/backward cross-validation, which constrains fold selection so that CV training folds are from time prior to CV test folds, i.e., out-of-sample. Common choices include trailing/rolling windows (k-2, k-1; k) and cumulative windows (1, 2, ..., k-1; k)

References:

If we are OK including this in sklearn.cross_validation, my plan was to add:

  • sklearn.cross_validation.TrailingWalkForward(ordered_index=...)
  • sklearn.cross_validation.CumulativeWalkForward(ordered_index=...)

We'd also need to discuss if/how to integrate this with grid_search,

Activity

  1. GaelVaroquaux commented on May 26, 2014

    @GaelVaroquaux
    Member

    To my knowledge, sklearn does not currently support rigorous cross-validation
    of time-dependent problems.

    I believe that this is out of scope, as we do not do any kind of
    structured prediction, and have removed HMMs because they required such
    concepts.

  2. jnothman commented on May 26, 2014

    @jnothman
    Member

    Hmm. I don't think this pertains to structured prediction exactly. The
    predictors, targets and evaluation are still over isolated decisions.
    Scikit Learn's cross validation already considers structure between
    samples, as in LeaveOneLabelOut (what Michael's first citation describes as
    sampling from different universes). But providing this information is also
    the main challenge for supporting nested cross
    validationhttps://github.com//issues/2904
    .

    We have also recently discussed data dependencies implied in ordering with
    relation to (Stratified)KFold and shuffling. Providing a robust alternative
    where shuffling is going to create train-test interdependence may be
    methodologically beneficial.

    Yet while I don't think it's clearly out of scope, I think it should
    probably remain in a gist for now, partially because the demand for and
    seminality of these techniques is unclear.

    On 27 May 2014 01:37, Gael Varoquaux [email protected] wrote:

    To my knowledge, sklearn does not currently support rigorous
    cross-validation
    of time-dependent problems.

    I believe that this is out of scope, as we do not do any kind of
    structured prediction, and have removed HMMs because they required such
    concepts.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/3202#issuecomment-44198963
    .

  3. mjbommar commented on May 27, 2014

    @mjbommar
    ContributorAuthor

    OK, thanks; gist or tiny module it is. #2904 is a very interesting read. Has there been any renewed discussion about it?

  4. GaelVaroquaux commented on May 27, 2014

    @GaelVaroquaux
    Member

    Yet while I don't think it's clearly out of scope, I think it should
    probably remain in a gist for now, partially because the demand for and
    seminality of these techniques is unclear.

    Fair enough. I agree with your summary.

  5. jnothman commented on Jun 25, 2014

    @jnothman
    Member

    I think this can be closed, as it is not an issue for the scikit-learn project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions