Skip to main content

Simplify time series forecasting

Project description

General Time Serie Prediction and Anomalies Detection

PyPI version
Exemple of LSTM + DECOMPOSITION prédiction :

LSTM PRED

Full documentation available at [https://gtsfutur.readthedocs.io/en/latest/].

Summary

-GSFutur object
-Example use case
-Requirements
-Some results

GTSPredictor object

This object simplify prediction by hidding all the paramaters for the user. Let's focus on the most important methods :
-fit()
-predict()
-retrain()
-prediction_eval()
-load_models()

Install

pip install GTSFutur

Use

Example use case (The dataframe needs 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 in order to do incremental learning)

# before the model need to be loaded either it's just after the first training or used reuse function
model=model.retrain(df)

Requirements

pandas
numpy
statsmodels
tensorflow
matplotlib
scipy
sklearn
pickle
xgboost

Results

LSTM PRED Theses are "out of the box" results. The only parameter to determine was the size of the seasonal pattern which is easy to find as he can be determine through visual inspection

GTSDetection object

Many differents models for anomaly detection.

List of models

IEQ_Detector

Mad_Detector

Variation_Detector

Period_Detector

Autoencoder_Detector

Wave_Detector

Use

Detect disruption in the seasonal shape for contextual anomalies:

    from GTSFutur.GTSDetector import Wave_Detector,Period_Detector,Mad_Detector,Variation_Detector,Autoencoder_Detector,IEQ_Detector
    detector=Period_Detector()
    detector.fit(data)
    anomaly=detector.detect(data,threshold=0.2)
    detector.plot_anomalies(anomaly,data)

Detect points far from the average statical distribution:

    from GTSFutur.GTSDetector import Wave_Detector,Period_Detector,Mad_Detector,Variation_Detector,Autoencoder_Detector,IEQ_Detector
    detector=IEQ_Detector()
    detector.fit(data)
    #alpha a severity parameter
    anomaly=detector.detect(data,alpha=1.96)
    detector.plot_anomalies(anomaly,data)

Detect points far from the median:

    from GTSFutur.GTSDetector import Wave_Detector,Period_Detector,Mad_Detector,Variation_Detector,Autoencoder_Detector,IEQ_Detector
    detector=Mad_Detector()
    detector.fit(data)
    anomaly=detector.detect(data,alpha=0.6785)
    detector.plot_anomalies(anomaly,data)

Detect important changes of values for measurements like mean,standard deviation and median on slidding windows:

    from GTSFutur.GTSDetector import Wave_Detector,Period_Detector,Mad_Detector,Variation_Detector,Autoencoder_Detector,IEQ_Detector
    detector=Variation_Detector(method="std")
    detector.fit(data)
    anomaly=detector.detect(data,threshold=0.5,windows_size=25)
    detector.plot_anomalies(anomaly,data)

Detect peaks once the signal denoised:

    from GTSFutur.GTSDetector import Wave_Detector,Period_Detector,Mad_Detector,Variation_Detector,Autoencoder_Detector,IEQ_Detector
    detector=Wave_Detector()
    detector.fit(data,threshold=0.3)
    anomaly=detector.detect(data,alpha=10)
    detector.plot_anomalies(anomaly,data)

Use a LSTM auto encoder to detect more complexe, global and contextual, anomalies:

    from GTSFutur.GTSDetector import Wave_Detector,Period_Detector,Mad_Detector,Variation_Detector,Autoencoder_Detector,IEQ_Detector
    detector=Autoencoder_Detector()
    detector.fit(100,data,"My_directory_name")
    anomaly=detector.detect(data,"My_directory_name",threshold=5)
    detector.plot_anomalies(anomaly,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.6.7.5
Filename, size File type Python version Upload date Hashes
Filename, size gtsfutur-0.1.6.7.5.tar.gz (21.3 MB) 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