gluonts.dataset.schema package#

class gluonts.dataset.schema.Array(ndim: int, dtype: Optional[Type[gluonts.dataset.schema.types.T]] = None, time_dim: Optional[int] = None)[source]#

Bases: gluonts.dataset.schema.types.GenericType[gluonts.dataset.schema.types.T]

Array type with fixed number of dimensions, but optional dtype and time dimension.

This class ensures that the handled output data, will have ndim number of dimensions. If specified, dtype will be applied to the input to force a consistent type, e.g. np.float32. time_dim is just a marker, indicating which axis notes the time-axis, useful for splitting. If time_dim is none, the array is time invariant.

dtype: Optional[Type[gluonts.dataset.schema.types.T]] = None#
ndim: int#
time_dim: Optional[int] = None#
class gluonts.dataset.schema.Default(*args, **kwds)[source]#

Bases: gluonts.dataset.schema.types.GenericType[gluonts.dataset.schema.types.T]

base: Optional[gluonts.dataset.schema.types.Type] = None#
value: gluonts.dataset.schema.types.T#
class gluonts.dataset.schema.Period(freq: Union[str, NoneType] = None)[source]#

Bases: object

freq: Optional[str] = None#
class gluonts.dataset.schema.Schema(fields: Dict[str, Union[Type, gluonts.dataset.schema.types.Type]] = <factory>)[source]#

Bases: object

add(name: str, ty: Union[Type, gluonts.dataset.schema.types.Type])[source]#
add_if(condition: bool, name: str, ty: typing.Union[typing.Type, gluonts.dataset.schema.types.Type], default=<dataclasses._MISSING_TYPE object>)[source]#
apply(entry) dict[source]#
default_fields: Dict[str, Any]#
fields: Dict[str, Union[Type, gluonts.dataset.schema.types.Type]]#
class gluonts.dataset.schema.Translator(fields: Dict[str, gluonts.dataset.schema.translate.Op], drop: bool = False)[source]#

Bases: object

Simple translation for GluonTS Datasets.

A given translator transforms an input dictionary (data-entry) into an output dictionary.

Basic usage:

>>> tl = Translator.parse(x="a[0]")
>>> data = {"a": [1, 2, 3]}
>>> assert tl(data)["x"] == 1

A translator first copies all input fields into a new dictionary, before applying the translations. Thus, an empty Translator acts like the identity function for dictionaries:

>>> identity = Translator()
>>> data = {"a": 1, "b": 2, "c": 3}
>>> assert identity(data) == data

Using Translator.parse(...)`, one can define expressions to be applied to the input data. For example, Translator.parse(x="y") will write the the value of y to the x column in the output.

These right-hand expressions support indexing (e.g. y[1]), attribute access (e.g. x.T) and method invocation (e.g. y.transpose(1, 0)).

drop: bool = False#
fields: Dict[str, gluonts.dataset.schema.translate.Op]#
get_fields()[source]#
static parse(fields: Optional[dict] = None, drop: bool = False, **kwargs_fields) gluonts.dataset.schema.translate.Translator[source]#
class gluonts.dataset.schema.Type[source]#

Bases: object