FBruzzesi / timebasedcv

Time based splits for cross validation
https://fbruzzesi.github.io/timebasedcv/
MIT License
30 stars 1 forks source link

sklearn compatibility #10

Closed FBruzzesi closed 1 year ago

FBruzzesi commented 1 year ago

Create a split class which is CV splitter compatible.

Sketch of it could be:

class TimeBasedCVSplitter(TimeBasedSplit):
    ...
    # init requires a start and an end date

    def split(self, X, y):
        return super().split(..., self.start, self.end)

    def get_n_splits(self):
        len(tuple(self._splits_from_period(self.start, self.end))

Depends on the support of TimeBasedSplit(...).split(...) for start and end dates in #9.