mixins¶
Classes
Base class for model mixins. |
|
|
Mixin for holding methods for multi-segment prediction. |
Mixin for models that don't support prediction intervals and don't need context for prediction. |
|
Mixin for models that don't support prediction intervals and need context for prediction. |
|
|
Mixin for holding methods for per-segment prediction. |
Mixin for models that support prediction intervals and don't need context for prediction. |
|
Mixin for models that support prediction intervals and need context for prediction. |
|
Implementation of |
- class MultiSegmentModelMixin(base_model: Any)[source]¶
Mixin for holding methods for multi-segment prediction.
It currently isn’t working with prediction intervals and context.
Init MultiSegmentModel.
- Parameters
base_model (Any) – Internal model which will be used to forecast segments, expected to have fit/predict interface
- fit(ts: etna.datasets.tsdataset.TSDataset) etna.models.mixins.MultiSegmentModelMixin [source]¶
Fit model.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
- Returns
Model after fit
- Return type
- get_model() Any [source]¶
Get internal model that is used inside etna class.
Internal model is a model that is used inside etna to forecast segments, e.g.
catboost.CatBoostRegressor
orsklearn.linear_model.Ridge
.- Returns
Internal model
- Return type
Any
- class NonPredictionIntervalContextIgnorantModelMixin[source]¶
Mixin for models that don’t support prediction intervals and don’t need context for prediction.
- forecast(ts: etna.datasets.tsdataset.TSDataset, return_components: bool = False) etna.datasets.tsdataset.TSDataset [source]¶
Make predictions.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
return_components (bool) – If True additionally returns forecast components
- Returns
Dataset with predictions
- Return type
- predict(ts: etna.datasets.tsdataset.TSDataset, return_components: bool = False) etna.datasets.tsdataset.TSDataset [source]¶
Make predictions with using true values as autoregression context if possible (teacher forcing).
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
return_components (bool) – If True additionally returns prediction components
- Returns
Dataset with predictions
- Return type
- class NonPredictionIntervalContextRequiredModelMixin[source]¶
Mixin for models that don’t support prediction intervals and need context for prediction.
- forecast(ts: etna.datasets.tsdataset.TSDataset, prediction_size: int, return_components: bool = False) etna.datasets.tsdataset.TSDataset [source]¶
Make predictions.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
prediction_size (int) – Number of last timestamps to leave after making prediction. Previous timestamps will be used as a context for models that require it.
return_components (bool) – If True additionally returns forecast components
- Returns
Dataset with predictions
- Return type
- predict(ts: etna.datasets.tsdataset.TSDataset, prediction_size: int, return_components: bool = False) etna.datasets.tsdataset.TSDataset [source]¶
Make predictions with using true values as autoregression context if possible (teacher forcing).
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
prediction_size (int) – Number of last timestamps to leave after making prediction. Previous timestamps will be used as a context for models that require it.
return_components (bool) – If True additionally returns prediction components
- Returns
Dataset with predictions
- Return type
- class PerSegmentModelMixin(base_model: Any)[source]¶
Mixin for holding methods for per-segment prediction.
Init PerSegmentModelMixin.
- Parameters
base_model (Any) – Internal model which will be used to forecast segments, expected to have fit/predict interface
- fit(ts: etna.datasets.tsdataset.TSDataset) etna.models.mixins.PerSegmentModelMixin [source]¶
Fit model.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
- Returns
Model after fit
- Return type
- get_model() Dict[str, Any] [source]¶
Get internal models that are used inside etna class.
Internal model is a model that is used inside etna to forecast segments, e.g.
catboost.CatBoostRegressor
orsklearn.linear_model.Ridge
.- Returns
dictionary where key is segment and value is internal model
- Return type
Dict[str, Any]
- class PredictionIntervalContextIgnorantModelMixin[source]¶
Mixin for models that support prediction intervals and don’t need context for prediction.
- forecast(ts: etna.datasets.tsdataset.TSDataset, prediction_interval: bool = False, quantiles: Sequence[float] = (0.025, 0.975), return_components: bool = False) etna.datasets.tsdataset.TSDataset [source]¶
Make predictions.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
prediction_interval (bool) – If True returns prediction interval for forecast
quantiles (Sequence[float]) – Levels of prediction distribution. By default 2.5% and 97.5% are taken to form a 95% prediction interval
return_components (bool) – If True additionally returns forecast components
- Returns
Dataset with predictions
- Return type
- predict(ts: etna.datasets.tsdataset.TSDataset, prediction_interval: bool = False, quantiles: Sequence[float] = (0.025, 0.975), return_components: bool = False) etna.datasets.tsdataset.TSDataset [source]¶
Make predictions with using true values as autoregression context if possible (teacher forcing).
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
prediction_interval (bool) – If True returns prediction interval for forecast
quantiles (Sequence[float]) – Levels of prediction distribution. By default 2.5% and 97.5% are taken to form a 95% prediction interval
return_components (bool) – If True additionally returns prediction components
- Returns
Dataset with predictions
- Return type
- class PredictionIntervalContextRequiredModelMixin[source]¶
Mixin for models that support prediction intervals and need context for prediction.
- forecast(ts: etna.datasets.tsdataset.TSDataset, prediction_size: int, prediction_interval: bool = False, quantiles: Sequence[float] = (0.025, 0.975), return_components: bool = False) etna.datasets.tsdataset.TSDataset [source]¶
Make predictions.
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
prediction_size (int) – Number of last timestamps to leave after making prediction. Previous timestamps will be used as a context for models that require it.
prediction_interval (bool) – If True returns prediction interval for forecast
quantiles (Sequence[float]) – Levels of prediction distribution. By default 2.5% and 97.5% are taken to form a 95% prediction interval
return_components (bool) – If True additionally returns forecast components
- Returns
Dataset with predictions
- Return type
- predict(ts: etna.datasets.tsdataset.TSDataset, prediction_size: int, prediction_interval: bool = False, quantiles: Sequence[float] = (0.025, 0.975), return_components: bool = False) etna.datasets.tsdataset.TSDataset [source]¶
Make predictions with using true values as autoregression context if possible (teacher forcing).
- Parameters
ts (etna.datasets.tsdataset.TSDataset) – Dataset with features
prediction_size (int) – Number of last timestamps to leave after making prediction. Previous timestamps will be used as a context for models that require it.
prediction_interval (bool) – If True returns prediction interval for forecast
quantiles (Sequence[float]) – Levels of prediction distribution. By default 2.5% and 97.5% are taken to form a 95% prediction interval
return_components (bool) – If True additionally returns prediction components
- Returns
Dataset with predictions
- Return type
- class SaveNNMixin[source]¶
Implementation of
AbstractSaveable
torch related classes.It saves object to the zip archive with 2 files:
metadata.json: contains library version and class name.
object.pt: object saved by
torch.save
.
- classmethod load(path: pathlib.Path) typing_extensions.Self ¶
Load an object.
Warning
This method uses
dill
module which is not secure. It is possible to construct malicious data which will execute arbitrary code during loading. Never load data that could have come from an untrusted source, or that could have been tampered with.- Parameters
path (pathlib.Path) – Path to load object from.
- Returns
Loaded object.
- Return type
typing_extensions.Self
- save(path: pathlib.Path)¶
Save the object.
- Parameters
path (pathlib.Path) – Path to save object to.