Skip to main content

TempportalPredictionsKit: toolset for timeseries data predictions

Project description

tpk (Temporal Predictions Kit)

A collection of tools, models and functionalities for hanling timeseries datasets

Test Passing Coverage Downloads Package version Supported Python versions
CodeQL Dependency Review License Code of Conduct Discord

Installation

tpk requires Python 3.7 or newer, and the easiest way to install it is via pip:

pip install tpk"

Simple Example

To illustrate how to use tpk, we train a model and make predictions using the airpassengers dataset. The dataset consists of a single time series of monthly passenger numbers between 1949 and 1960. We train the model on the first nine years and make predictions for the remaining three years.

import pandas as pd
import matplotlib.pyplot as plt

from gluonts.dataset.pandas import PandasDataset
from gluonts.dataset.split import split
from gluonts.torch import DeepAREstimator
from tpk.torch import TPKEstimator

# Load data from a CSV file into a PandasDataset
df = pd.read_csv(
    "https://raw.githubusercontent.com/AileenNielsen/"
    "TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv",
    index_col=0,
    parse_dates=True,
)
dataset = PandasDataset(df, target="#Passengers")

# Split the data for training and testing
training_data, test_gen = split(dataset, offset=-36)
test_data = test_gen.generate_instances(prediction_length=12, windows=3)

# Train the model and make predictions
model = TPKEstimator(
    prediction_length=12, freq="M", trainer_kwargs={"max_epochs": 5}
).train(training_data)

forecasts = list(model.predict(test_data.input))

# Plot predictions
plt.plot(df["1954":], color="black")
for forecast in forecasts:
  forecast.plot()
plt.legend(["True values"], loc="upper left", fontsize="xx-large")
plt.show()
todo: replace me

[train-test]

Note, the forecasts are displayed in terms of a probability distribution and the shaded areas represent the 50% and 90% prediction intervals.

Contributing

If you wish to contribute to the project, please refer to our contribution guidelines.

Citing

If you use tpk in a scientific publication, we encourage you to add the following references to the related papers, in addition to any model-specific references that are relevant for your work:

Links

Documentation

Stay in touch

Please show your support and stay in touch by:

Your support helps us to stay in touch with you and encourages us to continue developing and improving the framework. Thank you for your support!


Contributors

Thanks to all of these amazing people who made the project better!

Download files

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

Source Distribution

tpk-0.0.1.dev0.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

tpk-0.0.1.dev0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file tpk-0.0.1.dev0.tar.gz.

File metadata

  • Download URL: tpk-0.0.1.dev0.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for tpk-0.0.1.dev0.tar.gz
Algorithm Hash digest
SHA256 e764a5621aec0119ce87b4c451cc05472da07ad3802873c35e677459047cba29
MD5 190528a260952fbb66f1f7c4224fedd5
BLAKE2b-256 53130fcc4375f72eb4292439fdf3a919deedb5f3797079e9ec8c7a9747991b4b

See more details on using hashes here.

File details

Details for the file tpk-0.0.1.dev0-py3-none-any.whl.

File metadata

  • Download URL: tpk-0.0.1.dev0-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for tpk-0.0.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 41d7965c5be40b3b6a7c09459f4fc73aa40c2352bb28d291a64e2deabf88e72f
MD5 ac5b7584032fa650c230b197480df491
BLAKE2b-256 f1dcce61a77b4349109e1c5235204462bc1efab20f38d169e412f198c24e6725

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