Skip to main content

A library to forecast timeseires data

Project description

Time Series Forecaster

Build Status

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.

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.

  1. Preprocess Timeseries Data - Missing values are handled using forward fill
  2. Data is then checked for stationarity using Dickey-Fuller Statistical Test
    1. Threshold/Critical Value for the test is set to 1%
    2. If the Statistical Value of the test statistic is less than 1% critical value, then the timeseries is considered to be stationary
  3. 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.
  4. If the timeseries is not stationary:
    1. First log transformation is performed and step 2 is repeated.
    2. 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
    3. For all these transformations Step 2 and Step 3 are performed
    4. If no transformation makes the timeseries stationary, then timeseries modeling cannot be performed
  5. 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


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)

Uploaded Source

Built Distribution

tsf-0.1.7-py3-none-any.whl (14.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page