afisp-rs
A clean-room Rust + PyO3 implementation of the AFISP workflow: stability analysis to find worst-performing data subsets, then interpretable subgroup phenotyping.
Full documentation: DOCUMENTATION.md
Two Python APIs ship in one package:
| Import | Use when |
|---|---|
from afisp import … |
You want the original sklearn-style API (fit(X, losses), optional EBM, plotting) |
from afisp_rs import … |
You want the Rust-backed API (fit_from_mu_hat, fit_with_estimator, explicit backends) |
Install from PyPI
Original AFISP compatibility (EBM cross-fit, pandas, plotting, statsmodels):
Demo extras (includes PyTorch surrogate losses):
Requires Python ≥ 3.9 and numpy. Prebuilt wheels are provided for common Linux, macOS, and Windows platforms. If no wheel matches your platform, pip builds from source and you will need Rust + Python dev headers.
Quick start
Rust-native API (recommended for new code)
=
=
=
=
=
=
=
Original-style sklearn API
# Requires: pip install "afisp-rs[original]"
# Uses ExplainableBoostingRegressor by default for conditional-loss cross-fit.
=
, =
For Rust-backed phenotyping through the compatibility layer, pass y_true, y_score, and performance_threshold to SubgroupPhenotyper.fit().
What is implemented
Stage 1 — Stability analysis
- Fold-aware worst-subset thresholds on out-of-fold conditional loss estimates (
mu_hat) - Influence-function style worst-case risk estimator with analytical 95% CIs
- Subset masks, observed fractions, Cohen's d effect sizes
Stage 2 — Subgroup phenotyping
backend="sirus"— Rust-native stable rule forest (default)backend="conjunction"— deterministic conjunction miner (DecisionList fallback inafisplayer)- Bootstrap AUROC CIs, Holm–Bonferroni correction, Cohen's d filtering
See DESIGN.md for fidelity notes vs the upstream Python reference.
Rust library (crates.io)
[]
= { = "0.1", = false }
Pure Rust usage (no Python):
use WorstSubsetFinderCore;
let mut finder = new;
finder.fit_from_mu_hat.unwrap;
Enable the Python extension when building with maturin: --features extension-module.
Development (from source)
Full example: examples/demo.py
Publishing
Maintainers: see PUBLISHING.md. Releases are automated on v* tags to PyPI (afisp-rs) and crates.io (afisp_rs).
License
MIT License. See LICENSE.