A library to forecast timeseires data
Project description
Time Series Forecaster
An automated machine learning toolkit for timeseries forecasting built using python and its libraries.
Features
Takes an input time series (uni-variate or multi-variate) and performs the following functionalities.
- Pre-processing, Imputations, Stationarity Check
- Transformations (to achieve stationarity, if required)
- Timeseries modeling to select the best model based on RMSE
- Reverse Transformations (if required)
- Returns the forecasts for the user specified periods and the best model RMSE
Requirements
- Python>=3.4
Installation
$ pip3 install tsf
Simple Usage
>>> import pandas as pd
>>> ts_data = pd.read_csv('ts_data.csv')
>>> from tsf.forecaster import TimeSeriesForecaster as tsf
>>> ts_model = tsf()
>>> forecasted, training_predicted, rmse = ts_model.forecast(ts_data=ts_data, forecast_feature='Close', forecast_periods=3)
Parameters: | ts_data: Time Series data frame for which forecast is to be generated forecast_feature: The feature/endog variable which is to be forecasted forecast_periods: Number of future periods for which to generate forecast |
Attributes: | forecasted: The forecasted time series using the best model for the number of periods mentioned by forecast_periods training_predicted: The predictions on the training data used to built the timeseries model rmse: RMSE on the training data for the best model |
Console Output
The root mean square error for the forecast is 0.934
The number of predictions requested is 3 and predictions are as below:
36 718.050266
37 771.421601
38 829.542411
Detailed Description
The code takes the timeseries data and follows the steps below to forecast timeseries for the specified future periods.
- Preprocess Timeseries Data - Missing values are handled using forward fill
- Data is then checked for stationarity using Dickey-Fuller Statistical Test
- Threshold/Critical Value for the test is set to 1%
- If the Statistical Value of the test statistic is less than 1% critical value, then the timeseries is considered to be stationary
- If the timeseries is stationary (result of step 2), then modeling is performed on the data using various timeseries modeling techniques (as mentioned in Features section) and best model is selected based on RMSE to output the forecasted value for fuuture periods specified by the user.
- If the timeseries is not stationary:
- First log transformation is performed and step 2 is repeated.
- If found stationary, step 3 is performed else the next transformations are performed in the following order : Moving Average, Exponentially weighted moving average, Differencing, Second Order Differencing
- For all these transformations Step 2 and Step 3 are performed
- If no transformation makes the timeseries stationary, then timeseries modeling cannot be performed
- For the timeseries which returns the forecast values as a result of step 3, reverse transformations are performed to scale back the data to original scale. For example: If data acheieved stationarity through Log Transformation then reverse log transformation is performed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tsf-0.1.7.tar.gz
(13.0 kB
view hashes)
Built Distribution
tsf-0.1.7-py3-none-any.whl
(14.6 kB
view hashes)