Skip to content

Conversation

@lehendo
Copy link
Contributor

@lehendo lehendo commented Jan 25, 2026

This PR adds the k-means clustering conformal prediction.

  • Implemented ClusterLabel for cluster-specific calibration thresholds using K-means on patient embeddings
  • Added example script tuev_kmeans_conformal.py demonstrating usage on TUEV EEG dataset
  • Includes test suite with coverage for initialization, calibration, and prediction

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds K-means clustering-based conformal prediction (ClusterLabel) for multiclass classification in EEG analysis. The method groups patients into clusters using K-means on embeddings and computes cluster-specific calibration thresholds to improve prediction set efficiency compared to global thresholds.

Changes:

  • Implemented ClusterLabel class that performs K-means clustering on patient embeddings and applies cluster-specific calibration thresholds
  • Added comprehensive test suite covering initialization, calibration, and prediction
  • Included example script demonstrating usage on TUEV EEG dataset with ContraWR model

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pyhealth/calib/predictionset/cluster/cluster_label.py Core implementation of cluster-based conformal prediction with K-means clustering
pyhealth/calib/predictionset/cluster/init.py Module initialization exporting ClusterLabel class
pyhealth/calib/predictionset/init.py Updated to export ClusterLabel from cluster submodule
tests/core/test_cluster_label.py Test suite covering initialization, calibration, and forward pass with various configurations
examples/conformal_eeg/tuev_kmeans_conformal.py Example script demonstrating ClusterLabel usage on TUEV EEG events dataset

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lehendo
Copy link
Contributor Author

lehendo commented Feb 4, 2026

Tbh, the copilot suggestions were pretty valid. Implemented some of them.

Copy link
Collaborator

@siddharthal siddharthal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@siddharthal siddharthal merged commit 04ca18f into sunlabuiuc:master Feb 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants