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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file tsf-0.1.7.tar.gz.

File metadata

  • Download URL: tsf-0.1.7.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for tsf-0.1.7.tar.gz
Algorithm Hash digest
SHA256 0a5a1d269780c64b54b2c133830b49e84fd14ca9587175ecd03e8b161b512ad0
MD5 04e1dc99cbd64732a742df682db9284b
BLAKE2b-256 c026aae31ef23d51c5ccee936d37bfb62d62abfc73c0c9f419de59c0062101ae

See more details on using hashes here.

File details

Details for the file tsf-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: tsf-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for tsf-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 45004afaaa68b635366a1e47447d00a2ccf3534cea0aa9f8e2603ee23a21cf17
MD5 f1d3534ca927666c511080ded353b524
BLAKE2b-256 bc5cc098bb1e3cfb54cd285dcc3dd221940a696b49542fa7a25323ef2f7c83eb

See more details on using hashes here.

Supported by

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