Shortcuts

TabularForecastingData

class flash.tabular.forecasting.data.TabularForecastingData(train_input=None, val_input=None, test_input=None, predict_input=None, data_fetcher=None, transform=<class 'flash.core.data.io.input_transform.InputTransform'>, transform_kwargs=None, val_split=None, batch_size=None, num_workers=0, sampler=None, pin_memory=True, persistent_workers=False)[source]

The TabularForecastingData class is a DataModule with a set of classmethods for loading data for tabular forecasting.

classmethod from_data_frame(time_idx=None, target=None, group_ids=None, parameters=None, train_data_frame=None, val_data_frame=None, test_data_frame=None, predict_data_frame=None, input_cls=<class 'flash.tabular.forecasting.input.TabularForecastingDataFrameInput'>, transform=<class 'flash.core.data.io.input_transform.InputTransform'>, transform_kwargs=None, data_fetcher=None, val_split=None, batch_size=None, num_workers=0, sampler=None, pin_memory=True, persistent_workers=True, **input_kwargs)[source]

Creates a TabularForecastingData object from the given data frames.

Note

The time_idx, target, and group_ids do not need to be provided if parameters are passed instead. These can be obtained from the parameters attribute of the TabularForecastingData object that contains your training data.

To learn how to customize the transforms applied for each stage, read our customizing transforms guide.

Parameters
  • time_idx (Optional[str]) – Column denoting the time index of each observation.

  • target (Union[str, List[str], None]) – Column denoting the target or list of columns denoting the target.

  • group_ids (Optional[List[str]]) – List of column names identifying a time series. This means that the group_ids identify a sample together with the time_idx. If you have only one timeseries, set this to the name of a column that is constant.

  • parameters (Optional[Dict[str, Any]]) – Parameters to use for the timeseries if time_idx, target, and group_ids are not provided (e.g. when loading data for inference or validation).

  • train_data_frame (Optional[DataFrame]) – The pandas DataFrame to use when training.

  • val_data_frame (Optional[DataFrame]) – The pandas DataFrame to use when validating.

  • test_data_frame (Optional[DataFrame]) – The pandas DataFrame to use when testing.

  • predict_data_frame (Optional[DataFrame]) – The pandas DataFrame to use when predicting.

  • input_cls (Type[Input]) – The Input type to use for loading the data.

  • transform (TypeVar(INPUT_TRANSFORM_TYPE, Type[flash.core.data.io.input_transform.InputTransform], Callable, Tuple[Union[StrEnum, str], Dict[str, Any]], Union[StrEnum, str], None)) – The InputTransform type to use.

  • transform_kwargs (Optional[Dict]) – Dict of keyword arguments to be provided when instantiating the transforms.

  • input_kwargs (Any) – Additional keyword arguments to be used when creating the TimeSeriesDataset.

Return type

TabularForecastingData

Returns

The constructed TabularForecastingData.

Examples

We have a DataFrame data with the following contents:

>>> data.head(3)
   series  time_idx     value
0       0         0 -0.000000
1       0         1  0.141552
2       0         2  0.232782
>>> from pandas import DataFrame
>>> from flash import Trainer
>>> from flash.tabular import TabularForecaster, TabularForecastingData
>>> datamodule = TabularForecastingData.from_data_frame(
...     "time_idx",
...     "value",
...     ["series"],
...     train_data_frame=data,
...     predict_data_frame=DataFrame.from_dict(
...         {
...             "time_idx": list(range(50)),
...             "value": [0.0] * 50,
...             "series": [0] * 50,
...         }
...     ),
...     time_varying_unknown_reals=["value"],
...     max_encoder_length=30,
...     max_prediction_length=20,
...     batch_size=32,
... )
>>> model = TabularForecaster(
...     datamodule.parameters,
...     backbone="n_beats",
...     backbone_kwargs={"widths": [16, 256]},
... )
>>> trainer = Trainer(fast_dev_run=True)
>>> trainer.fit(model, datamodule=datamodule)  
Training...
>>> trainer.predict(model, datamodule=datamodule)  
Predicting...
input_transform_cls

alias of flash.core.data.io.input_transform.InputTransform

property parameters: Optional[Dict[str, Any]]

The parameters dictionary from the TimeSeriesDataSet object created from the train data when constructing the TabularForecastingData object.

Return type

Optional[Dict[str, Any]]

Read the Docs v: latest
Versions
latest
stable
0.8.2
0.8.1.post0
0.8.1
0.8.0
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.2
0.5.1
0.5.0
0.4.0
0.3.2
0.3.1
0.3.0
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0post1
Downloads
html
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.