PyPOTS: Python Toolbox for Machine Learning on Partially-Observed Time Series

repository·main·Indexed 24 days ago

https://github.com/wenjiedu/pypots

A specialized Python toolbox providing unified APIs and classical and state-of-the-art algorithms for handling missing values in multivariate time series data. It supports tasks including Imputation (IMPT), Forecasting (FCST), Classification (CLAF), Clustering (CLUS), Anomaly Detection (ANOD), and time series representation learning (TS2Vec). The library includes various model types such as Neural Nets, LLMs, Time-Series Foundation Models (TSFM), Probabilistic, and Matrix Factorization methods.

Tokens
37.3K
Snippets
35
Records
150
Agent score
83%

What's inside PyPOTS

  1. Overview of PyPOTS capabilities and tasks

    main

    PyPOTS is a Python toolbox designed for machine learning on Partially-Observed Time Series (POTS). It provides algorithms to handle multivariate time series that contain missing values due to sensor failures, communication errors, or other malfunctions.

    PyPOTS supports the following tasks:

    • IMPT: Imputation (filling in missing values)
    • FCST: Forecasting (predicting future values)
    • CLAF: Classification (categorizing time series)
    • CLUS: Clustering (grouping similar time series)
    • ANOD: Anomaly Detection (identifying outliers)
    • TS2Vec: Time series representation learning and vectorization

    Note that some models (marked with 🧑‍🔧 in documentation) are adapted for POTS data using specific embedding strategies and training approaches (ORT+MIT) to handle missingness, even if they weren't originally designed for partially-observed data.

  2. Overview of PyPOTS

    main

    PyPOTS (pronounced "Pie Pots") is a Python toolkit designed for modeling Partially-Observed Time Series (POTS). It addresses the common real-world problem where sensor failures, communication anomalies, or other unforeseen reasons lead to missing values in time-series data.

    PyPOTS provides a unified API, detailed algorithm learning guides, and application examples to help engineers and researchers handle POTS data modeling efficiently, allowing them to focus on their core problems rather than data imputation complexities. The library continuously updates with both classical and state-of-the-art algorithms for partially-observed multivariate time series.

  3. Overview of available PyPOTS algorithms and tasks

    main

    PyPOTS provides a wide range of algorithms categorized by their underlying model type (LLM&TSFM, Neural Net, Probabilistic, MF, or Naive) and the time-series tasks they support.

    Supported tasks include:

    • IMPT: Imputation
    • FCST: Forecasting
    • CLAF: Classification
    • CLUS: Clustering
    • ANOD: Anomaly Detection

    You can find implementation examples for most algorithms in the examples/ directory of the repository, organized by task (e.g., examples/imputation/, examples/forecasting/).

  4. Available classification algorithms in pypots.classification

    main

    The pypots.classification module provides a collection of specialized algorithms for time series classification tasks. These algorithms are organized into submodules based on their underlying architecture or methodology.

    Available algorithm modules include:

    • saits: SAITS-based classification
    • tefn: TEFN-based classification
    • brits: BRITS-based classification
    • itransformer: iTransformer-based classification
    • patchtst: PatchTST-based classification
    • csai: CSAI-based classification
    • timesnet: TimesNet-based classification
    • autoformer: Autoformer-based classification
    • ts2vec: TS2Vec-based classification
    • grud: GRUD-based classification
    • raindrop: Raindrop-based classification
    • seft: SEFT-based classification
  5. Understand the PyPOTS repository structure

    main

    The PyPOTS repository is organized by task type and shared infrastructure. The main source package is located in pypots/ and is divided into task-specific modules, reusable neural network components, and data utilities.

    Core Directory Map

    • pypots/imputation/, pypots/forecasting/, pypots/classification/, pypots/clustering/, pypots/anomaly_detection/, pypots/representation/: Task-specific model folders.
    • pypots/base.py: Shared model abstractions (BaseModel, BaseNNModel).
    • pypots/data/: Dataset and IO helpers (e.g., BaseDataset, HDF5 saving, validation).
    • pypots/nn/: Reusable PyTorch modules, loss functions, and metrics.
    • pypots/optim/: Optimizer abstractions wrapping PyTorch optimizers.
    • pypots/cli/: Command-line interface.
    • pypots/utils/: Logging and file operations.
  6. Explore available forecasting algorithms in PyPOTS

    main

    The pypots.forecasting module provides a collection of specialized algorithms for time series forecasting. These algorithms are organized into submodules based on their underlying architectures. Available algorithm modules include:

    • Transformer-based: pypots.forecasting.transformer
    • Linear-based: pypots.forecasting.mixlinear, pypots.forecasting.dlinear
    • LLM-based: pypots.forecasting.timellm, pypots.forecasting.gpt4ts
    • Convolutional/TCN-based: pypots.forecasting.moderntcn
    • Specialized Architectures: pypots.forecasting.moment, pypots.forecasting.tefn, pypots.forecasting.micn, pypots.forecasting.segrnn, pypots.forecasting.fits, pypots.forecasting.film, pypots.forecasting.timesnet, pypots.forecasting.timemixerpp, pypots.forecasting.timemixer, pypots.forecasting.csdi, and pypots.forecasting.bttf.
  7. Available imputation algorithms in pypots.imputation

    main

    The pypots.imputation module provides a wide variety of algorithms for time-series imputation. These algorithms are organized into submodules based on their underlying architecture or specific method.

    Available algorithm groups include:

    • Transformer-based: transformer, imputeformer, itransformer, crossformer, patchtst, etsformer, nonstationary_transformer, reformer, autoformer, informer, fedformer, pyraformer.
    • Graph/Spatial-Temporal: stemgnn, csdi, tslanet.
    • RNN/Sequence-based: segrnn, brits, mrnn, grud, tcn, moderntcn.
    • Statistical/Baseline: locf (Last Observation Carried Forward), median, mean.
    • Specialized/Recent Architectures: saits, helix, tefn, csai, moment, timellm, gpt4ts, fits, timemixer, timemixerpp, totem, tkan, koopa, frets, timesnet, micn, dlinear, tide, scinet, film, revin_scinet, usgan, gpvae, trmf, lerp.

    To use an algorithm, import it from its respective submodule within pypots.imputation.

  8. Explore pypots.nn modules

    main

    The pypots.nn package provides a comprehensive collection of neural network components specifically designed for time series analysis, including functional utilities, core model components, loss functions, metrics, and a wide variety of specialized architectural modules.

    Key sub-packages include:

    • pypots.nn.functional: Functional implementations for neural operations.
    • pypots.nn.modules.base_model_core: Core building blocks for model architectures.
    • pypots.nn.modules.loss: Loss functions for training.
    • pypots.nn.modules.metric: Evaluation metrics.
    • pypots.nn.modules.[algorithm]: Specialized modules for specific time series architectures (e.g., transformer, tcn, timesnet, autoformer, patchtst, etc.).
  9. Explore PyPOTS subpackages and capabilities

    main

    PyPOTS is organized into several specialized subpackages based on the machine learning task. You can use these modules to perform imputation, classification, clustering, forecasting, anomaly detection, and representation learning. It also provides core building blocks for neural networks, optimization, data handling, and utilities.

    Available subpackages:

    • pypots.imputation: Algorithms for missing data imputation.
    • pypots.classification: Models for classification tasks.
    • pypots.clustering: Algorithms for unsupervised clustering.
    • pypots.forecasting: Time-series forecasting models.
    • pypots.anomaly_detection: Methods for detecting anomalies in data.
    • pypots.representation: Techniques for learning data representations.
    • pypots.nn: Neural network components and building blocks.
    • pypots.optim: Optimization algorithms and tools.
    • pypots.data: Data loading and preprocessing utilities.
    • pypots.utils: General-purpose utility functions.
  10. Supported tasks and algorithms in PyPOTS

    main

    PyPOTS supports five main types of tasks for multivariate Partially Observed Time Series (POTS) data:

    • IMPT (Imputation): Filling in missing values.
    • FCST (Forecasting): Predicting future values.
    • CLAF (Classification): Categorizing time series data.
    • CLUS (Clustering): Grouping similar time series.
    • ANOD (Anomaly Detection): Identifying outliers or unusual patterns.

    Additionally, PyPOTS includes TS2Vec for time series representation learning and vectorization.

    Note on Model Compatibility: Some models marked with 🧑‍🔧 (e.g., Transformer, iTransformer, Informer) were not originally designed for POTS data and cannot handle missing values in their raw form. To make them compatible, PyPOTS implements specific embedding strategies and training methods (ORT+MIT) similar to the SAITS paper.

  11. Available anomaly detection algorithms in PyPOTS

    main
    PyPOTS provides a wide range of algorithms for anomaly detection in time series data. These algorithms are organized under the pypots.anomaly_detection module. You can use these models to identify outliers or unusual patterns in multivariate or univariate time series.
  12. Overview of the PyPOTS Ecosystem

    main

    PyPOTS is part of a larger ecosystem designed for time-series analysis and imputation:

    • TSDB (Time Series Data Beans): A tool to make loading 172+ open-source time-series datasets easy.
    • PyGrinder: A toolkit to simulate real-world missingness patterns (MCAR, MAR, MNAR) in datasets.
    • BenchPOTS: A benchmarking suite providing unified data-preprocessing pipelines for fair evaluation of POTS algorithms.
    • BrewPOTS: A repository containing tutorials for learning how to use PyPOTS effectively.