gluonts.dataset.common module#
- class gluonts.dataset.common.CategoricalFeatureInfo(*, name: str, cardinality: str)[source]#
Bases:
BaseModel
- cardinality: str#
- name: str#
- gluonts.dataset.common.FileDataset(path: 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) Dataset [source]#
- gluonts.dataset.common.ListDataset(data_iter: 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[BasicFeatureInfo] = None, feat_static_cat: List[CategoricalFeatureInfo] = [], feat_static_real: List[BasicFeatureInfo] = [], feat_dynamic_real: List[BasicFeatureInfo] = [], feat_dynamic_cat: List[CategoricalFeatureInfo] = [], prediction_length: Optional[int] = None)[source]#
Bases:
BaseModel
- feat_dynamic_cat: List[CategoricalFeatureInfo]#
- feat_dynamic_real: List[BasicFeatureInfo]#
- feat_static_cat: List[CategoricalFeatureInfo]#
- feat_static_real: List[BasicFeatureInfo]#
- freq: str#
- prediction_length: Optional[int]#
- target: Optional[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, DateOffset], use_timestamp: bool = False, name: str = 'start')[source]#
Bases:
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.
- freq: Union[str, 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:
NamedTuple
- row: int#
Alias for field number 1
- source: str#
Alias for field number 0
- class gluonts.dataset.common.TrainDatasets(metadata: MetaData, train: Dataset, test: Optional[Dataset] = None)[source]#
Bases:
NamedTuple
A dataset containing two subsets, one to be used for training purposes, and the other for testing purposes, as well as metadata.
- save(path_str: str, writer: 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.
- gluonts.dataset.common.load_datasets(metadata: Path, train: Path, test: Optional[Path], one_dim_target: bool = True, cache: bool = False) 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: