Skip to main content

Simplify time series forecasting

Project description

This module aim is to do accurate and out of the box time series predictions.

Please refer to github and influxdb_blog for further informations.

Example use case (The dataframe need to have a columns named "time" and one named "y" in order to work)
my dataframe (df) is like below and have a 200 points seasonal pattern :
"time","y"
"1749-01",58.0
"1749-02",62.6
"1749-03",70.0
...
Code for prediction 365 steps ahead

from GTSFutur.GTSPredictor import GTSPredictor
model=GTSPredictor()
model.fit(df,look_back=400,freq_period=200,directory="My_directory_name")
prediction,lower,upper=model.predict(steps=365)

Code for prediction 365 steps ahead using the user interface

from GTSFutur.GTSPredictor import GTSPredictor
model=GTSPredictor()
model.fit_with_UI(df,directory="My_directory_name")
prediction,lower,upper=model.predict(steps=365)

This will open a matplotlib figure and you will be able to select the seasonal pattern with the mouse

plot

model.plot_prediction(df,prediction,lower,upper)

reuse a saved model

model=model.reuse(df,directory="My_directory_name")

Retrain the model (on new data for example)

model=model.retrain(df)

Requirements

pandas
numpy
statsmodels
tensorflow
matplotlib
scipy
sklearn
pickle

Quick methods explanation

fit needs only three inputs
-df : dataframe
with a time columns (string) and y the columns with the values to forecast.
-look_back : int
size of inputs (generaly freq_period *2 but always more than freq_period).
-freq_period : int
size in point of the seasonal pattern (ex 24 if daily seasonality for a signal sampled at 1h frequency).
-directory : str
Directory where the models are going to be saved, by default at the root (r".").

Once the model fitted it can by used by applying the predict function which need only two inputs:
-steps : int
number of points you want to forecast, by default 1.
-frame : Bool
If frame == True , compute an 95% intervalle and retruns 3 arrays | if frame == False return an array with the predicted values

Retrain allows your model to do incremental learning by retraining yours models with new data :
-df : dataframe
with a time columns (string) and y the columns with the values to forecast.
-look_back : int
size of inputs (generaly freq_period *2 but always more than freq_period).
-freq_period : int
size in point of the seasonal pattern (ex 24 if daily seasonality for a signal sampled at 1h frequency).

load_models allows to reuse saved model by loading it in the class :
-directory : str
name of directory contaning trend.h5,seasonal.h5,residual.h5 by default (r".") ie root of project

prediction_eval : once the prediction made
This function compute and print four differents metrics (mse ,mae ,r2 and median) to evaluate accuracy of the model prediction and real_data need to have the same size
-prediction : array
predicted values.
-real_data : array
real data.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gtsfutur, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size GTSFutur-0.1.1.tar.gz (10.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page