Skip to content

felixsuarez0727/TinyTimeMixerDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Time Series Forecasting Demo with TinyTimeMixer

This project demonstrates time series forecasting using the tsfm_public library and the TinyTimeMixer model. It loads energy consumption data, performs preprocessing, generates forecasts, and visualizes the results.

What is TinyTimeMixer?

It is one of the many pretrained models from the family of "Granite Time Series". This models are developed by IBM. This models performs on principles of zero/few-shot learning, hence, it is used to provide predictions even with limited training data. This model is lightweight meaning it could run with minimial hardware requirements. This model is useful in scenarios where series data is scarce or diverse.

Further details here!

Check this academic paper!

Prerequisites

Before running the code, ensure you have the following installed:

  • Python 3.x
  • venv (virtual environment module)
  • pip (Python package installer)

Setup

  1. Create a virtual environment:

    python -m venv venv
  2. Activate the virtual environment:

    • On Windows:

      .\venv\Scripts\activate
    • On macOS and Linux:

      source venv/bin/activate
  3. Install the necessary dependencies:

    pip install "tsfm_public[notebooks] @ git+[https://github.com/ibm-granite/granite-tsfm.git@v0.2.12](https://github.com/ibm-granite/granite-tsfm.git@v0.2.12)"
        pip install -r requirements.txt

Running the Demo

Execute the demo.py script:

```bash
python demo.py
```

This script will:

  • Load the energy consumption dataset (energy_dataset.csv).
  • Fill missing data using forward fill.
  • Display the last few rows of the preprocessed data.
  • Generate a plot of the target time series.
  • Load the TinyTimeMixer forecasting model (ibm-granite/granite-timeseries-ttm-r1).
  • Create a forecasting pipeline.
  • Generate forecasts for the target time series.
  • Display the last few rows of the forecast.
  • Generate and display a plot comparing the actual data with the forecast.

Showing chart made with loaded data

The data loaded is used to build a chart. Data Preview

Dataset for demo.py

The dataset used in this demo is energy_dataset.csv, which contains hourly energy consumption data. It should be placed in the archive directory within the project root.

Dependencies

  • matplotlib
  • pandas
  • tsfm_public (from git+https://github.com/ibm-granite/granite-tsfm.git@v0.2.12)
  • torch>=1.8.0
  • numpy>=1.19.0
  • h5py>=3.1.0
  • matplotlib>=3.3.0
  • scikit-learn>=0.24.0
  • tqdm>=4.50.0
  • pandas>=1.1.0
  • seaborn>=0.11.0
  • scipy>=1.6.0
  • tensorboard>=2.5.0

Notes

About demo.py

  • You can experiment with different TinyTimeMixer models by changing the model name in the from_pretrained function.
  • The context_length parameter controls the number of historical data points used for forecasting.
  • Feel free to modify the script to explore different forecasting scenarios and datasets.

About

This project demonstrates time series forecasting using the tsfm_public library and the TinyTimeMixer model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages