Registry / ai-ml / shap-hypetune

shap-hypetune

JSON →
library0.2.7pypypiunverified

A Python package for simultaneous hyperparameters tuning and feature selection for gradient boosting models (LightGBM, XGBoost, CatBoost, Random Forest). Current version: 0.2.7. Release cadence: occasional, last release Jun 2023.

pip install shap-hypetune
INSTALL
IMPORT
SIG · SHAP-HYPETUNE
S
shap-hypetune
ai-mlpythonv0.2.7
Install
19.8s avg
Import
Disk
569MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 19.8s · import 0.000s · 558MB
569MB installed
● package 569MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BoostingRFA
from shap_hypetune import BoostingRFA
from shap_hypetune import RFA
RFA was added in v0.2.4 but the class is actually named BoostingRFA; importing just 'RFA' fails
BoostingRFE
from shap_hypetune import BoostingRFE
from shap_hypetune.rfe import BoostingRFE
Top-level import works; no submodule needed
BoostingRFECV
from shap_hypetune import BoostingRFECV
BoostingSelector
from shap_hypetune import BoostingSelector
from shap_hypetune.selector import BoostingSelector
Top-level import is correct; submodule not directly exposed

Basic usage: perform recursive feature addition with hyperparameter tuning using LightGBM. Note: estimator can be 'lgbm', 'xgb', 'catboost', or 'rf' (Random Forest, added in v0.2.4).

import pandas as pd from sklearn.datasets import make_classification from sklearn.model_selection import train_test_split from shap_hypetune import BoostingRFA X, y = make_classification(n_samples=100, n_features=20, random_state=0) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0) model = BoostingRFA(estimator='lgbm', n_iter=5, early_stopping_rounds=10, random_state=0) model.fit(X_train, y_train) print('Train accuracy:', model.score(X_train, y_train)) print('Selected features:', model.get_support())
Debug
Known issues
breakingIn v0.2.7, numpy types np.bool, np.int, np.float were replaced by native Python types. If you rely on exact numpy dtypes in model outputs, upgrade numpy to >=1.20 and check your custom callbacks.
fix
Upgrade to v0.2.7 or cast numpy types explicitly.
affects: <=0.2.6
gotchaThe 'n_iter' parameter controls both tuning and feature selection iterations; setting it too low may result in poor convergence. In BoostingRFA and BoostingRFE, n_iter is the total number of trials (if hyperopt=True) or grid points (if grid=True).
fix
Use at least 10-20 iterations for tuning; increase if using hyperopt=True.
affects: all
gotchaFeature selection methods (RFA, RFE) require a fitted model with feature importance; if you pass a custom estimator that does not provide 'feature_importances_', it will raise an error.
fix
Use only LightGBM, XGBoost, CatBoost, or Random Forest as the base estimator, or ensure custom estimator has the attribute.
affects: all
deprecatedUsage of 'estimator' parameter as a string (e.g., 'lgbm') is stable, but passing a scikit-learn estimator object is experimental and may break in future versions.
fix
Stick to string names for now; if you need a custom estimator, test thoroughly.
affects: all
Upgrade
Version history
0.2.7latest on PyPI · released Feb 21, 2024
Audit
Dependencies
numpyrequiredCore numerical dependency
pandasrequiredData structure for input features
scikit-learnrequiredBase estimator and compatibility
shaprequiredSHAP importance for feature selection
lightgbmoptionalOne of the supported gradient boosting engines
xgboostoptionalOne of the supported gradient boosting engines
catboostoptionalOne of the supported gradient boosting engines
hyperoptoptionalAlternative tuning method (used with hyperopt=True)
Agent activity
24 hits · last 30 days
node
16
OpenAI (training)
1
Resources
shap-hypetune — pip install shap-hypetune · libregistry