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
pip install afisp-rs
Original AFISP compatibility (EBM cross-fit, pandas, plotting, statsmodels):
pip install "afisp-rs[original]"
Demo extras (includes PyTorch surrogate losses):
pip install "afisp-rs[demo]"
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)
import numpy as np
from sklearn.ensemble import RandomForestRegressor
from afisp_rs import WorstSubsetFinder, SubgroupPhenotyper, brier_loss
y_true = np.array([0, 1, 0, 1, 0, 1], dtype=np.uint8)
y_score = np.array([0.2, 0.8, 0.3, 0.7, 0.1, 0.9])
losses = np.asarray(brier_loss(y_true, y_score))
X = np.random.randn(len(losses), 3)
finder = WorstSubsetFinder(subset_fractions=[0.5, 1.0], eps=1e-8, random_state=7)
finder.fit_with_estimator(X, losses, RandomForestRegressor(random_state=7), cv=3)
print("Worst-case risks:", finder.r_hats_)
print("Subset masks:", finder.subset_masks())
subset_labels = finder.subset_masks()[0].astype(np.uint8)
phen = SubgroupPhenotyper(backend="sirus", random_state=7, sirus_num_trees=64)
phen.fit(
X,
subset_labels,
losses,
y_true=y_true,
y_score=y_score,
performance_threshold=0.6,
)
print(phen.summary_table())
Original-style sklearn API
from afisp import WorstSubsetFinder, SubgroupPhenotyper
# Requires: pip install "afisp-rs[original]"
# Uses ExplainableBoostingRegressor by default for conditional-loss cross-fit.
finder = WorstSubsetFinder(subset_fractions=[0.2, 0.4, 1.0], cv=10, eps=1e-5)
finder.fit(X, losses, feature_names=["age", "sex", "score"])
print(finder.R_hats_)
print(finder.confidence_intervals())
idx, effect = finder.find_max_effect_size()
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)
[dependencies]
afisp_rs = { version = "0.1", default-features = false }
Pure Rust usage (no Python):
use afisp_rs::WorstSubsetFinderCore;
let mut finder = WorstSubsetFinderCore::new(vec![0.2, 1.0], 0.0, 0);
finder.fit_from_mu_hat(losses, mu_hat, Some(fold_ids)).unwrap();
Enable the Python extension when building with maturin: --features extension-module.
Development (from source)
git clone https://github.com/na399/afisp-rs.git
cd afisp-rs
python -m pip install maturin pytest numpy scikit-learn
maturin develop --release --features extension-module
pytest -q
cargo test --no-default-features
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.
Metadata
Release files for afisp-rs 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| afisp_rs-0.1.1.tar.gz | 29.4 kB | Without provenance | Details for afisp_rs-0.1.1.tar.gz |
Built distributions (wheels)
Total release size: 8.1 MB
Release files / afisp_rs-0.1.1.tar.gz
| Download URL | afisp_rs-0.1.1.tar.gz |
|---|---|
| Size | 29.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a08761c9294f86f80b6ccddfbe90a8bda50516ebe9c2492f1ded1b6270164584
|
|
BLAKE2b-256 checksum How to use checksums |
fee9c34013090dd927fa20e080fa49a4b2436e6ff0b3e936850a1b4415a153c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | afisp_rs-0.1.1-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 414.8 kB |
| Tags | Linux glibc 2.17+ ARM64 PyPy 3.11 PyPy 3.11 7.3 |
|
SHA-256 checksum How to use checksums |
ecbe0da2660941938d06e816a6457502de3d9b6fc60215ed9f7783193c7576d3
|
|
BLAKE2b-256 checksum How to use checksums |
c760e95c95cf884c7824c7de1f7ace70524a8c165f56fdcd2f2bfc1c2b861a55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | afisp_rs-0.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 407.2 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
dc453b831adacec9f7c71b4bd19a8bc0be0549a4775f04f5a2a3d28db02c97d9
|
|
BLAKE2b-256 checksum How to use checksums |
0c6de5ad912123888deec04d572e0c6e8057129fa988dca7224b77e600bc633a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp314-cp314-win_amd64.whl
| Download URL | afisp_rs-0.1.1-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 269.0 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ee3185cc18c80ed6794133208d9f82e96d187eef05d227ce1536af91937d45d9
|
|
BLAKE2b-256 checksum How to use checksums |
ce154d4a80728077c7a123203caa7edfb2b70e1f6f34fa56a9ef1ba2fc5fcb2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | afisp_rs-0.1.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 409.5 kB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
2f390a287ed3569df1acdef7792fe94a4c4c3d12bbf9e17dffabd5caa4db089a
|
|
BLAKE2b-256 checksum How to use checksums |
464f2f7f41124a303a3f50957c7d596b05cac6190e0b21a5db563a196cf12ada
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | afisp_rs-0.1.1-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 739.3 kB |
| Tags | CPython 3.14 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ba9130227ce82ab474a31ac463c09396c7d84961f2b1c409015abcba688f9297
|
|
BLAKE2b-256 checksum How to use checksums |
19aaa920e4d44efb87882b410d41bb9599f99aa4bdbe09c2434ca7824c181524
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp313-cp313-win_amd64.whl
| Download URL | afisp_rs-0.1.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 268.0 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1d4e1a2729b9ff18c730303f1b3fa8cecc584999a4a1061d61a82948fd69e03f
|
|
BLAKE2b-256 checksum How to use checksums |
29dafb5c5d3b9e4e25c3ab5071e214d0a33571fed158594ac9898c9ce0e9a769
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | afisp_rs-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 409.4 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
d5bef11e8ac570664fef5d481c6bd74d5f0f322242d8cc8903d383d1f2d33d26
|
|
BLAKE2b-256 checksum How to use checksums |
223a471888f0a0a41b0b96fcdd175ad5873ed52a47ddb871dd173afc5f1b30ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | afisp_rs-0.1.1-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 739.4 kB |
| Tags | CPython 3.13 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
697b223949a62ac1ea0d7c67ea071c893756e7203b03dc673d505d8832562373
|
|
BLAKE2b-256 checksum How to use checksums |
057033eea336c741ea07412f4b5acc4bd4c4269b635aa1c27f18b70444c36178
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp312-cp312-win_amd64.whl
| Download URL | afisp_rs-0.1.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 268.6 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7315bea413fa8db6c18217c46b0abce50e1d00a7fc50f58e5bdd31868b0777ad
|
|
BLAKE2b-256 checksum How to use checksums |
a5288966758966946f4e093efd12d9a39c7021d457cb9363f31d906cfa25f90c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | afisp_rs-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 422.0 kB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
bd1c72061d812e0226ab95b75f5d779e5e6442da87da91f59466f00159b80588
|
|
BLAKE2b-256 checksum How to use checksums |
d5dcc345eaa87f52170fbc7200e1aa9a2bd61f7565042357ce5b457ea27f8ab4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | afisp_rs-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 409.4 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
3a2db8b89eafe9f111e5937f6813025aafe3840cfbb497cf8df62c70f23322af
|
|
BLAKE2b-256 checksum How to use checksums |
624508a7f83333f8b957fcefa70459043051ee2a7cf410733a8f4c0218e277a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | afisp_rs-0.1.1-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 740.1 kB |
| Tags | CPython 3.12 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7955a89ed8162979142b31264551a3131f596ec06ec47ade5fa8f7cddaab22c7
|
|
BLAKE2b-256 checksum How to use checksums |
08f7554ccc33e5e6c00c02646cc2caf081363712423c4fc25310fc0c8c90e117
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp311-cp311-win_amd64.whl
| Download URL | afisp_rs-0.1.1-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 271.7 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
767a1a51df0aaba1025104fbbab0ab166db55aebd7a0860352fd0f518e923108
|
|
BLAKE2b-256 checksum How to use checksums |
5a4399f8832805049e7348e4d4b13f5d389f82eb19e72af354e1eb065a11eddf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | afisp_rs-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 413.3 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
c71e2e6422bda034fc639d4ca03632a3f4becc6bb299f5dff59777dcf1e6283f
|
|
BLAKE2b-256 checksum How to use checksums |
97192733a22f195e987cb1b1cc3a34805e95b97fffb0b95524016d6cf861e7d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | afisp_rs-0.1.1-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 746.1 kB |
| Tags | CPython 3.11 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
94328b041331e160d0c23d70332d584e43b5e50ca8705ecee123e1c1948d9ae7
|
|
BLAKE2b-256 checksum How to use checksums |
d27f512a5d5c3f7eee9e298ba46b652215f591af558924e59cfe5f622d41a45e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp310-cp310-win_amd64.whl
| Download URL | afisp_rs-0.1.1-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 271.5 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f186265371a26515106c32ccf6014a17a4fcec1b2b8f9db9c39bc6a6931a283a
|
|
BLAKE2b-256 checksum How to use checksums |
3f9a96f9a18414f31bf1f291953d3752609f777edbc8214c8b33cc7077b60fa9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | afisp_rs-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 413.1 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
139ab82066ccc57f11d7b8d06026815fba25ecda6dbf44975f91c942f7981f47
|
|
BLAKE2b-256 checksum How to use checksums |
8b4655963c666480f9217e1f62803c2e6ea60302d8e740bdd6aaf807b22e46c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / afisp_rs-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | afisp_rs-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 415.9 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
e97db816729691ec9d26b1d607d99634479cbc388c4f820917035074adae830c
|
|
BLAKE2b-256 checksum How to use checksums |
a4bcdc56141fa5c28f4fdf6ad385961959f00ebce4b805f21d8f42d1e30f5d55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Security for afisp-rs 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.