Skip to content

Repository files navigation

Proximity Forest: ECG Arrhythmia Detection

Open in Streamlit   Research Paper   UCR Archive

This repository presents an applied benchmark evaluation of the Proximity Forest algorithm (Lucas et al., 2019) across diverse domains from the UCR Time Series Classification Archive. The study compares Proximity Forest against three baseline classifiers to evaluate its effectiveness and scalability in a reproducible Python pipeline.

Reference

Lucas, B., Shifaz, A., Pelletier, C., O'Neill, L., Zaidi, N., Goethals, B., ... & Webb, G. I. (2019). Proximity Forest: an effective and scalable distance-based classifier for time series. Data Mining and Knowledge Discovery, 33(3), 607–635. Authors' Original Repository (Java)

Project Overview

Time series classification is a challenging problem in machine learning. Standard classifiers that ignore temporal structure perform poorly on tasks such as ECG anomaly detection, seismic event identification, and motion recognition. Proximity Forest addresses this by constructing an ensemble of decision trees whose splits are governed by randomized distance measures (DTW, ERP, LCSS, MSM, TWE, WDTW, and others), achieving high accuracy while remaining computationally scalable.

This project demonstrates the full data science lifecycle:

  1. Exploratory Data Analysis — Visualizing time-series waveforms and class distributions across seven benchmark datasets.
  2. Pipeline Engineering — Automated data ingestion, model training, prediction, and metric reporting using aeon and scikit-learn.
  3. Comparative Evaluation — Benchmarking Proximity Forest against three baselines: KNN-DTW, 1-NN Euclidean, and Random Forest.
  4. Statistical Result Reporting — Accuracy tables, confusion matrix heatmaps, and comparison charts saved for reproducibility.

Repository Structure

Proximity_tree_Model/
├── app/
│   └── streamlit_app.py                      # Interactive Streamlit dashboard
├── data/
│   └── UCR Archive 2018.zip                  # Standard benchmark dataset (not tracked by Git)
├── src/
│   └── run_experiment.py                     # End-to-end training and evaluation pipeline
├── results/
│   ├── full_results.csv                      # Complete results table
│   ├── dataset_summary.csv                   # Dataset characteristics
│   ├── model_evaluation.txt                  # Human-readable report
│   ├── accuracy_comparison.png               # Grouped accuracy bar chart
│   ├── training_time_comparison.png          # Training time comparison
│   ├── eda/                                  # EDA waveform and class distribution plots
│   └── confusion_matrices/                   # Per-dataset, per-classifier confusion matrices
├── .streamlit/
│   └── config.toml                           # Streamlit dark theme configuration
├── proximity_forest_benchmark_analysis.ipynb # Critical Difference Diagram visualizations
├── docs/
│   └── Proximity_tree_DWDM_ProjectFile.pdf   # Full project report
├── requirements.txt
└── README.md

Datasets

Seven UCR benchmark datasets were selected to span diverse application domains. All datasets are pre-processed and z-normalized per the UCR standard.

Dataset Domain Train Test Series Length Classes
ECG200 Medical / ECG 100 100 96 2
ECGFiveDays Medical / ECG 23 861 136 2
GunPoint Motion Capture 50 150 150 2
ItalyPowerDemand Sensor / Power 67 1029 24 2
TwoLeadECG Medical / ECG 23 1139 82 2
MoteStrain Sensor 20 1252 84 2
Coffee Spectral 28 28 286 2

Note on Data Pre-processing: In a production environment, raw time-series data requires missing value imputation, noise smoothing, and z-score normalization before inference. UCR datasets come pre-cleaned to enable objective comparison of algorithm architectures.

Classifiers

Classifier Description
Proximity Forest Distance-based ensemble of proximity trees using randomized measures (DTW, ERP, LCSS, MSM, etc.). n_trees=20, n_splitters=5.
KNN-DTW (k=1) Nearest-neighbour classifier with Dynamic Time Warping distance. Standard time-series baseline.
1-NN Euclidean Nearest-neighbour classifier with Euclidean distance. Simplest baseline.
Random Forest scikit-learn Random Forest on flattened features. Non-temporal baseline.

Results

Accuracy by Dataset

Dataset Proximity Forest KNN-DTW (k=1) 1-NN Euclidean Random Forest
ECG200 0.8900 0.7700 0.8800 0.8100
ECGFiveDays 0.8525 0.7677 0.7967 0.7700
GunPoint 0.9933 0.9067 0.9133 0.9067
ItalyPowerDemand 0.9621 0.9504 0.9553 0.9670
TwoLeadECG 0.9824 0.9043 0.7471 0.7120
MoteStrain 0.8738 0.8347 0.8786 0.8842
Coffee 1.0000 1.0000 1.0000 0.9643

Average Accuracy

Classifier Average Accuracy Dataset Wins
Proximity Forest 0.9363 4 / 7
1-NN Euclidean 0.8816 1 / 7
KNN-DTW (k=1) 0.8763 0 / 7
Random Forest 0.8592 2 / 7

Proximity Forest achieves the highest average accuracy of 93.63% across all benchmark datasets and wins on 4 of 7 datasets, consistently outperforming all three baselines. The results are consistent with the claims of Lucas et al. (2019) that distance-based temporal measures yield superior classification performance over standard machine learning approaches on time-series data.

Accuracy Comparison Chart

Accuracy Comparison

Training Time Comparison

Training Time Comparison

As expected, Proximity Forest has a higher training cost than baselines due to the computation of multiple distance measures at each node. This is the scalability trade-off discussed in the original paper.

Setup and Installation

  1. Clone the repository:

    git clone https://github.com/manaskng/proximity-forest.git
    cd proximity-forest
  2. Install dependencies:

    pip install -r requirements.txt

Running the Experiment

To reproduce all results from scratch:

python src/run_experiment.py

This will automatically download the required UCR datasets, train all four classifiers, and regenerate all output files in the results/ directory.

Benchmark Visualizations (Notebook)

The Jupyter notebook proximity_forest_benchmark_analysis.ipynb contains Critical Difference Diagrams generated from the full 85-dataset UCR benchmark results published by the original authors, statistically comparing Proximity Forest against HIVE-COTE, BOSS, Shapelet Transform, EE, and DTW.

jupyter notebook proximity_forest_benchmark_analysis.ipynb

Documentation

A comprehensive project report covering methodology, algorithm details, and extended analysis is available at docs/Proximity_tree_DWDM_ProjectFile.pdf.

Interactive Demo

An interactive Streamlit application is provided for exploring the datasets, visualizing ECG waveforms, and running live inference on test samples.

Run locally:

streamlit run app/streamlit_app.py

Live deployment: manaskng-proximity-forest.streamlit.app

The dashboard includes three sections:

  • Problem Overview — Clinical context, methodology, and benchmark results summary
  • Data Explorer — Interactive waveform viewer, class distribution charts, and classifier comparison
  • Live Classification Demo — Real-time inference on random ECG test samples with confusion matrix and classification report

About

Applied machine learning pipeline utilizing the aeon framework to benchmark Proximity Forest for scalable time-series classificatio

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages