gluonts.dataset.common module#

class gluonts.dataset.common.BasicFeatureInfo(*, name: str)[source]#

Bases: pydantic.v1.main.BaseModel

name: str#
class gluonts.dataset.common.CategoricalFeatureInfo(*, name: str, cardinality: str)[source]#

Bases: pydantic.v1.main.BaseModel

cardinality: str#
name: str#
gluonts.dataset.common.FileDataset(path: pathlib.Path, freq: str, one_dim_target: bool = True, cache: bool = False, use_timestamp: bool = False, loader_class=None, pattern='*', levels=2, translate=None, ignore_hidden=True) gluonts.dataset.Dataset[source]#
gluonts.dataset.common.ListDataset(data_iter: gluonts.dataset.Dataset, freq: str, one_dim_target: bool = True, use_timestamp: bool = False, translate: Optional[dict] = None) List[Dict[str, Any]][source]#

Dataset backed directly by a list of dictionaries.

Parameters
  • data_iter – Iterable object yielding all items in the dataset. Each item should be a dictionary mapping strings to values. For instance: {“start”: “2014-09-07”, “target”: [0.1, 0.2]}.

  • freq – Frequency of the observation in the time series. Must be a valid Pandas frequency.

  • one_dim_target – Whether to accept only univariate target time series.

class gluonts.dataset.common.MetaData(*, freq: str, target: Optional[gluonts.dataset.common.BasicFeatureInfo] = None, feat_static_cat: List[gluonts.dataset.common.CategoricalFeatureInfo] = [], feat_static_real: List[gluonts.dataset.common.BasicFeatureInfo] = [], feat_dynamic_real: List[gluonts.dataset.common.BasicFeatureInfo] = [], feat_dynamic_cat: List[gluonts.dataset.common.CategoricalFeatureInfo] = [], prediction_length: Optional[int] = None)[source]#

Bases: pydantic.v1.main.BaseModel

class Config[source]#

Bases: pydantic.v1.config.BaseConfig

allow_population_by_field_name: bool = True#
feat_dynamic_cat: List[gluonts.dataset.common.CategoricalFeatureInfo]#
feat_dynamic_real: List[gluonts.dataset.common.BasicFeatureInfo]#
feat_static_cat: List[gluonts.dataset.common.CategoricalFeatureInfo]#
feat_static_real: List[gluonts.dataset.common.BasicFeatureInfo]#
freq: str#
prediction_length: Optional[int]#
target: Optional[gluonts.dataset.common.BasicFeatureInfo]#
class gluonts.dataset.common.ProcessDataEntry(freq: str, one_dim_target: bool = True, use_timestamp: bool = False)[source]#

Bases: object

class gluonts.dataset.common.ProcessStartField(*, freq: Union[str, pandas._libs.tslibs.offsets.DateOffset], use_timestamp: bool = False, name: str = 'start')[source]#

Bases: pydantic.v1.main.BaseModel

Transform the start field into a Period with the given frequency.

Parameters
  • name (str) – Name of the field to transform.

  • freq (Union[str, pandas._libs.tslibs.offsets.DateOffset]) – Frequency to use. This must be a valid Pandas frequency string.

class Config[source]#

Bases: object

arbitrary_types_allowed = True#
freq: Union[str, pandas._libs.tslibs.offsets.DateOffset]#
name: str#
use_timestamp: bool#
class gluonts.dataset.common.ProcessTimeSeriesField(name, is_required: bool, is_static: bool, is_cat: bool)[source]#

Bases: object

Converts a time series field identified by name from a list of numbers into a numpy array.

Constructor parameters modify the conversion logic in the following way:

If is_required=True, throws a GluonTSDataError if the field is not present in the Data dictionary.

If is_cat=True, the array type is np.int32, otherwise it is np.float32.

If is_static=True, asserts that the resulting array is 1D, otherwise asserts that the resulting array is 2D. 2D dynamic arrays of shape (T) are automatically expanded to shape (1,T).

Parameters
  • name – Name of the field to process.

  • is_required – Whether the field must be present.

  • is_cat – Whether the field refers to categorical (i.e. integer) values.

  • is_static – Whether the field is supposed to have a time dimension.

class gluonts.dataset.common.SourceContext(source, row)[source]#

Bases: tuple

row: int#

Alias for field number 1

source: str#

Alias for field number 0

class gluonts.dataset.common.TrainDatasets(metadata: gluonts.dataset.common.MetaData, train: gluonts.dataset.Dataset, test: Optional[gluonts.dataset.Dataset] = None)[source]#

Bases: tuple

A dataset containing two subsets, one to be used for training purposes, and the other for testing purposes, as well as metadata.

metadata: gluonts.dataset.common.MetaData#

Alias for field number 0

save(path_str: str, writer: gluonts.dataset.DatasetWriter, overwrite=False) None[source]#

Saves an TrainDatasets object to a JSON Lines file.

Parameters
  • path_str – Where to save the dataset.

  • overwrite – Whether to delete previous version in this folder.

test: Optional[gluonts.dataset.Dataset]#

Alias for field number 2

train: gluonts.dataset.Dataset#

Alias for field number 1

gluonts.dataset.common.infer_file_type(path)[source]#
gluonts.dataset.common.load_datasets(metadata: pathlib.Path, train: pathlib.Path, test: Optional[pathlib.Path], one_dim_target: bool = True, cache: bool = False) gluonts.dataset.common.TrainDatasets[source]#

Loads a dataset given metadata, train and test path.

Parameters
  • metadata – Path to the metadata file

  • train – Path to the training dataset files.

  • test – Path to the test dataset files.

  • one_dim_target – Whether to load FileDatasets as univariate target time series.

  • cache – Indicates whether the FileDatasets should be cached or not.

Returns

An object collecting metadata, training data, test data.

Return type

TrainDatasets