Skip to main content

recursive-pietro

SHAP-based recursive feature elimination with cross-validation and early stopping.

Drop-in sklearn-compatible replacement for Probatus ShapRFECV — faster, cleaner, and works in pipelines.

Installation

pip install recursive-pietro

With optional boosting-library support:

pip install recursive-pietro[lightgbm]   # LightGBM early stopping
pip install recursive-pietro[xgboost]    # XGBoost early stopping
pip install recursive-pietro[catboost]   # CatBoost early stopping
pip install recursive-pietro[plot]       # matplotlib plotting
pip install recursive-pietro[all]        # everything

Quick start

from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
from recursive_pietro import ShapFeatureElimination

X, y = make_classification(n_samples=200, n_features=15, n_informative=5, random_state=42)

selector = ShapFeatureElimination(
    RandomForestClassifier(n_estimators=50, random_state=42),
    step=0.2,
    cv=3,
    scoring="roc_auc",
    random_state=42,
)

selector.fit(X, y)

# Selected features
print(selector.selected_features_)

# Use in transform
X_reduced = selector.transform(X)

Early stopping (LightGBM / XGBoost / CatBoost)

from lightgbm import LGBMClassifier

selector = ShapFeatureElimination(
    LGBMClassifier(n_estimators=500, random_state=42),
    step=0.2,
    cv=5,
    scoring="roc_auc",
    early_stopping_rounds=50,
    eval_metric="auc",
)

selector.fit(X, y)

Feature set selection strategies

After fitting, choose different feature sets from the elimination report:

selector.get_feature_set(method="best")              # highest validation score
selector.get_feature_set(method="best_parsimonious")  # fewest features within threshold
selector.get_feature_set(method="best_coherent")      # lowest std within threshold
selector.get_feature_set(method=10)                   # exactly 10 features

sklearn pipeline support

from sklearn.pipeline import Pipeline
from sklearn.linear_model import LogisticRegression

pipe = Pipeline([
    ("feature_selection", ShapFeatureElimination(
        RandomForestClassifier(n_estimators=50, random_state=42),
        step=1, cv=3, scoring="roc_auc",
    )),
    ("classifier", LogisticRegression()),
])

pipe.fit(X, y)

Plotting

pip install recursive-pietro[plot]
selector.plot()

License

MIT

Metadata

Release files for recursive-pietro 0.2.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 recursive-pietro 0.2.0
File Size Uploaded
recursive_pietro-0.2.0.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for recursive-pietro 0.2.0
File Interpreter ABI Platform
recursive_pietro-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.3 kB

Release files / recursive_pietro-0.2.0.tar.gz

Download URL recursive_pietro-0.2.0.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e01ac885fa9fd86d078651555915c079e62a57e7dc2306db83ac19506c91f984
BLAKE2b-256 checksum
How to use checksums
4372d4b02b3d5621d1491072bc4a9c24a601909eefc37b30d5e10a3ef4743880
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 26, 2026.

Transparency log

Release files / recursive_pietro-0.2.0-py3-none-any.whl

Download URL recursive_pietro-0.2.0-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f875704f91a3f5a5fc3a9b0f97816edee9044e78ddd0f394cce29f4330a1c7e
BLAKE2b-256 checksum
How to use checksums
2f04df42c8c6dd94ae69ae5584e2051cf9ef0df905c6ed0e9b8b05b0ab95ab4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 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