zshuai8/PDMBench

2

stars

16

commits

Python

primary language

Feb 9, 2026

updated

README

PDMBench: A Comprehensive Benchmark for Predictive Maintenance

PDMBench is a unified benchmark platform for evaluating deep learning models on predictive maintenance (PdM) tasks. It provides standardized access to 14 industrial datasets, 33 models (including 4 foundation models), an interactive web UI, a REST API, and a Python framework for programmatic experimentation.

Key Features:

  • 14 PdM datasets spanning bearings, gearboxes, motors, and telemetry
  • 29 baseline models from the time series deep learning literature
  • 4 foundation models — Chronos, MOMENT, TimesFM, Moirai — with freeze/fine-tune support
  • Interactive web UI (Streamlit) for dataset exploration, model training, and results analysis
  • REST API (FastAPI) for programmatic dataset access and model evaluation
  • Python framework (pdm_framework) for scripted experiments and custom model integration

Table of Contents

  1. Getting Started
  2. Supported Datasets
  3. Supported Models
  4. Web Application
  5. REST API
  6. Python API (pdm_framework)
  7. CLI Usage
  8. Acknowledgment
  9. Contact

Getting Started

1. Clone the Repository

git clone https://github.com/zshuai8/PDMBenchmark
cd PDMBench

2. Install Requirements

We recommend Python 3.8+ and a virtual environment.

pip install -r requirements.txt

3. Prepare Datasets

Download and unzip the datasets into the ./dataset/ directory. Each dataset resides in a numbered subdirectory (e.g., ./dataset/01/ for Paderborn).

Datasets are available from the HuggingFace collection.


Supported Datasets

PDMBench includes 14 datasets covering fault diagnosis, remaining useful life (RUL) prediction, and early failure detection.

IDNameDescriptionSampling Rate (Hz)ChannelsDesign Target
01PaderbornPaderborn University Bearing Dataset64,0003Fault diagnosis
02HUSTHuazhong Univ. of Science and Technology Bearing Dataset51,2002Fault diagnosis
03IMSIntelligent Maintenance Systems Bearing Dataset20,4801RUL prediction
04CWRUCase Western Reserve University Bearing Dataset12,0001Fault diagnosis
05XJTUXi'an Jiaotong University Bearing Dataset25,6001RUL prediction & Fault diagnosis
06MFPTMechanical Fault Prevention Technology Bearing Dataset97,6001Fault diagnosis
07FEMTOFEMTO-ST Institute Bearing Dataset25,6003RUL prediction
09MAFAULDAMachinery Fault Database51,2004Fault diagnosis
12MendeleyMendeley Bearing Dataset9,6001Fault diagnosis
13PlanetaryPlanetary Gearbox Dataset48,0001Fault diagnosis
16AzureMicrosoft Azure Predictive Maintenance Dataset14RUL prediction
17Electric Motor VibrationsElectric Motor Fault Dataset42,0004Fault diagnosis
18Rotor Broken BarRotor Broken Bar Dataset50,0001Fault diagnosis
19Gear Box UoCUniversity of Connecticut Gearbox Dataset20,0001Fault diagnosis

Supported Models

Baseline Models (29)

All baseline models are adapted from the time series deep learning literature:

CategoryModels
Transformer variantsTransformer, PatchTST, iTransformer, Autoformer, Informer, FEDformer, Crossformer, ETSformer, Reformer, TimeXer
Advanced architecturesTimesNet, TimeMixer, TSMixer, FreTS, SegRNN, Pyraformer, MICN, FiLM, Koopa, MambaSimple, TemporalFusionTransformer, SCINet, PAttn, WPMixer, MultiPatchFormer
Simple / LinearDLinear, MLP, LightTS, TiDE

Foundation Models (4)

PDMBench supports four pre-trained foundation models for time series, available in the web UI and CLI:

ModelSourceAvailable SizesDefaultDescription
ChronosAmazontiny, mini, small, base, largesmallT5-based time series foundation model
MOMENTCMUsmall, base, largebaseOpen-source time series foundation model
TimesFMGoogle200m200mDecoder-only time series foundation model
MoiraiSalesforcesmall, base, largesmallUniversal time series forecasting model

Foundation model configuration options:

  • Model size — select the pre-trained checkpoint size
  • Freeze backbone — when enabled (default), freezes the pre-trained backbone and only trains a linear classification head (linear probing); when disabled, fine-tunes the entire model
  • Segment length — input segment length passed to the foundation model (options: 24, 48, 96, 192)

Web Application

PDMBench includes a Streamlit-based web application for interactive experimentation.

Launch

streamlit run app_new.py

Pages

The application has four main pages:

1. Dataset Explorer & Processing

Five tabs for exploring and preprocessing datasets:

TabFeatures
Data ProcessingNormalization (standardization, minmax, robust, per-sample), smoothing (moving average, Savitzky-Golay, exponential), detrending, filtering (lowpass/highpass/bandpass/bandstop), outlier handling, resampling, sequence length configuration (64-4096). Live preview of raw vs. processed signals in time and frequency domains.
OverviewSample counts, class distribution pie charts, imbalance ratio.
Signal ViewerPer-sample time-series visualization, multi-feature selection, time-domain statistics (mean, std, RMS, peak, crest factor, kurtosis), FFT, spectral centroid, power spectral density.
DistributionsPer-feature value distributions by class, feature statistics table.
EmbeddingsDimensionality reduction (PCA, t-SNE, UMAP) with 2D scatter plots colored by class.

2. Model Training

Three tabs:

  • Training Configuration — Select dataset, model (baseline or foundation), and task type (classification, early failure prediction, RUL estimation). Configure training parameters (batch size, learning rate, epochs, optimizer, LR scheduler, early stopping), architecture parameters (d_model, d_ff, n_heads, encoder/decoder layers, dropout), and model-specific parameters. Foundation models expose size selection, freeze backbone toggle, and segment length. Start training with real-time progress monitoring.
  • Cross-Condition Evaluation — Evaluate generalization across operating conditions. Select source/target conditions for datasets with known operating regimes (CWRU, Paderborn, XJTU, IMS, MFPT).
  • Custom Model — Upload a PyTorch model file (.py), auto-detect the model class, validate input/output shapes, and register for use in training.

3. Results Analysis

  • Leaderboard ranked by selected metric (accuracy, F1 micro/macro/weighted, ECE, Brier score)
  • Bar chart comparisons across models
  • Model-vs-dataset performance heatmaps
  • Per-dataset breakdown tables

4. Python API

Interactive documentation and code examples for the pdm_framework package.


REST API

PDMBench provides a RESTful API built with FastAPI for programmatic access to datasets and evaluation services.

Launch

uvicorn api.main:app --reload --port 8000

Interactive docs are available at http://localhost:8000/docs (Swagger UI) and http://localhost:8000/redoc (ReDoc).

Endpoints

MethodPathDescription
GET/API status, version, uptime, and number of available datasets
GET/datasetsList all datasets with metadata
GET/datasets/{name}Get detailed info for a specific dataset (by name or ID)
GET/datasets/{name}/samplesGet samples from a dataset split. Query params: split (train/val/test), offset, limit (max 100), format (json/numpy/csv)
GET/datasets/{name}/download/{split}Download a complete dataset split as an NPZ file
GET/datasets/{name}/statsGet dataset statistics (sample counts, class distributions, sequence lengths)
POST/evaluateSubmit predictions for evaluation. Returns accuracy, F1 micro/macro/weighted
GET/leaderboard/{name}Get leaderboard for a dataset. Query params: metric (accuracy/f1_macro), limit
GET/models/baseline/{name}Get pre-computed baseline model results for a dataset
GET/client/pythonGet example Python client code

Authentication

Some endpoints support optional API key authentication via the X-API-Key header.

Python Client Example

import requests

BASE_URL = "http://localhost:8000"

# List datasets
response = requests.get(f"{BASE_URL}/datasets")
datasets = response.json()
print(f"Available datasets: {datasets['total']}")

# Get dataset info
response = requests.get(f"{BASE_URL}/datasets/Paderborn")
info = response.json()
print(f"Dataset: {info['name']}, Classes: {info['num_classes']}")

# Get samples
response = requests.get(
    f"{BASE_URL}/datasets/Paderborn/samples",
    params={"split": "train", "offset": 0, "limit": 10}
)
samples = response.json()
print(f"Returned {samples['returned_samples']} of {samples['total_samples']} samples")

# Download full split
response = requests.get(f"{BASE_URL}/datasets/Paderborn/download/train", stream=True)
with open("train_data.npz", "wb") as f:
    f.write(response.content)

# Submit predictions for evaluation
predictions = [0] * 100  # your model's predictions
response = requests.post(
    f"{BASE_URL}/evaluate",
    json={
        "dataset_name": "Paderborn",
        "model_name": "MyModel",
        "predictions": predictions
    }
)
result = response.json()
print(f"Accuracy: {result['accuracy']:.4f}, F1 macro: {result['f1_macro']:.4f}")

Python API (pdm_framework)

The pdm_framework package provides a clean, programmatic interface for working with PDMBench datasets, models, training, and evaluation.

Quick Start

from pdm_framework import PDMDataset, Trainer, Evaluator, TrainerConfig
from pdm_framework.models import SimpleLSTM

# Load dataset by name
dataset = PDMDataset('Paderborn')
train_loader, val_loader, test_loader = dataset.get_loaders(batch_size=32)

# Create model
model = SimpleLSTM(
    seq_len=dataset.seq_len,
    num_features=dataset.num_features,
    num_classes=dataset.num_classes,
    hidden_size=128,
    num_layers=2
)

# Train
config = TrainerConfig(optimizer='adamw', learning_rate=1e-3, scheduler='cosine', epochs=50, patience=5)
trainer = Trainer(model, train_loader, val_loader, config=config)
history = trainer.fit()

# Evaluate
evaluator = Evaluator(model, test_loader)
metrics = evaluator.evaluate()
print(metrics)

Datasets

list_datasets()

Returns a list of all available dataset names.

from pdm_framework import list_datasets
print(list_datasets())
# ['Paderborn', 'HUST', 'IMS', 'CWRU', 'XJTU', 'MFPT', 'FEMTO', 'MAFAULDA',
#  'Mendeley', 'Planetary', 'Azure', 'Electric Motor Vibrations', 'Rotor Broken Bar', 'Gear Box UoC']

PDMDataset

PDMDataset(
    dataset_name: str,       # Dataset name (e.g., 'Paderborn', 'CWRU') or legacy ID ('01', '04')
    root_path: str = None,   # Custom path to dataset directory (default: auto-detect)
    seq_len: int = None,     # Truncate sequences to this length (default: full length)
    transform: Callable = None  # Transform applied to training samples
)

Properties:

PropertyTypeDescription
seq_lenintSequence length of the data
num_featuresintNumber of input channels/features
num_classesintNumber of output classes
train_data(ndarray, ndarray)Raw training features and labels
val_data(ndarray, ndarray)Raw validation features and labels
test_data(ndarray, ndarray)Raw test features and labels

Methods:

MethodDescription
get_loaders(batch_size=32, num_workers=4, shuffle_train=True)Returns (train_loader, val_loader, test_loader) as PyTorch DataLoaders
get_class_distribution()Returns class counts per split as a dictionary

Models

Built-in Models

ModelDescriptionKey Parameters
SimpleMLPFlattens input, passes through FC layershidden_dims=[256, 128], dropout=0.1
SimpleLSTMBidirectional LSTM with last-hidden-state outputhidden_size=128, num_layers=2, bidirectional=True
SimpleCNN1D CNN with BatchNorm and MaxPoolnum_filters=[64, 128, 256], kernel_size=3
SimpleTransformerTransformer encoder with global average poolingd_model=64, n_heads=4, num_layers=2

All models accept (seq_len, num_features, num_classes) as their first three arguments.

PDMModel (Base Class)

Inherit from PDMModel to create custom models compatible with the framework:

from pdm_framework.models import PDMModel
import torch.nn as nn

class MyModel(PDMModel):
    def __init__(self, seq_len, num_features, num_classes):
        super().__init__(seq_len, num_features, num_classes)
        self.net = nn.Sequential(
            nn.Flatten(),
            nn.Linear(seq_len * num_features, 128),
            nn.ReLU(),
            nn.Linear(128, num_classes)
        )

    def forward(self, x):
        # x: [batch, seq_len, num_features]
        return self.net(x)

PDMModel also provides predict(x) (returns class indices) and predict_proba(x) (returns softmax probabilities).

ModelWrapper

Adapt external models with different input/output conventions:

from pdm_framework.models import ModelWrapper

wrapped = ModelWrapper(
    model=my_external_model,
    seq_len=512, num_features=3, num_classes=5,
    input_transform=lambda x: x.permute(0, 2, 1)  # [B, T, C] -> [B, C, T]
)

get_model(name, seq_len, num_features, num_classes, **kwargs)

Factory function. name is one of 'mlp', 'lstm', 'cnn', 'transformer'.

Utility Functions

  • count_parameters(model) — returns the number of trainable parameters
  • get_model_summary(model) — returns a formatted string summary of model layers

Trainer

from pdm_framework import Trainer, TrainerConfig

config = TrainerConfig(
    optimizer='adamw',        # 'adam', 'adamw', 'sgd', 'rmsprop'
    learning_rate=1e-3,
    weight_decay=1e-4,
    scheduler='cosine',       # 'cosine', 'step', 'plateau', 'exponential', 'none'
    epochs=50,
    patience=10,              # early stopping patience
    use_amp=False,            # mixed precision training
    verbose=True
)

trainer = Trainer(model, train_loader, val_loader, config=config)
history = trainer.fit()       # returns dict with 'train_loss', 'train_acc', 'val_loss', 'val_acc'

The Trainer handles:

  • Optimizer and learning rate scheduler creation
  • Early stopping with best-model restoration
  • Optional mixed precision (AMP)
  • Checkpointing via save_checkpoint(path) / load_checkpoint(path)

Evaluator

from pdm_framework import Evaluator

evaluator = Evaluator(model, test_loader)
metrics = evaluator.evaluate()  # returns EvaluationMetrics

print(metrics.accuracy)
print(metrics.f1)
print(metrics.confusion_matrix)
print(metrics.auc_roc)
print(metrics.summary())         # formatted string
print(metrics.to_dict())         # dictionary

EvaluationMetrics fields: accuracy, precision, recall, f1, confusion_matrix, per_class_precision, per_class_recall, per_class_f1, predictions, true_labels, probabilities, auc_roc.

Additional evaluator methods:

MethodDescription
error_analysis()Returns misclassified sample indices, top confusion pairs, confidence statistics
get_worst_predictions(n=10)Returns the n most confidently wrong predictions
class_performance_summary()Per-class accuracy, precision, recall, F1

Comparing Models

from pdm_framework.evaluators import compare_models, print_comparison_table

results = compare_models(
    {'MLP': mlp_model, 'LSTM': lstm_model, 'CNN': cnn_model},
    test_loader
)
print_comparison_table(results)

Transforms

Data augmentation transforms operate on individual samples (torch tensors). Use Compose to chain them.

from pdm_framework.transforms import Compose, Normalize, Jitter, Scale, TimeWarp

augmentation = Compose([
    Normalize(),
    Jitter(sigma=0.03),
    Scale(sigma=0.1),
    TimeWarp(sigma=0.2),
])

dataset = PDMDataset('Paderborn', transform=augmentation)

Transforms are applied only to training samples (not validation/test).

Available transforms:

TransformDescriptionKey Parameters
NormalizeMin-max normalization to [0, 1]min_val=0.0, max_val=1.0
StandardizeZero mean, unit variancemean=None, std=None
JitterAdd Gaussian noisesigma=0.03
ScaleRandom magnitude scalingsigma=0.1
TimeWarpSmooth temporal warpingsigma=0.2, num_knots=4
MagnitudeWarpSmooth magnitude warpingsigma=0.2, num_knots=4
CutoutZero out random segmentsn_holes=1, length_ratio=0.1
FrequencyMaskMask random frequency bandsmax_mask_ratio=0.2, n_masks=1
GaussianNoiseAdd noise at specified SNRsnr_db=20.0
RandomCropCrop and resize to original lengthcrop_ratio_range=(0.8, 1.0)
ChannelDropoutRandomly drop channelsdropout_prob=0.1
RandomFlipFlip signal in time or valuep=0.5, axis='time'
MixupMix two samples (batch-level)alpha=0.2
ComposeChain multiple transformstransforms=[...]

CLI Usage

Train and evaluate models directly from the command line:

python run.py \
  --task_name classification \
  --model TimesNet \
  --data Paderborn \
  --is_training 1

Modify --model, --data, and other hyperparameters as needed. All 33 models (baseline + foundation) are available via the CLI.


Acknowledgment

Our benchmark framework is built upon and extends the Time Series Library (TSLib), an open-source project providing a unified codebase for evaluating deep learning models on time series tasks. We greatly appreciate the efforts of the TSLib team.

If you find our benchmark useful, please also consider citing TSLib:

@inproceedings{wu2023timesnet,
  title={TimesNet: Temporal 2D-Variation Modeling for General Time Series Analysis},
  author={Haixu Wu and Tengge Hu and Yong Liu and Hang Zhou and Jianmin Wang and Mingsheng Long},
  booktitle={International Conference on Learning Representations},
  year={2023},
}

Contact

For questions, please open an issue or reach out via email.

Contributors

zshuai8

16 commits

zshuai8/PDMBench

2

stars

16

commits

Python

primary language

Feb 9, 2026

updated

README

PDMBench: A Comprehensive Benchmark for Predictive Maintenance

PDMBench is a unified benchmark platform for evaluating deep learning models on predictive maintenance (PdM) tasks. It provides standardized access to 14 industrial datasets, 33 models (including 4 foundation models), an interactive web UI, a REST API, and a Python framework for programmatic experimentation.

Key Features:

  • 14 PdM datasets spanning bearings, gearboxes, motors, and telemetry
  • 29 baseline models from the time series deep learning literature
  • 4 foundation models — Chronos, MOMENT, TimesFM, Moirai — with freeze/fine-tune support
  • Interactive web UI (Streamlit) for dataset exploration, model training, and results analysis
  • REST API (FastAPI) for programmatic dataset access and model evaluation
  • Python framework (pdm_framework) for scripted experiments and custom model integration

Table of Contents

  1. Getting Started
  2. Supported Datasets
  3. Supported Models
  4. Web Application
  5. REST API
  6. Python API (pdm_framework)
  7. CLI Usage
  8. Acknowledgment
  9. Contact

Getting Started

1. Clone the Repository

git clone https://github.com/zshuai8/PDMBenchmark
cd PDMBench

2. Install Requirements

We recommend Python 3.8+ and a virtual environment.

pip install -r requirements.txt

3. Prepare Datasets

Download and unzip the datasets into the ./dataset/ directory. Each dataset resides in a numbered subdirectory (e.g., ./dataset/01/ for Paderborn).

Datasets are available from the HuggingFace collection.


Supported Datasets

PDMBench includes 14 datasets covering fault diagnosis, remaining useful life (RUL) prediction, and early failure detection.

IDNameDescriptionSampling Rate (Hz)ChannelsDesign Target
01PaderbornPaderborn University Bearing Dataset64,0003Fault diagnosis
02HUSTHuazhong Univ. of Science and Technology Bearing Dataset51,2002Fault diagnosis
03IMSIntelligent Maintenance Systems Bearing Dataset20,4801RUL prediction
04CWRUCase Western Reserve University Bearing Dataset12,0001Fault diagnosis
05XJTUXi'an Jiaotong University Bearing Dataset25,6001RUL prediction & Fault diagnosis
06MFPTMechanical Fault Prevention Technology Bearing Dataset97,6001Fault diagnosis
07FEMTOFEMTO-ST Institute Bearing Dataset25,6003RUL prediction
09MAFAULDAMachinery Fault Database51,2004Fault diagnosis
12MendeleyMendeley Bearing Dataset9,6001Fault diagnosis
13PlanetaryPlanetary Gearbox Dataset48,0001Fault diagnosis
16AzureMicrosoft Azure Predictive Maintenance Dataset14RUL prediction
17Electric Motor VibrationsElectric Motor Fault Dataset42,0004Fault diagnosis
18Rotor Broken BarRotor Broken Bar Dataset50,0001Fault diagnosis
19Gear Box UoCUniversity of Connecticut Gearbox Dataset20,0001Fault diagnosis

Supported Models

Baseline Models (29)

All baseline models are adapted from the time series deep learning literature:

CategoryModels
Transformer variantsTransformer, PatchTST, iTransformer, Autoformer, Informer, FEDformer, Crossformer, ETSformer, Reformer, TimeXer
Advanced architecturesTimesNet, TimeMixer, TSMixer, FreTS, SegRNN, Pyraformer, MICN, FiLM, Koopa, MambaSimple, TemporalFusionTransformer, SCINet, PAttn, WPMixer, MultiPatchFormer
Simple / LinearDLinear, MLP, LightTS, TiDE

Foundation Models (4)

PDMBench supports four pre-trained foundation models for time series, available in the web UI and CLI:

ModelSourceAvailable SizesDefaultDescription
ChronosAmazontiny, mini, small, base, largesmallT5-based time series foundation model
MOMENTCMUsmall, base, largebaseOpen-source time series foundation model
TimesFMGoogle200m200mDecoder-only time series foundation model
MoiraiSalesforcesmall, base, largesmallUniversal time series forecasting model

Foundation model configuration options:

  • Model size — select the pre-trained checkpoint size
  • Freeze backbone — when enabled (default), freezes the pre-trained backbone and only trains a linear classification head (linear probing); when disabled, fine-tunes the entire model
  • Segment length — input segment length passed to the foundation model (options: 24, 48, 96, 192)

Web Application

PDMBench includes a Streamlit-based web application for interactive experimentation.

Launch

streamlit run app_new.py

Pages

The application has four main pages:

1. Dataset Explorer & Processing

Five tabs for exploring and preprocessing datasets:

TabFeatures
Data ProcessingNormalization (standardization, minmax, robust, per-sample), smoothing (moving average, Savitzky-Golay, exponential), detrending, filtering (lowpass/highpass/bandpass/bandstop), outlier handling, resampling, sequence length configuration (64-4096). Live preview of raw vs. processed signals in time and frequency domains.
OverviewSample counts, class distribution pie charts, imbalance ratio.
Signal ViewerPer-sample time-series visualization, multi-feature selection, time-domain statistics (mean, std, RMS, peak, crest factor, kurtosis), FFT, spectral centroid, power spectral density.
DistributionsPer-feature value distributions by class, feature statistics table.
EmbeddingsDimensionality reduction (PCA, t-SNE, UMAP) with 2D scatter plots colored by class.

2. Model Training

Three tabs:

  • Training Configuration — Select dataset, model (baseline or foundation), and task type (classification, early failure prediction, RUL estimation). Configure training parameters (batch size, learning rate, epochs, optimizer, LR scheduler, early stopping), architecture parameters (d_model, d_ff, n_heads, encoder/decoder layers, dropout), and model-specific parameters. Foundation models expose size selection, freeze backbone toggle, and segment length. Start training with real-time progress monitoring.
  • Cross-Condition Evaluation — Evaluate generalization across operating conditions. Select source/target conditions for datasets with known operating regimes (CWRU, Paderborn, XJTU, IMS, MFPT).
  • Custom Model — Upload a PyTorch model file (.py), auto-detect the model class, validate input/output shapes, and register for use in training.

3. Results Analysis

  • Leaderboard ranked by selected metric (accuracy, F1 micro/macro/weighted, ECE, Brier score)
  • Bar chart comparisons across models
  • Model-vs-dataset performance heatmaps
  • Per-dataset breakdown tables

4. Python API

Interactive documentation and code examples for the pdm_framework package.


REST API

PDMBench provides a RESTful API built with FastAPI for programmatic access to datasets and evaluation services.

Launch

uvicorn api.main:app --reload --port 8000

Interactive docs are available at http://localhost:8000/docs (Swagger UI) and http://localhost:8000/redoc (ReDoc).

Endpoints

MethodPathDescription
GET/API status, version, uptime, and number of available datasets
GET/datasetsList all datasets with metadata
GET/datasets/{name}Get detailed info for a specific dataset (by name or ID)
GET/datasets/{name}/samplesGet samples from a dataset split. Query params: split (train/val/test), offset, limit (max 100), format (json/numpy/csv)
GET/datasets/{name}/download/{split}Download a complete dataset split as an NPZ file
GET/datasets/{name}/statsGet dataset statistics (sample counts, class distributions, sequence lengths)
POST/evaluateSubmit predictions for evaluation. Returns accuracy, F1 micro/macro/weighted
GET/leaderboard/{name}Get leaderboard for a dataset. Query params: metric (accuracy/f1_macro), limit
GET/models/baseline/{name}Get pre-computed baseline model results for a dataset
GET/client/pythonGet example Python client code

Authentication

Some endpoints support optional API key authentication via the X-API-Key header.

Python Client Example

import requests

BASE_URL = "http://localhost:8000"

# List datasets
response = requests.get(f"{BASE_URL}/datasets")
datasets = response.json()
print(f"Available datasets: {datasets['total']}")

# Get dataset info
response = requests.get(f"{BASE_URL}/datasets/Paderborn")
info = response.json()
print(f"Dataset: {info['name']}, Classes: {info['num_classes']}")

# Get samples
response = requests.get(
    f"{BASE_URL}/datasets/Paderborn/samples",
    params={"split": "train", "offset": 0, "limit": 10}
)
samples = response.json()
print(f"Returned {samples['returned_samples']} of {samples['total_samples']} samples")

# Download full split
response = requests.get(f"{BASE_URL}/datasets/Paderborn/download/train", stream=True)
with open("train_data.npz", "wb") as f:
    f.write(response.content)

# Submit predictions for evaluation
predictions = [0] * 100  # your model's predictions
response = requests.post(
    f"{BASE_URL}/evaluate",
    json={
        "dataset_name": "Paderborn",
        "model_name": "MyModel",
        "predictions": predictions
    }
)
result = response.json()
print(f"Accuracy: {result['accuracy']:.4f}, F1 macro: {result['f1_macro']:.4f}")

Python API (pdm_framework)

The pdm_framework package provides a clean, programmatic interface for working with PDMBench datasets, models, training, and evaluation.

Quick Start

from pdm_framework import PDMDataset, Trainer, Evaluator, TrainerConfig
from pdm_framework.models import SimpleLSTM

# Load dataset by name
dataset = PDMDataset('Paderborn')
train_loader, val_loader, test_loader = dataset.get_loaders(batch_size=32)

# Create model
model = SimpleLSTM(
    seq_len=dataset.seq_len,
    num_features=dataset.num_features,
    num_classes=dataset.num_classes,
    hidden_size=128,
    num_layers=2
)

# Train
config = TrainerConfig(optimizer='adamw', learning_rate=1e-3, scheduler='cosine', epochs=50, patience=5)
trainer = Trainer(model, train_loader, val_loader, config=config)
history = trainer.fit()

# Evaluate
evaluator = Evaluator(model, test_loader)
metrics = evaluator.evaluate()
print(metrics)

Datasets

list_datasets()

Returns a list of all available dataset names.

from pdm_framework import list_datasets
print(list_datasets())
# ['Paderborn', 'HUST', 'IMS', 'CWRU', 'XJTU', 'MFPT', 'FEMTO', 'MAFAULDA',
#  'Mendeley', 'Planetary', 'Azure', 'Electric Motor Vibrations', 'Rotor Broken Bar', 'Gear Box UoC']

PDMDataset

PDMDataset(
    dataset_name: str,       # Dataset name (e.g., 'Paderborn', 'CWRU') or legacy ID ('01', '04')
    root_path: str = None,   # Custom path to dataset directory (default: auto-detect)
    seq_len: int = None,     # Truncate sequences to this length (default: full length)
    transform: Callable = None  # Transform applied to training samples
)

Properties:

PropertyTypeDescription
seq_lenintSequence length of the data
num_featuresintNumber of input channels/features
num_classesintNumber of output classes
train_data(ndarray, ndarray)Raw training features and labels
val_data(ndarray, ndarray)Raw validation features and labels
test_data(ndarray, ndarray)Raw test features and labels

Methods:

MethodDescription
get_loaders(batch_size=32, num_workers=4, shuffle_train=True)Returns (train_loader, val_loader, test_loader) as PyTorch DataLoaders
get_class_distribution()Returns class counts per split as a dictionary

Models

Built-in Models

ModelDescriptionKey Parameters
SimpleMLPFlattens input, passes through FC layershidden_dims=[256, 128], dropout=0.1
SimpleLSTMBidirectional LSTM with last-hidden-state outputhidden_size=128, num_layers=2, bidirectional=True
SimpleCNN1D CNN with BatchNorm and MaxPoolnum_filters=[64, 128, 256], kernel_size=3
SimpleTransformerTransformer encoder with global average poolingd_model=64, n_heads=4, num_layers=2

All models accept (seq_len, num_features, num_classes) as their first three arguments.

PDMModel (Base Class)

Inherit from PDMModel to create custom models compatible with the framework:

from pdm_framework.models import PDMModel
import torch.nn as nn

class MyModel(PDMModel):
    def __init__(self, seq_len, num_features, num_classes):
        super().__init__(seq_len, num_features, num_classes)
        self.net = nn.Sequential(
            nn.Flatten(),
            nn.Linear(seq_len * num_features, 128),
            nn.ReLU(),
            nn.Linear(128, num_classes)
        )

    def forward(self, x):
        # x: [batch, seq_len, num_features]
        return self.net(x)

PDMModel also provides predict(x) (returns class indices) and predict_proba(x) (returns softmax probabilities).

ModelWrapper

Adapt external models with different input/output conventions:

from pdm_framework.models import ModelWrapper

wrapped = ModelWrapper(
    model=my_external_model,
    seq_len=512, num_features=3, num_classes=5,
    input_transform=lambda x: x.permute(0, 2, 1)  # [B, T, C] -> [B, C, T]
)

get_model(name, seq_len, num_features, num_classes, **kwargs)

Factory function. name is one of 'mlp', 'lstm', 'cnn', 'transformer'.

Utility Functions

  • count_parameters(model) — returns the number of trainable parameters
  • get_model_summary(model) — returns a formatted string summary of model layers

Trainer

from pdm_framework import Trainer, TrainerConfig

config = TrainerConfig(
    optimizer='adamw',        # 'adam', 'adamw', 'sgd', 'rmsprop'
    learning_rate=1e-3,
    weight_decay=1e-4,
    scheduler='cosine',       # 'cosine', 'step', 'plateau', 'exponential', 'none'
    epochs=50,
    patience=10,              # early stopping patience
    use_amp=False,            # mixed precision training
    verbose=True
)

trainer = Trainer(model, train_loader, val_loader, config=config)
history = trainer.fit()       # returns dict with 'train_loss', 'train_acc', 'val_loss', 'val_acc'

The Trainer handles:

  • Optimizer and learning rate scheduler creation
  • Early stopping with best-model restoration
  • Optional mixed precision (AMP)
  • Checkpointing via save_checkpoint(path) / load_checkpoint(path)

Evaluator

from pdm_framework import Evaluator

evaluator = Evaluator(model, test_loader)
metrics = evaluator.evaluate()  # returns EvaluationMetrics

print(metrics.accuracy)
print(metrics.f1)
print(metrics.confusion_matrix)
print(metrics.auc_roc)
print(metrics.summary())         # formatted string
print(metrics.to_dict())         # dictionary

EvaluationMetrics fields: accuracy, precision, recall, f1, confusion_matrix, per_class_precision, per_class_recall, per_class_f1, predictions, true_labels, probabilities, auc_roc.

Additional evaluator methods:

MethodDescription
error_analysis()Returns misclassified sample indices, top confusion pairs, confidence statistics
get_worst_predictions(n=10)Returns the n most confidently wrong predictions
class_performance_summary()Per-class accuracy, precision, recall, F1

Comparing Models

from pdm_framework.evaluators import compare_models, print_comparison_table

results = compare_models(
    {'MLP': mlp_model, 'LSTM': lstm_model, 'CNN': cnn_model},
    test_loader
)
print_comparison_table(results)

Transforms

Data augmentation transforms operate on individual samples (torch tensors). Use Compose to chain them.

from pdm_framework.transforms import Compose, Normalize, Jitter, Scale, TimeWarp

augmentation = Compose([
    Normalize(),
    Jitter(sigma=0.03),
    Scale(sigma=0.1),
    TimeWarp(sigma=0.2),
])

dataset = PDMDataset('Paderborn', transform=augmentation)

Transforms are applied only to training samples (not validation/test).

Available transforms:

TransformDescriptionKey Parameters
NormalizeMin-max normalization to [0, 1]min_val=0.0, max_val=1.0
StandardizeZero mean, unit variancemean=None, std=None
JitterAdd Gaussian noisesigma=0.03
ScaleRandom magnitude scalingsigma=0.1
TimeWarpSmooth temporal warpingsigma=0.2, num_knots=4
MagnitudeWarpSmooth magnitude warpingsigma=0.2, num_knots=4
CutoutZero out random segmentsn_holes=1, length_ratio=0.1
FrequencyMaskMask random frequency bandsmax_mask_ratio=0.2, n_masks=1
GaussianNoiseAdd noise at specified SNRsnr_db=20.0
RandomCropCrop and resize to original lengthcrop_ratio_range=(0.8, 1.0)
ChannelDropoutRandomly drop channelsdropout_prob=0.1
RandomFlipFlip signal in time or valuep=0.5, axis='time'
MixupMix two samples (batch-level)alpha=0.2
ComposeChain multiple transformstransforms=[...]

CLI Usage

Train and evaluate models directly from the command line:

python run.py \
  --task_name classification \
  --model TimesNet \
  --data Paderborn \
  --is_training 1

Modify --model, --data, and other hyperparameters as needed. All 33 models (baseline + foundation) are available via the CLI.


Acknowledgment

Our benchmark framework is built upon and extends the Time Series Library (TSLib), an open-source project providing a unified codebase for evaluating deep learning models on time series tasks. We greatly appreciate the efforts of the TSLib team.

If you find our benchmark useful, please also consider citing TSLib:

@inproceedings{wu2023timesnet,
  title={TimesNet: Temporal 2D-Variation Modeling for General Time Series Analysis},
  author={Haixu Wu and Tengge Hu and Yong Liu and Hang Zhou and Jianmin Wang and Mingsheng Long},
  booktitle={International Conference on Learning Representations},
  year={2023},
}

Contact

For questions, please open an issue or reach out via email.

Contributors

zshuai8

16 commits

Languages

Python

94.9%

Shell

5.1%