statsforecast
Forecasting using statistical models
Install
pip install statsforecast
How to use
import numpy as np
import pandas as pd
from IPython.display import display, Markdown
from statsforecast import StatsForecast
from statsforecast.models import random_walk_with_drift, seasonal_naive, ses
def display_df(df):
display(Markdown(df.to_markdown()))
rng = np.random.RandomState(0)
serie1 = np.arange(1, 8)[np.arange(100) % 7] + rng.randint(-1, 2, size=100)
serie2 = np.arange(100) + rng.rand(100)
series = pd.DataFrame(
{
'ds': pd.date_range('2000-01-01', periods=serie1.size + serie2.size, freq='D'),
'y': np.hstack([serie1, serie2]),
},
index=pd.Index([0] * serie1.size + [1] * serie2.size, name='unique_id')
)
display_df(pd.concat([series.head(), series.tail()]))
| unique_id | ds | y |
|---|---|---|
| 0 | 2000-01-01 00:00:00 | 0 |
| 0 | 2000-01-02 00:00:00 | 2 |
| 0 | 2000-01-03 00:00:00 | 2 |
| 0 | 2000-01-04 00:00:00 | 4 |
| 0 | 2000-01-05 00:00:00 | 5 |
| 1 | 2000-07-14 00:00:00 | 95.7649 |
| 1 | 2000-07-15 00:00:00 | 96.9441 |
| 1 | 2000-07-16 00:00:00 | 97.75 |
| 1 | 2000-07-17 00:00:00 | 98.3394 |
| 1 | 2000-07-18 00:00:00 | 99.4895 |
fcst = StatsForecast(series, models=[random_walk_with_drift, (seasonal_naive, 7), (ses, 0.1)], freq='D', n_jobs=2)
forecasts = fcst.forecast(5)
display_df(forecasts)
2021-12-08 20:33:06 statsforecast.core INFO: Computing forecasts
2021-12-08 20:33:07 statsforecast.core INFO: Computed forecasts for random_walk_with_drift.
2021-12-08 20:33:07 statsforecast.core INFO: Computed forecasts for seasonal_naive_season_length-7.
2021-12-08 20:33:07 statsforecast.core INFO: Computed forecasts for ses_alpha-0.1.
| unique_id | ds | random_walk_with_drift | seasonal_naive_season_length-7 | ses_alpha-0.1 |
|---|---|---|---|---|
| 0 | 2000-04-10 00:00:00 | 3.0303 | 3 | 3.85506 |
| 0 | 2000-04-11 00:00:00 | 3.06061 | 5 | 3.85506 |
| 0 | 2000-04-12 00:00:00 | 3.09091 | 4 | 3.85506 |
| 0 | 2000-04-13 00:00:00 | 3.12121 | 7 | 3.85506 |
| 0 | 2000-04-14 00:00:00 | 3.15152 | 6 | 3.85506 |
| 1 | 2000-07-19 00:00:00 | 100.489 | 93.0166 | 90.4709 |
| 1 | 2000-07-20 00:00:00 | 101.489 | 94.2307 | 90.4709 |
| 1 | 2000-07-21 00:00:00 | 102.489 | 95.7649 | 90.4709 |
| 1 | 2000-07-22 00:00:00 | 103.489 | 96.9441 | 90.4709 |
| 1 | 2000-07-23 00:00:00 | 104.489 | 97.75 | 90.4709 |
Metadata
Release files for statsforecast 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| statsforecast-0.2.0.tar.gz | 13.4 kB | Without provenance | Details for statsforecast-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| statsforecast-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for statsforecast-0.2.0-py3-none-any.whl |
Total release size: 25.8 kB
Release files / statsforecast-0.2.0.tar.gz
| Download URL | statsforecast-0.2.0.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45d51cbf895175b0860fc5fe79ad5524f12dd50e9959fc0c7354fd4f2d56b51a
|
|
BLAKE2b-256 checksum How to use checksums |
6be885f261e125923a17a45772e1029de728c224541de270197697736f9227fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / statsforecast-0.2.0-py3-none-any.whl
| Download URL | statsforecast-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9e4150083795a7d5c962162527bc9a140141cd3957b72c5fb21f27dbc065755
|
|
BLAKE2b-256 checksum How to use checksums |
bc688f939502e6c22c2d302c8067cb6824c54c974ca484044aa2a892e2c4c6c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Security for statsforecast 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.