Skip to main content

Robust Clinical Association Displacement (CAD) analysis with statistical normalization

Reason this release was yanked:

add more clinically useful features

Project description

clinical-cad

Clinical Association Displacement (CAD) and Weighted Association Error (WAE) for lexical fairness over any binary demographic (sex, race, age group, etc.). Compare a reference corpus (e.g. ground-truth text) with model predictions to see how word associations with two groups change, and get a single fairness number (WAE).


Installation

pip install clinical-cad

Quick example

1. Run with your own CSVs (reference = ground truth, prediction = model output):

cad --reference_csv reference.csv --prediction_csv predictions.csv

Results go to ./cad_output by default. Use --output_dir my_results to change that.

2. Try it without data (demo):

cad --demo

3. Use a different demographic (e.g. race instead of sex):

Your CSV must have a column with exactly two values (e.g. White and Black). Then:

cad --reference_csv ref.csv --prediction_csv pred.csv \
    --label_column race --group_a White --group_b Black

What it does (for new users)

  • CAD
    For each word, it measures how strongly it’s associated with group A vs group B in the reference corpus, and how that changes in the prediction corpus. Words that shift a lot are “displaced” and can indicate bias.

  • WAE (Weighted Association Error)
    One number summarizing how much associations shifted overall. Lower WAE = fairer (less lexical bias). It comes with 95% confidence intervals (bootstrap).

You get JSON summaries, CSV tables, and plots in the output directory.


Input format

Both CSVs need:

  1. A text column (default: findings for reference, predicted_report for predictions; override with --reference_text_column / --prediction_text_column).
  2. A demographic column with exactly two values (e.g. M/F, White/Black, young/old). Default column name is PatientSex if you don’t pass --label_column.

Example:

PatientSex findings
M No acute findings.
F Normal heart size.

Parameters (only the important ones)

Parameter Default Why it matters
--reference_csv (required) Path to reference (ground-truth) CSV.
--prediction_csv (required) Path to model-output CSV.
--output_dir ./cad_output Where to write results.
--label_column PatientSex Column that holds the two groups (e.g. sex, race).
--group_a F First group value (e.g. F, White).
--group_b M Second group value (e.g. M, Black).
--alpha 0.1 Smoothing for rare words; keeps log-odds stable.
--min_freq 1 Ignore words with fewer than this many occurrences.
--significance_level 0.0455 P-value for “strong” association; lower = stricter.
--neutral_significance 0.317 P-value for “neutral”; higher = more words treated as neutral.
--displacement_significance 0.01 P-value for when a word is considered “displaced”.
--wae_weight total How to weight words: total, ref, or pred.
--bootstrap_samples 1000 Number of bootstrap samples for WAE confidence intervals.
--stopwords_path Optional file with extra stopwords (one per line).
--no_stopword_removal False Turn off stopword removal.
--demo False Run on built-in demo data (no CSVs needed).

Paper and citation

This tool supports the methodology described in our paper on lexical fairness in clinical text (e.g. radiology report generation).

If you use clinical-cad in your work, please cite:

@article{parikh2026measuring,
  title={Measuring What VLMs Don't Say: Validation Metrics Hide Clinical Terminology Erasure in Radiology Report Generation},
  author={Parikh, Aditya and Feragen, Aasa and Das, Sneha and Frank, Stella},
  journal={arXiv preprint arXiv:2603.01625},
  year={2026}
}

(Replace title, author, booktitle, year, and url with your paper details.)


Python API

from clinical_cad import parse_args, run_pipeline

args = parse_args()
run_pipeline(
    args.reference_csv,
    args.reference_text_column,
    args.prediction_csv,
    args.prediction_text_column,
    args.label_column or "PatientSex",
    args.output_dir,
    args,
)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clinical_cad-0.1.1.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clinical_cad-0.1.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file clinical_cad-0.1.1.tar.gz.

File metadata

  • Download URL: clinical_cad-0.1.1.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for clinical_cad-0.1.1.tar.gz
Algorithm Hash digest
SHA256 59ccb1e18928edc9421490f9be57c1ad5c88d6c15084e0e22934410f0ace783b
MD5 fa2620a1ae747dd54886b91655b7c942
BLAKE2b-256 357000d21b12da69af39d4facb4b2b4716978fad03e4d92f7a02ade4c77b6b82

See more details on using hashes here.

File details

Details for the file clinical_cad-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: clinical_cad-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for clinical_cad-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19e6f77c54631f5d4a91b6e9a091af0053e4ec803a5c3700404564974489b14a
MD5 0829e8677a798c54a59850659b8d0324
BLAKE2b-256 873ba449775abfac52b1a998926b6afc71167485a7eb63275616758d0f7c746a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page