Skip to main content

afisp-rs

A clean-room Rust + PyO3 implementation of the AFISP workflow: stability analysis to find worst-performing data subsets, then interpretable subgroup phenotyping.

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

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 in afisp layer)
  • 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

Dual-licensed under MIT OR Apache-2.0.

Metadata

Release files for afisp-rs 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for afisp-rs 0.1.0
File Size Uploaded
afisp_rs-0.1.0.tar.gz 29.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for afisp-rs 0.1.0
File
afisp_rs-0.1.0-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl PyPy 3.11 PyPy 3.11 7.3 Linux glibc 2.17+ ARM64 Details
afisp_rs-0.1.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 Details
afisp_rs-0.1.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
afisp_rs-0.1.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ ARM64 Details
afisp_rs-0.1.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.14 CPython 3.14 macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) Details
afisp_rs-0.1.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
afisp_rs-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64 Details
afisp_rs-0.1.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) Details
afisp_rs-0.1.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
afisp_rs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
afisp_rs-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
afisp_rs-0.1.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) Details
afisp_rs-0.1.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
afisp_rs-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
afisp_rs-0.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.11 CPython 3.11 macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) Details
afisp_rs-0.1.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
afisp_rs-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64 Details
afisp_rs-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ ARM64 Details

Total release size: 8.1 MB

Release files / afisp_rs-0.1.0.tar.gz

Download URL afisp_rs-0.1.0.tar.gz
Size 29.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3301e6ab7afeedd401e249cb065bb4d0eb30abb43486ebfc6eee1d7b2445560e
BLAKE2b-256 checksum
How to use checksums
741055a07cc7bc40fe904df7f570df6b7d2293fb2d79bcb5b6c37e11fd82fcb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL afisp_rs-0.1.0-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 418.5 kB
Tags Linux glibc 2.17+ ARM64 PyPy 3.11 PyPy 3.11 7.3
SHA-256 checksum
How to use checksums
711ed4e65765500bec46ca7da9b86c999b5dc75b08f956ec4a280ce175543a36
BLAKE2b-256 checksum
How to use checksums
cb7b1a0f20c1bb95a1c8632be52c183dc1ee19902d2062385c04f6ea86ab77e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL afisp_rs-0.1.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 411.1 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
00cad7014effd34926e712d37fb941db529833c8166c9c07de0409f37a705ac1
BLAKE2b-256 checksum
How to use checksums
c1b78d496f9de3f286ae23da4024ed3fc20c760aa2eaa709b023c49ab2939424
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp314-cp314-win_amd64.whl

Download URL afisp_rs-0.1.0-cp314-cp314-win_amd64.whl
Size 273.0 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
feb5928f46439f81ddae72b1dac8a6f229f5971bf4c9ef87558f71be11802cda
BLAKE2b-256 checksum
How to use checksums
caebe22bc1414121308199fab27fffe4cde8169e19ccd15a06d03c02551abbe2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL afisp_rs-0.1.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 413.3 kB
Tags CPython 3.14 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
e0090351e9816ebf53041019519ae77901eb58525ec1c47afa532ab0cbef2d92
BLAKE2b-256 checksum
How to use checksums
80df729ca6849308229cab3974f7c777cb612b0237541176812f905133934447
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL afisp_rs-0.1.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 743.2 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
cd37d6e0e89c5cba2b7d8132c915b2b357297da95efaf2961858e17ee04b4654
BLAKE2b-256 checksum
How to use checksums
4000b2b90b8f6fe0a4cbf460fb1569482261e6e745fc5963564ee8822b618447
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp313-cp313-win_amd64.whl

Download URL afisp_rs-0.1.0-cp313-cp313-win_amd64.whl
Size 272.0 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
e8fe6dc0a22b8c1b1b1aee7244a96ca2ccecce31803a77f6e55b70d92de0971c
BLAKE2b-256 checksum
How to use checksums
b7711d0fab326adba2ca7df6b65881c764decf4737b29e8f70a2e5aeee488633
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL afisp_rs-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 413.3 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
800f7149271271dfc3c703cfd63533dea63d282e77256e5f7780e0b7eeab7d1c
BLAKE2b-256 checksum
How to use checksums
4f1f5a9eb1a823a011fbd11b88699e1e7f74d2df5021abd2e3aa52ea5f1bf548
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL afisp_rs-0.1.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 743.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
19e58f06ca9e67ec4bbac4f890fe611f1ef391a5f8f2fd1dba1c721768cd4b6b
BLAKE2b-256 checksum
How to use checksums
2ea65e6d96a2d10df8b331052001ec8bbb4f72c8815a18351aa7dd18550eea6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp312-cp312-win_amd64.whl

Download URL afisp_rs-0.1.0-cp312-cp312-win_amd64.whl
Size 272.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
9d566f0f3114fd9079eccdda7c5aa79088c9d416e995e50e9a4f26560f224099
BLAKE2b-256 checksum
How to use checksums
f8e7519638a5dc925dddd8183956f2dfb2544871f3f85774bebbb8e0be5b1eef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL afisp_rs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Size 426.0 kB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
28c4c808eec4de21aa207d1a35bdfcd4e5a0ea323d76c90d00fbaef7904180af
BLAKE2b-256 checksum
How to use checksums
1328ff557f9490b9523350d3102a296be059335fd10570b8369c3504e20837e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL afisp_rs-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 413.5 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
475ce962d02c4bcb11ffef40a0ec63ae45ca32eabc391c36c146b517e2fbc143
BLAKE2b-256 checksum
How to use checksums
233755f989e5cc4aba48519df085199e605d20dac3ea5809eb60ae4affea6fec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL afisp_rs-0.1.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 744.0 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
d34e1a3c6aa82c1263699c2dd0835411ec50fecb3efdf8579f290e749ef0f28d
BLAKE2b-256 checksum
How to use checksums
ae897456ce8030bcd5a7afa05d8cef90f3d332520798c9355f826c8f3548adb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp311-cp311-win_amd64.whl

Download URL afisp_rs-0.1.0-cp311-cp311-win_amd64.whl
Size 275.7 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
54fb830a7a396e3bd9b2f74fa4dfbfcebcd6b92b8c9a69509ee42e9ee05249ed
BLAKE2b-256 checksum
How to use checksums
59cfc4e69030bd41c59ba76519eca3cb7e99e9fc6179baa8aa8c716cac173559
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL afisp_rs-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 417.1 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
9c578b85c375109e2528626225b596d6512ffd4870c6ff9e34e6885a3f346d0f
BLAKE2b-256 checksum
How to use checksums
0adeabd5dfc2d1ccb383da377f2e85612b2df3f64725dc1f981d8c8ab14fd446
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL afisp_rs-0.1.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 750.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
317be81cc4df8194cbb3aa00753c207c3264eaef2d5ed8561fe3144516628a36
BLAKE2b-256 checksum
How to use checksums
0fd0f50c48163d7185105b8783b906f14f6c48feab221c4fc0436f57ba801472
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp310-cp310-win_amd64.whl

Download URL afisp_rs-0.1.0-cp310-cp310-win_amd64.whl
Size 275.5 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
fcea84567bb0b0ce8b4bc2604ec56b9b1f817cbe6a8864dfde85f33cbd76848a
BLAKE2b-256 checksum
How to use checksums
f4d76fcaae5cafa2e9e8a5cd3f4dce5b931916d328d974979aaef8ba2cf75eb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL afisp_rs-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 417.0 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
ac9a8ff4ec8ecf26f4c81eee529873b02e158df748044c12b3474a73eea7dd5d
BLAKE2b-256 checksum
How to use checksums
d876dd2338a39779882a2f23413c33c7d71cc07b9421b3d4d1b8de74e30844ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / afisp_rs-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL afisp_rs-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 419.7 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
a0ef93e6194bd995ba59824d8adfd09826861ccab516241095eec6870386f684
BLAKE2b-256 checksum
How to use checksums
1f435f9359a160bbeafdfa5e7a7db1352a6204e6aecf47f6871dc22abb806951
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

19 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page