Saltar al contenido principal

TimeSeriesWindowConverter

Converter
DashAI.back.converters.simple_converters.TimeSeriesWindowConverter

Turn a time series into the supervised rows a regression model needs.

A forecasting dataset is a date column and a value column: one row per point in time, with nothing to regress on. This converter reshapes it into lag_k, ..., lag_1, target, where each row carries the k values that came before target. That is a plain tabular regression problem, so the result is used with RegressionTask and any regressor DashAI already has.

Given a window of 3 and the series 100, 120, 115, 140, 150, 160::

lag_3, lag_2, lag_1, target 100, 120, 115, 140 120, 115, 140, 150 115, 140, 150, 160

The scope selects the date column and the target column is chosen separately, the way every supervised converter takes its target. Rows are sorted by date before windowing, so the source ordering does not matter.

Two things to know before using the result:

  • Everything else is discarded. The output holds the lag columns and the target and nothing more, including the date column, because the rows no longer line up with the original ones.
  • Consecutive rows overlap by k - 1 values. A splitter that shuffles will therefore put near duplicate rows on both sides of the split and report a score that is too good. The output is regression data, so split it chronologically by turning shuffling off on the splitter rather than leaving it on.

Parameters

window_size : integer, default=3
How many past values each row carries. A window of 3 turns the series into rows of lag_3, lag_2, lag_1 and target, where target is the value that followed those three.

Methods

fit(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'TimeSeriesWindowConverter'

Defined on TimeSeriesWindowConverter

Identify the date column and the target, and check both are usable.

Parameters

x : DashAIDataset
The scoped columns. Exactly one must be a Date.
y : DashAIDataset, optional
The target column, holding the series to window.

Returns

TimeSeriesWindowConverter
The fitted converter instance (self).

get_output_type(self, column_name: str = None) -> DashAI.back.types.dashai_data_type.DashAIDataType

Defined on TimeSeriesWindowConverter

Return the type of a lag or target column.

Parameters

column_name : str, optional
Name of the output column. Unused, since every output column of this converter has the same type. Defaults to None.

Returns

DashAIDataType
Integer or Float, matching the target column.

transform(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'DashAIDataset'

Defined on TimeSeriesWindowConverter

Reshape the series into lag columns and a target.

Parameters

x : DashAIDataset
The scoped columns, holding the date column found during fit.
y : DashAIDataset, optional
The target column.

Returns

DashAIDataset
A dataset of window_size + 1 columns, lag_k down to lag_1 followed by target. Every other column is gone, and the first window_size rows are too, since no complete window precedes them.

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 BaseConverter

Get metadata for the converter, used by the DashAI frontend.

Parameters

cls : type
The converter class (injected automatically by Python for classmethods).

Returns

Dict[str, Any]
Dictionary containing display name, short description, image preview path, category, icon, color, and whether the converter is supervised.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

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.