Skip to content

Add note about forecast to documentation of models #112

Merged
merged 4 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Pipeline ([#78](https://github.com/tinkoff-ai/etna-ts/pull/78))
- Sequence anomalies ([#96](https://github.com/tinkoff-ai/etna-ts/pull/96))
- 'is_weekend' feature in DateFlagsTransform ([#101](https://github.com/tinkoff-ai/etna-ts/pull/101))
- Documentation example for models and note about inplace nature of forecast ([#112](https://github.com/tinkoff-ai/etna-ts/pull/112))

### Changed
- SklearnTransform out column names ([#99](https://github.com/tinkoff-ai/etna-ts/pull/99))
Expand Down
31 changes: 31 additions & 0 deletions docs/source/models.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
Models
======

Models are used to make predictions. Let's look at the basic example of usage:

>>> import pandas as pd
>>> from etna.datasets import TSDataset, generate_ar_df
>>> from etna.transforms import LagTransform
>>> from etna.models import LinearPerSegmentModel
>>>
>>> df = generate_ar_df(periods=100, start_time="2021-01-01", ar_coef=[1/2], n_segments=2)
>>> ts = TSDataset(TSDataset.to_dataset(df), "D")
>>> lag_transform = LagTransform(in_column="target", lags=[3, 4, 5])
>>> ts.fit_transform(transforms=[lag_transform])
>>> future_ts = ts.make_future(3)
>>> model = LinearPerSegmentModel()
>>> model.fit(ts)
LinearPerSegmentModel(fit_intercept = True, normalize = False, )
>>> forecast_ts = model.forecast(future_ts)
segment segment_0 ... segment_1
feature regressor_target_lag_3 ... target
timestamp ...
2021-04-11 -0.090673 ... 0.286764
2021-04-12 -0.665337 ... 0.295589
2021-04-13 0.365363 ... 0.374554
[3 rows x 8 columns]

There is a key note to mention: `future_ts` and `forecast_ts` are the same objects.
Method `forecast` only fills 'target' columns in `future_ts` and return reference to it.

>>> forecast_ts is future_ts
True


.. _models:

.. currentmodule:: etna
Expand Down