Saltar al contenido principal

RollingOriginSplitter

Splitter
DashAI.back.splitters.RollingOriginSplitter

Cross-validate a series by walking the origin forward through time.

The model is fitted on everything before each origin and scored on the horizon steps after it; the origin then advances by one horizon and the model is refitted with more history. The last horizon is the test::

n = 48, horizon = 6, 3 origins

validation fit [0, 24) forecast [24, 30) validation fit [0, 30) forecast [30, 36) validation fit [0, 36) forecast [36, 42) test fit [0, 42) forecast [42, 48)

This is what k-fold cannot do for a series: its folds train on rows that come after the ones they score, which measures interpolation rather than forecasting. The validation score is the mean over the origins.

Parameters​

horizon : integer, default=6
How many steps ahead the model is scored, from every origin and on the test. A step is one period of the series: a month on a monthly series.
n_origins : integer, default=3
How many validation windows the model is scored on, each one horizon after the last and each with more history.

Methods​

cuts(self, n_steps: 'int') -> 'Dict[str, Any]'

Defined on OriginSplitter

Where a series of n_steps steps is cut.

Parameters

n_steps : int
How many steps the series has.

Returns

dict
{"horizon", "validation_origins", "test_origin", "n_steps"}. Origin o fits on steps [0, o) and forecasts [o, o + h).

explainable_partitions(cls, split_indexes: 'Dict[str, Any]') -> 'Dict'

Defined on OriginSplitter

No partition of rows to explain: a backtest's cuts are steps.

explainable_splits(cls, split_indexes: 'Dict[str, Any]') -> 'List[Dict[str, Any]]'

Defined on BaseSplitter

Describe the partitions of a run that an explainer may target.

Parameters

split_indexes : dict
The Run.split_indexes payload, already parsed.

Returns

list[dict]
One {"name", "rows"} entry per non-empty partition, followed by an all entry. Empty when the run has no data to explain.

get_credential(self, name: str)

Defined on ConfigObject

Resolve a registered credential component by name.

Parameters

name : str
Credential component class name (e.g. "HuggingFaceCredential").

Returns

BaseCredential
An instance of the requested credential component.

get_metadata(cls) -> 'Dict[str, Any]'

Defined on BaseSplitter

Return metadata describing how this splitter carves the dataset.

Returns

Dict[str, Any]
Mapping with partitioning, which the frontend uses to decide whether the splitter belongs to the holdout or the cross-validation strategy, and geometry, the shape of the carve.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

needed_steps(self) -> 'int'

Defined on OriginSplitter

The fewest steps a series needs for these cuts.

prepare_y(self, y)

Defined on BaseSplitter

Encode the target variable for stratified splitting.

Parameters

y : object
Target values to encode. This may be a list, a pandas-like object, or a DashAI dataset that exposes a single target column.

Returns

object
Encoded labels suitable for stratified splitting.

preview(cls, params, dataset, split_type=None, indexes=None)

Defined on OriginSplitter

One bar per origin and the test (see BaseSplitter.preview).

split(self, x: "'DashAIDataset'", y: "'DashAIDataset'")

Defined on OriginSplitter

Not how a backtest is cut: see cuts.

split_indexes(self, x: "'DashAIDataset'", y: "'DashAIDataset'") -> 'List'

Defined on OriginSplitter

Not how a backtest is cut: see cuts.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.

Parameters

raw_data : dict
A dictionary with the data provided by the user to initialize the model.

Returns

dict
A validated dictionary with the necessary objects.

validate_size(self, n_rows: 'int') -> 'None'

Defined on OriginSplitter

Refuse a dataset too short for these cuts (see cuts).

Compatible with​