Applicability Area (ApAr): A decision-analytic utility-based approach to evaluating predictive models.
Project description
ApAr: Applicability Area
A decision-analytic utility-based approach to evaluating predictive models, beyond discrimination.
ApAr communicates the range of prior probability and test cutoffs for which a predictive model has positive utility — larger ApAr values suggest broader potential use of the model.
Installation
pip install apar
For plotting support:
pip install apar[plot]
Quick Start
from sklearn.datasets import load_diabetes
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_curve
import numpy as np
from apar import applicability_area
# Example: binary classification
X, y = load_diabetes(return_X_y=True)
y_binary = (y > np.median(y)).astype(int)
model = LogisticRegression(max_iter=1000).fit(X, y_binary)
y_scores = model.predict_proba(X)[:, 1]
fpr, tpr, thresholds = roc_curve(y_binary, y_scores)
# Compute ApAr
result = applicability_area(
tpr=tpr,
fpr=fpr,
thresholds=thresholds,
u_tn=1.0, # utility of true negative (highest)
u_tp=0.8, # utility of true positive
u_fn=0.0, # utility of false negative (lowest)
u_fp=0.6, # utility of false positive
)
print(f"Applicability Area: {result['apar']}")
Visualize
from apar import plot_applicability_area
plot_applicability_area(result, title="My Model's Applicability Area")
Key Concepts
The framework considers three clinical strategies in a binary classification problem:
| Strategy | Description |
|---|---|
| Treat All | Treat all patients as if they have the condition |
| Treat None | Treat no one — assume everyone is free of the condition |
| Test | Use the predictive model to decide who to treat |
ApAr integrates the range of prior probabilities over the ROC curve where the Test strategy has the highest expected utility. This goes beyond AUROC by incorporating the decision context (utilities/costs) into model evaluation.
API Reference
Core Functions
applicability_area(tpr, fpr, thresholds, u_tn, u_tp, u_fn, u_fp, ...)— Compute the ApAr metric.compute_thresholds(sensitivity, specificity, u_tn, u_tp, u_fn, u_fp)— Get the pL/pStar/pU thresholds for a single operating point.compute_thresholds_over_roc(tpr, fpr, u_tn, u_tp, u_fn, u_fp)— Thresholds for every ROC operating point.treat_all(p, u_fp, u_tp)— Expected utility of the "treat all" strategy.treat_none(p, u_fn, u_tn)— Expected utility of the "treat none" strategy.test_utility(p, sensitivity, specificity, u_tn, u_tp, u_fn, u_fp)— Expected utility of the "test" strategy.
Plotting
plot_applicability_area(result)— Plot the ApAr diagram with shaded applicable region.plot_utility_lines(sensitivity, specificity, u_tn, u_tp, u_fn, u_fp)— Plot the Kassirer-Pauker utility lines.
Citation
If you use ApAr in your research, please cite:
@article{liu2023applicability,
title={Applicability Area: A novel utility-based approach for evaluating predictive models, beyond discrimination},
author={Liu, Star and Wei, Shixiong and Lehmann, Harold P},
journal={AMIA Annual Symposium Proceedings},
volume={2023},
pages={494--503},
year={2024},
publisher={American Medical Informatics Association}
}
Liu S, Wei S, Lehmann HP. Applicability Area: A novel utility-based approach for evaluating predictive models, beyond discrimination. AMIA Annu Symp Proc. 2024 Jan 11;2023:494-503. PMID: 38222359
License
MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file apar-0.1.0.tar.gz.
File metadata
- Download URL: apar-0.1.0.tar.gz
- Upload date:
- Size: 16.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c023fb4163316c3c91f9f09e69a8c1181b03f2213bf05401acd16f5e4f63580b
|
|
| MD5 |
4302e90d422ff6bae06c9b7b053f7835
|
|
| BLAKE2b-256 |
505efbadf47b007555835a5b33d48d20595fbb0c01fb0f65f6af88fc00648f99
|
Provenance
The following attestation bundles were made for apar-0.1.0.tar.gz:
Publisher:
ci.yml on StarLiu1/apar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
apar-0.1.0.tar.gz -
Subject digest:
c023fb4163316c3c91f9f09e69a8c1181b03f2213bf05401acd16f5e4f63580b - Sigstore transparency entry: 1066588712
- Sigstore integration time:
-
Permalink:
StarLiu1/apar@051654217a2754f6876cd10778784868a5e4b6ab -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/StarLiu1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@051654217a2754f6876cd10778784868a5e4b6ab -
Trigger Event:
release
-
Statement type:
File details
Details for the file apar-0.1.0-py3-none-any.whl.
File metadata
- Download URL: apar-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e0093db1118cb80da3f528a9cc48c3545cdae42ee6272630f62ece92e4dde6f
|
|
| MD5 |
6b82ce0802474d61d240da677263f128
|
|
| BLAKE2b-256 |
1cb0d20670de0b62e1ac84936ef7bf0cfe1f2b86463e9630438428b06a569fd2
|
Provenance
The following attestation bundles were made for apar-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on StarLiu1/apar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
apar-0.1.0-py3-none-any.whl -
Subject digest:
6e0093db1118cb80da3f528a9cc48c3545cdae42ee6272630f62ece92e4dde6f - Sigstore transparency entry: 1066588716
- Sigstore integration time:
-
Permalink:
StarLiu1/apar@051654217a2754f6876cd10778784868a5e4b6ab -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/StarLiu1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@051654217a2754f6876cd10778784868a5e4b6ab -
Trigger Event:
release
-
Statement type: