Prediction Accuracy Subgroup Identification - Find subgroups with differential model performance
Project description
PASI: Prediction Accuracy Subgroup Identification
A Python package implementing PASI Trees - a tree-based algorithm to find subgroups with differential model performance for a given prediction model and a given accuracy measure.
Installation
pip install pasi
Features
- Identify Subgroups with Differential Performance: Discover subgroups where your predictive model performs differently
- Multiple Accuracy Measures:
- Individual-level accuracy estimation
- AUC (Area Under the ROC Curve) with confidence intervals
- AUPRC (Area Under the Precision-Recall Curve) with confidence intervals
- Statistical Rigor: Includes variance estimation and confidence intervals for all metrics
- Optimized Performance: Uses parallel processing and efficient algorithms for large datasets
Quick Start
import pandas as pd
import numpy as np
from pasi_test import pasiTree
from sklearn.linear_model import LogisticRegression
# Load your data
X = pd.DataFrame(...) # Your features
y = np.array(...) # Binary target variable (0/1)
# First, train a predictive model
pred_model = LogisticRegression().fit(X, y)
y_pred = pred_model.predict_proba(X)[:, 1]
# Create a PASI tree with AUC as the accuracy measure
# This will identify subgroups with differential AUC performance
pasi_tree_auc = pasiTree(measure='auc', min_samples_leaf=100, max_depth=3)
pasi_tree_auc.fit(X=X, y=y, y_pred=y_pred)
# Create a PASI tree with AUPRC as the accuracy measure
# Useful for imbalanced datasets
pasi_tree_auprc = pasiTree(measure='auprc', min_samples_leaf=100, max_depth=3)
pasi_tree_auprc.fit(X=X, y=y, y_pred=y_pred)
# Visualize the tree
tree_dot = pasi_tree_auc.tree.export_graphviz(feature_names=list(X.columns))
# You can visualize the DOT string using tools like graphviz
# Get subgroup-specific accuracy predictions
subgroup_accuracies = pasi_tree_auc.predict(X)
Accuracy Measures
AUC (Area Under the ROC Curve)
The package implements AUC calculation with variance estimation using the DeLong method. This provides statistically rigorous confidence intervals.
AUPRC (Area Under the Precision-Recall Curve)
AUPRC is especially useful for imbalanced datasets. The implementation uses bootstrap resampling to estimate variance and confidence intervals.
Individual-level Accuracy
For regression or custom metrics, you can provide individual-level accuracy values for each sample.
Advanced Usage
Pruning Trees
# Prune the tree using cross-validation to avoid overfitting
pasi_tree_auc.select_pruned_tree(X, y=y, y_pred=y_pred, n_fold=5)
# The pruned tree is accessible through
pruned_tree = pasi_tree_auc.pruned_tree
Test Set Evaluation
# Evaluate identified subgroups on a test set
pasi_tree_auc.test_eval(X_test, y=y_test, y_pred=y_pred_test)
Citation
If you use this package in your research, please cite:
[Citation information will be added here]
License
This project is licensed under the MIT License - see the LICENSE file 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 pasi-0.1.0.tar.gz.
File metadata
- Download URL: pasi-0.1.0.tar.gz
- Upload date:
- Size: 56.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bb16883b56c524180b163f7acc7534d8a2720c62bc808fe87a3743ac5e942a2
|
|
| MD5 |
5490313978448b281f7265a10942bff8
|
|
| BLAKE2b-256 |
d1a4cd2467068bf04426777b2bab601cfbbe183bf12a6b3a8b7aac32746d5985
|
File details
Details for the file pasi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pasi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65d248c4e7244e05a92d57e68f1feba352277178c43c9a0fd2a497453b9413fc
|
|
| MD5 |
9cf65b601038ec9be11112ebd482b243
|
|
| BLAKE2b-256 |
dce55fe312d9c24cf8407f77852f2d6e06549f522b718f8075377c195369b29e
|