GluonTS

repository·dev·Indexed 26 days ago

https://github.com/awslabs/gluonts

A Python package for probabilistic time series modeling, specializing in deep learning-based models built on PyTorch. Version 0.17.0.dev0 supports workflows including data loading via PandasDataset, training with DeepAREstimator, and generating probabilistic forecasts. The library includes a shell module for Amazon SageMaker integration and a nursery containing experimental implementations such as Attention-based Domain Adaptation (DAF), Probabilistic Few-Shot Forecasting, and Robust Multivariate Time-Series Forecasting.

Tokens
26.4K
Snippets
84
Records
144
Agent score
89%

What's inside gluonts

  1. Understand Probabilistic Forecasting in GluonTS

    dev

    GluonTS focuses on probabilistic forecasting, meaning instead of predicting a single point value, the models predict probability distributions.

    This allows you to understand the range of likely values and uncertainty. For example, a model might predict a median demand of 50 units but indicate that it is unlikely to exceed 60. This is often represented via prediction intervals such as p50, p90, p95, or p98 percentiles.

  2. Understand the `gluonts.ext` module

    dev
    gluonts.ext is a module containing extra GluonTS models that are not implemented using PyTorch or MXNet. Because these models do not belong to the gluonts.torch or gluonts.mx subpackages, they may require additional third-party dependencies to be installed before they can be used.
  3. Retrain models and then predict

    dev

    To retrain the models from scratch before making predictions:

    1. Train: Run the notebooks in ./3. code/2. train/. The order of execution within this folder does not matter.
      • This will overwrite existing files in ./5. models/ and ./2. data/processed/ (specifically test_000.pkl files).
    2. Predict: Once training is complete, follow the steps in the "Generate predictions using pre-trained models" guide.
  4. Train models for Robust Multivariate Time-Series Forecasting

    dev

    You can train different types of models (clean, augmented, or defended) using train.py or train_adv.py.

    Clean Model

    Train a standard model using train.py.

    Model with Data Augmentation

    Train a model using Gaussian data augmentation by adding the --gaussian flag.

    Model with Mini-Max Defense

    Train a model with mini-max defense using train_adv.py. This requires specifying --sparsity, --attack_params, and --lr.

  5. Set up the GluonTS development environment

    dev

    To set up the development environment, ensure you have Python 3.10 or higher installed. It is recommended to use uv for managing dependencies. Running the initial setup script and uv sync will install required packages and configure Git hooks for automated type and style checks during commits.

    ./dev_setup.sh
    
    # Install with uv (recommended)
    uv sync
  6. Use the Spliced Binned-Pareto distribution for heavy-tailed time series

    dev

    The Spliced Binned-Pareto distribution is designed to model time series with heavy-tailed noise in non-stationary scenarios. It handles extreme observations and captures time dependencies in higher-order moments (like tail heaviness), making it useful for anomaly detection where accurately modeling extreme events is critical.

    To implement this, you can use a DistributionalTCN to fit the Spliced Binned-Pareto distribution to your data and compare its performance against other distributions like Gaussian or standard Binned distributions.

  7. Build and preview GluonTS documentation

    dev

    You can build the project documentation using just. The output will be located in docs/_build/html. For direct editing of .rst files, use make livehtml to start a sphinx-autobuild session that automatically rebuilds the documentation on changes.

    # Build documentation
    just docs
    
    # Preview documentation (for .rst edits)
    cd docs
    make livehtml
    open http://127.0.0.1:8000
  8. Understand Target and Feature types in GluonTS

    dev

    When preparing data for forecasting, GluonTS distinguishes between the target (the values you want to predict) and features (additional information that impacts the target).

    Feature Types

    • Dynamic Features: Values that change at every time point (e.g., temperature, product price, or automatically generated features like day-of-the-week).
      • Note: Most models require dynamic features to be available for the future time range when making predictions.
    • Static Features: Values that describe a time series independently of time (e.g., store ID or product category).

    Feature Formats

    • Continuous (Real) Features: Numerical values where the magnitude has meaning (e.g., price).
    • Categorical Features: Discrete entities where the number is just an identifier (e.g., Store 0, 1, 2).