No project description provided
Project description
forecastout
ForecastOut makes predictions for univariate time series using both statistical and machine learning approaches.
The algorithm works for both monthly and daily data.
In the case of monthly data, ForecastOut makes predictions using different statistical models (ARIMA, variations of Holt-Winters, Prophet, etc.) and then ensembles them using backtesting. A Naive Seasonal model is averaged into the resulting prediction in case the latter is not plausible.
For daily data, ForecastOut first aggregates the data (by summing or averaging) on a monthly basis and applies the algorithm described above to make a monthly forecast. Then, it disaggregates the monthly forecast to a daily basis using the time series and calendar information in a Random Forest.
The algorithm provides not only the forecast output and 95% confidence bands but also detailed results of each model, backtesting, and time series decomposition.
Installation
pip install forecastout
Quickstart
To make a prediction, you only need one necessary input: a pandas DataFrame with two columns:
- date: string format "YYYY-MM-DD" (e.g., "2024-01-01").
- value: integer or float format (e.g., 1000.0).
It should contain at least 24 monthly observations (if the data is daily, it should cover more than 24 months).
import pandas as pd
from forecastout import ForecastOut
forecastout = ForecastOut(
df=pd.DataFrame()
)
This will directly execute a prediction for 15 months for the inserted time series input. You can access the results as follows:
# -- Monthly forecast output
print(forecastout.df_monthly_forecast)
# -- Monthly forecast predictions by model
print(forecastout.df_predictions_by_model)
# -- Daily forecast output (if daily data)
print(forecastout.df_daily_forecast)
# -- Time series decomposition
print(forecastout.df_ts_decomposition)
# -- Backtesting predictions for each model
print(forecastout.df_predictions_bt)
# -- Daily decomposition percentage (if daily data)
print(forecastout.df_daily_shares)
Inputs
ForecastOut can customize the results through the following parameters.
import pandas as pd
from forecastout import ForecastOut
forecastout = ForecastOut(
df=pd.DataFrame(),
sum_aggregation=True,
horizon=3,
months_to_backtest=3,
models_to_use=['autoarima', 'holtwinters', 'prophet'],
average_top_models_number=1
)
- sum_aggregation (bool): If True, it adds daily data. If False, it averages daily data.
- horizon (int): Number of periods to forecast.
- months_to_backtest (int): Number of periods to do the backtesting.
- models_to_use (list): List of models to be used. ForecastOut has available 'autoarima', 'holtwinters' and 'prophet' (new coming soon).
- average_top_models_number (int): Number of models to use as average (if 1, it selects the most precise model in the backtesting).
Remarks
- Calendar Data available is only for Spain when doing the disaggregation from monthly to daily data (more calendars will be available in the future).
- In case the input DataFrame contains gaps, they will be assumed to be 0 value.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file forecastout-0.0.5.tar.gz
.
File metadata
- Download URL: forecastout-0.0.5.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.18 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f20c9e8c6ed24fb802a436543b485bf08bf63d750cce5fb90f6e2c69eb929922 |
|
MD5 | 63d1dfc39da0a2f02dc71f95d22b05ec |
|
BLAKE2b-256 | 5f1d0507dee7e4cd918f49b6d16a0daf30d84457d0cd96513590afbcd4da0d16 |
File details
Details for the file forecastout-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: forecastout-0.0.5-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.18 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa70cc542594b762d4d72490faafdd475ff03da2a2b642d2fb006e02823417e6 |
|
MD5 | 6b760ab45ab36e18703d105c9e418773 |
|
BLAKE2b-256 | 72a967114243d799c1ab16ea2d24f7f0d05fc256d167af113065b6c201771d15 |