PyPI version Python versions MIT License 29 CV methods

Trustworthy Cross-Validation for Medical ML

Framework-agnostic toolkit with 29 CV methods, automatic data leakage detection, clinical metrics, and regulatory compliance support.
Developed at SMAILE, Karolinska Institutet's core facility for AI.

$ pip install trustcv content_copy

🎙️ Podcast: The Reproducibility Crisis in Medical AI

Deep dive into how trustcv solves "data leakage" and why standard validation methods fail in clinical settings. (Generated with AI)

timer ~18 min topic Data Leakage, CV Methods, Clinical Safety

Choose the Right CV Method for Your Medical Data

What type of medical data do you have?

shuffle

Independent Samples

Each sample is independent (e.g., different patients)

schedule

Time Series

Temporal dependencies (e.g., patient monitoring)

group_work

Grouped/Hierarchical

Multiple samples per patient or hospital

map

Spatial

Geographic or anatomical correlations

Visualize Cross-Validation Strategies

5

📊 Cross-Validation Methods

Choose the right validation strategy for your medical machine learning project

🔄

I.I.D. Methods

Hold-Out, K-Fold, Stratified, LOOCV, Bootstrap

9 methods

Temporal Methods

Time Series, Rolling, Expanding, Purged, CPCV

8 methods
👥

Grouped Methods

Group K-Fold, LOGO, LPGO, Hierarchical, Multi-level

8 methods
🌍

Spatial Methods

Spatial Block, Buffered, Spatiotemporal, Environmental

4 methods
🎯

Total Coverage

All validation strategies from the systematic review

29 methods total
🔬

Framework Support

Scikit-learn, PyTorch, TensorFlow, MONAI

4+ frameworks
table_chart View Complete Methods Comparison

Comprehensive table with 29+ methods, medical applications, and implementation guidance

Why trustcv?

verified_user

Safety First

Automatic detection of data leakage, patient-level contamination, and temporal violations

regulatory_compliance

Regulatory Compliance

Learn to select, justify, and document your cross-validation strategy to meet FDA and CE MDR requirements for AI/ML medical devices

arrow_forward Start Learning
local_hospital

Medical-Specific

Methods designed for clinical data: patient grouping, disease prevalence, temporal patterns

school

Learn by Doing

Interactive tutorials with real medical datasets and Google Colab notebooks

Quick Start

Install from PyPI and validate your first model in minutes

# Install from PyPI
pip install trustcv
from trustcv import TrustCVValidator
from sklearn.ensemble import RandomForestClassifier

# Initialize with medical-specific settings
validator = TrustCVValidator(
    method='group_kfold',       # Patient-grouped cross-validation
    n_splits=5,
    check_leakage=True          # Automatic data leakage detection
)

# Validate your model with patient grouping
results = validator.validate(
    model=RandomForestClassifier(),
    X=X_features,
    y=y_labels,
    groups=patient_ids  # Ensure patient-level splits
)

# Get comprehensive results with clinical metrics
print(results.summary())
pip install trustcv[pytorch] PyTorch support
pip install trustcv[tensorflow] TensorFlow/Keras
pip install trustcv[monai] Medical imaging
pip install trustcv[all] All frameworks

🎯 Choose Your Learning Path

Multiple ways to master medical cross-validation

play_circle

Interactive Demonstrations

Explore real medical scenarios through hands-on simulations

  • 🚨 Data leakage consequences in ICU prediction
  • 🏥 Multi-site clinical trial validation
  • ⏰ Temporal validation for time-series data
  • 👥 Patient-level cross-validation strategies
4 Interactive Demos Real Medical Data
quiz

Knowledge Assessment

Test your understanding with our comprehensive CV quiz

  • 📋 10 clinical scenario questions
  • 🎯 Detailed explanations and insights
  • 📊 Personalized skill assessment
  • 📚 Tailored learning recommendations
15 Minutes Instant Feedback
code

Hands-On Coding

Learn by coding with our Jupyter notebook tutorials

  • 📓 Step-by-step implementation guides
  • 💻 Real datasets and working examples
  • 🔬 Advanced techniques and best practices
  • 🏥 Clinical deployment considerations
10 Notebooks Google Colab Ready