Latest release v1.9.4

Predict antimicrobial resistance with rigorously validated machine learning.

ResPredAI is an open-source Python pipeline that turns routinely collected clinical data into calibrated, interpretable resistance predictions. It implements the framework of our npj Digital Medicine study on Gram-negative bloodstream infections, ready to be re-run on your own cohort.

pip install respredai
  • Python 3.10+
  • MIT license
  • 9 models
  • CLI + HTML report

Capabilities

Everything a clinical prediction study needs, in one reproducible run.

ResPredAI builds the methodological safeguards into the pipeline itself: leakage-safe validation, calibrated probabilities and thresholds that reflect clinical costs. Results are designed to hold up outside the training cohort.

9 models
  • Logistic Regression
  • Linear SVC
  • RBF SVC
  • KNN
  • MLP
  • Random Forest
  • XGBoost
  • CatBoost
  • TabPFN optional

Validation

Nested cross-validation

Outer folds for evaluation, inner folds for tuning. Group-aware and repeatable, with preprocessing fitted on training folds only.

Temporal validation

Prospective-style evaluation with a date cutoff or ratio split, alone or alongside cross-validation.

External validation

Train on one cohort with train, then score another with evaluate using the saved preprocessing.

Clinical reliability

Probability calibration

Platt or isotonic calibration, assessed with Brier score, ECE/MCE and reliability curves.

Clinically weighted thresholds

Youden, F1, F2 or cost-sensitive thresholds that weigh very major errors (VME) against major errors (ME).

Conformal prediction sets

Per-class (Mondrian) sets, {S}, {R} or {S,R}, that flag the cases the model cannot call at the chosen α.

Uncertainty for every metric

Bootstrap confidence intervals and corrected standard errors (Nadeau–Bengio) alongside each point estimate.

Interpretability & reporting

Signed feature importance

Native or SHAP-based importance, with risk (+) or protective (−) direction for each feature.

Subgroup analysis

The full metric set per clinical subgroup, with sample size and prevalence reported next to it.

Missing data

Simple, KNN or iterative (MissForest-style) imputation, fitted within each training fold.

Report and manifest

A self-contained HTML report plus a reproducibility manifest with environment, data fingerprint and configuration.

How it works

One pipeline, no shortcuts between training and test data.

Every step that learns from data is refitted inside each outer fold, so the held-out patients never influence the model that is scored on them.

1

Config & data

INI configuration, input validation, column checks

Outer CV fold × k folds × repeats group-aware

2

Preprocess

One-hot encoding, imputation and scaling fitted on the training fold

3

Tune

Grid search over hyperparameters

inner CV
4

Calibrate

Post-hoc Platt or isotonic calibration

5

Set threshold

Youden, F-score or VME/ME cost-weighted

6

Predict

Held-out fold: probabilities, labels and conformal sets

7

Report

Metrics with CIs, subgroups, calibration plots, HTML report

Temporal validation runs the same steps on a single time-based split. Read the run reference →

Quickstart

From a CSV to a full report in three commands.

  1. 1Install

    pip install respredai

    TabPFN is an optional extra: pip install "respredai[tabpfn]", which also needs a PriorLabs API token.

  2. 2Configure

    respredai create-config my_config.ini
    respredai validate-config my_config.ini --check-data

    Point the template at your data, targets and features, then check it before running.

  3. 3Run

    respredai run --config my_config.ini

    Metrics, plots, trained fold models and report.html land in the output folder.

my_config.ini excerpt
[Data]
data_path = ./data/my_data.csv
targets = Target1,Target2
continuous_features = Age,Creatinine,LOS

[Metadata]
# keep each patient in a single fold
group_column = PatientID
subgroup_columns = ward, sex

[Pipeline]
models = LR,RF,XGB,CatBoost
outer_folds = 5
inner_folds = 3
calibrate_probabilities = true
calibrate_threshold = true
# missing a resistance costs more
threshold_objective = cost_sensitive
vme_cost = 2.0
me_cost = 1.0

[Uncertainty]
alpha = 0.1

Outputs

Results you can read, check and share.

Every run writes CSV metrics, publication-ready figures and a single HTML report that collects them.

Research

Built for, and tested in, clinical research.

Studies that develop or apply ResPredAI. New work from the project will be listed here as it is published.

Cited by –

Loading from OpenAlex…

    Using ResPredAI in your research? Let us know on GitHub and we will feature it here.

    Roadmap

    Where ResPredAI has been, and where it is going.

    Release themes in order. Planned releases may change in scope or sequence; the changelog records what has shipped.

      Team

      People and institutions behind the project.

      Ettore Rocchi

      Creator and maintainer

      University of Bologna

      Institution

      University of Bologna

      Institution

      IRCCS Azienda Ospedaliero-Universitaria di Bologna

      The original study was a collaboration of 16 authors. See the full author list or all code contributors.

      Funding

      This research was supported by the European Union – NextGenerationEU through the Italian Ministry of University and Research (MUR) under the National Recovery and Resilience Plan (NRRP).