utils¶
Classes
Builder for PytorchForecasting dataset. |
|
Mixin for Pytorch Forecasting models. |
|
Mixin for |
- class PytorchForecastingDatasetBuilder(max_encoder_length: int = 30, min_encoder_length: Optional[int] = None, min_prediction_idx: Optional[int] = None, min_prediction_length: Optional[int] = None, max_prediction_length: int = 1, static_categoricals: Optional[List[str]] = None, static_reals: Optional[List[str]] = None, time_varying_known_categoricals: Optional[List[str]] = None, time_varying_known_reals: Optional[List[str]] = None, time_varying_unknown_categoricals: Optional[List[str]] = None, time_varying_unknown_reals: Optional[List[str]] = None, variable_groups: Optional[Dict[str, List[int]]] = None, constant_fill_strategy: Optional[Dict[str, Union[str, float, int, bool]]] = None, allow_missing_timesteps: bool = True, lags: Optional[Dict[str, List[int]]] = None, add_relative_time_idx: bool = True, add_target_scales: bool = True, add_encoder_length: Union[bool, str] = True, target_normalizer: Union[pytorch_forecasting.data.encoders.TorchNormalizer, pytorch_forecasting.data.encoders.NaNLabelEncoder, pytorch_forecasting.data.encoders.EncoderNormalizer, str, List[Union[pytorch_forecasting.data.encoders.TorchNormalizer, pytorch_forecasting.data.encoders.NaNLabelEncoder, pytorch_forecasting.data.encoders.EncoderNormalizer]], Tuple[Union[pytorch_forecasting.data.encoders.TorchNormalizer, pytorch_forecasting.data.encoders.NaNLabelEncoder, pytorch_forecasting.data.encoders.EncoderNormalizer]]] = 'auto', categorical_encoders: Optional[Dict[str, pytorch_forecasting.data.encoders.NaNLabelEncoder]] = None, scalers: Optional[Dict[str, Union[sklearn.preprocessing._data.StandardScaler, sklearn.preprocessing._data.RobustScaler, pytorch_forecasting.data.encoders.TorchNormalizer, pytorch_forecasting.data.encoders.EncoderNormalizer]]] = None)[source]¶
Builder for PytorchForecasting dataset.
Init dataset builder.
Parameters here is used for initialization of
pytorch_forecasting.data.timeseries.TimeSeriesDataSet
object.- Parameters
max_encoder_length (int) –
min_encoder_length (Optional[int]) –
min_prediction_idx (Optional[int]) –
min_prediction_length (Optional[int]) –
max_prediction_length (int) –
static_categoricals (Optional[List[str]]) –
static_reals (Optional[List[str]]) –
time_varying_known_categoricals (Optional[List[str]]) –
time_varying_known_reals (Optional[List[str]]) –
time_varying_unknown_categoricals (Optional[List[str]]) –
time_varying_unknown_reals (Optional[List[str]]) –
variable_groups (Optional[Dict[str, List[int]]]) –
constant_fill_strategy (Optional[Dict[str, Union[str, float, int, bool]]]) –
allow_missing_timesteps (bool) –
lags (Optional[Dict[str, List[int]]]) –
add_relative_time_idx (bool) –
add_target_scales (bool) –
add_encoder_length (Union[bool, str]) –
target_normalizer (Union[pytorch_forecasting.data.encoders.TorchNormalizer, pytorch_forecasting.data.encoders.NaNLabelEncoder, pytorch_forecasting.data.encoders.EncoderNormalizer, str, List[Union[pytorch_forecasting.data.encoders.TorchNormalizer, pytorch_forecasting.data.encoders.NaNLabelEncoder, pytorch_forecasting.data.encoders.EncoderNormalizer]], Tuple[Union[pytorch_forecasting.data.encoders.TorchNormalizer, pytorch_forecasting.data.encoders.NaNLabelEncoder, pytorch_forecasting.data.encoders.EncoderNormalizer]]]) –
categorical_encoders (Optional[Dict[str, pytorch_forecasting.data.encoders.NaNLabelEncoder]]) –
scalers (Optional[Dict[str, Union[sklearn.preprocessing._data.StandardScaler, sklearn.preprocessing._data.RobustScaler, pytorch_forecasting.data.encoders.TorchNormalizer, pytorch_forecasting.data.encoders.EncoderNormalizer]]]) –
- create_inference_dataset(ts: etna.datasets.tsdataset.TSDataset, horizon: int) pytorch_forecasting.data.timeseries.TimeSeriesDataSet [source]¶
Create inference dataset.
This method should be used only after
create_train_dataset
that is used during model training.- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Time series dataset.
horizon (int) – Size of prediction to make.
- Raises
ValueError: – if method was used before
create_train_dataset
- Return type
- create_train_dataset(ts: etna.datasets.tsdataset.TSDataset) pytorch_forecasting.data.timeseries.TimeSeriesDataSet [source]¶
Create train dataset.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Time series dataset.
- Return type
- set_params(**params: dict) etna.core.mixins.TMixin ¶
Return new object instance with modified parameters.
Method also allows to change parameters of nested objects within the current object. For example, it is possible to change parameters of a
model
in aPipeline
.Nested parameters are expected to be in a
<component_1>.<...>.<parameter>
form, where components are separated by a dot.- Parameters
**params – Estimator parameters
self (etna.core.mixins.TMixin) –
params (dict) –
- Returns
New instance with changed parameters
- Return type
etna.core.mixins.TMixin
Examples
>>> from etna.pipeline import Pipeline >>> from etna.models import NaiveModel >>> from etna.transforms import AddConstTransform >>> model = model=NaiveModel(lag=1) >>> transforms = [AddConstTransform(in_column="target", value=1)] >>> pipeline = Pipeline(model, transforms=transforms, horizon=3) >>> pipeline.set_params(**{"model.lag": 3, "transforms.0.value": 2}) Pipeline(model = NaiveModel(lag = 3, ), transforms = [AddConstTransform(in_column = 'target', value = 2, inplace = True, out_column = None, )], horizon = 3, )
- to_dict()¶
Collect all information about etna object in dict.
- class PytorchForecastingMixin[source]¶
Mixin for Pytorch Forecasting models.
- fit(ts: etna.datasets.tsdataset.TSDataset)[source]¶
Fit model.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – TSDataset to fit.
- Returns
model