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

Uploaded Source

Built Distribution

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

Uploaded Python 3

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