Skip to main content

Automatic and fast Gaussian process for time serie prediction.

Project description

makeprediction logo

MakePrediction is a package for building an automatic Gaussian process regression (GPR) models for time series prediction in Python. It was originally created by [Hanany Tolba].

  • MakePrediction is an open source project. If you have relevant skills and are interested in contributing then please do contact us (hananytolba@yahoo.com).*

Gaussian process regression (GPR):

The advantages of this Gaussian processes package:

  • Very fast training.
  • Very fast prediction.
  • The prediction can be interpolated as desired.
  • The training of the model is automatic, no kernel function needs to be specified. An optimal choice of kernel is automatically elaborated.
  • Possibility to choose a kernel function manually.
  • The prediction is probabilistic (Gaussian) so that confidence intervals can be calculated and used to decide whether to make a strategic decision.
  • The package provides an API for deployment.

Where do you find time series?

  • Energy
  • Finance
  • Medical, Biotech, and Healthcare
  • IoT Monitoring
  • Supply Chain
  • Agriculture
  • Retail

What does makeprediction do?

  • Modelling and analysis time series.
  • Automatic time-series prediction (forecasting).
  • Real-Time time series prediction.
  • Deploy on production the fitted (or saved) makeprediction model.

Applications:

  • Energy consumption prediction.
  • Energy demand prediction.
  • Stock price prediction.
  • Stock market prediction.
  • ...

Latest release from PyPI

  • pip install makeprediction

Latest source from GitHub

Be aware that the master branch may change regularly, and new commits may break your code.

MakePrediction GitHub repository, run:

  • pip install .

Example

Here is a simple example:

import pandas as pd
import numpy as np

from makeprediction.gpts import GaussianProcessTimeSerie
from makeprediction.kernels import RBF, White
from makeprediction.visualization import Visualizer

#generate time series
###############################
  
x = pd.date_range(start = datetime.datetime(2021,1,1), periods=1000, freq = '3s' )
time2num = date2num(x)

# Simulate a data
date = pd.date_range(start = '2022',periods = 1000, freq = '30T')
# As sum of RBF kernel and Gaussian noise kernel
kernel = RBF() + White(variance = .01) 
# add mean and variance 
data = 1000 + 50*kernel.simulate(date, seed = np.random.seed(1234))
# create a dataframe with data
df = pd.DataFrame(data = data, index = date, columns=['value'])
df.head()


# split time serie into train and test
TRAIN_SIZE = int(.8*len(df))
df_train, df_test = df[:TRAIN_SIZE], df[TRAIN_SIZE:]

# Create an instance of the class GaussianProcessTimeSerie with train data:
#########################################
model = GaussianProcessTimeSerie(df_train.index, df_train.value)
# Show train data with test data 
Visualizer.iplot(model, df_test.index, df_test.value)
makeprediction logo
# fit the model
model.fit()
#predict with model and plot result
model.predict(df_test.index)
Visualizer.iplot(model, df_test.index, df_test.value)
makeprediction logo
# Show initial score 
model.score(df_test.value)

# Online prediction with updating 
ypred = np.empty(shape = (0,))
ypred_std = np.empty(shape = (0,))

for x,y in df_test.itertuples():
    # predict for x value
    yp,yp_std = model.predict(x,return_value = True)
    ypred = np.append(ypred,yp)
    ypred_std = np.append(ypred_std,yp_std)
    # update the model for (x,y)
    data = {'x_update': x, 'y_update': y}
    model.update(**data)
#Set all new prediction to the model    
model.set_prediction(df_test.index, ypred, ypred_std)

# Show new prediction 

Visualizer.iplot(model, df_test.index, df_test.value)
makeprediction logo

The previous prediction with updating, can be obtained simply by the "predict" method as follows:

makeprediction logo
# Show new score 
model.score(df_test.value)

{'TrainErrors': {'MBE': 1.9652784019209927e-05,
  'MAE': 3.8085808450980743,
  'MSE': 22.963876468774956,
  'RMSE': 4.792063904913514,
  'NRMSE': 0.004642410409421008,
  'R2': 0.9867205336559287},
 'TestErrors': {'MBE': -0.3680353774898197,
  'MAE': 4.749355093190354,
  'MSE': 34.36287534118008,
  'RMSE': 5.8619856142078755,
  'NRMSE': 0.005905883435157759,
  'R2': 0.9879230611904987}}

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

makeprediction-4.0.0-py3-none-any.whl (58.1 kB view details)

Uploaded Python 3

File details

Details for the file makeprediction-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: makeprediction-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 58.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.3 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.13

File hashes

Hashes for makeprediction-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1af72c3586a304604aa3581782b63b6146cccc30357ec4ede8532acce2049f61
MD5 547e8a5f1494f6f17844a399068f5394
BLAKE2b-256 28b47ff414db0cfd247b13d1a4080c84ae1963281cff41a5f4068db39043689a

See more details on using hashes here.

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