A Python package for the SHAPBoost feature selection algorithm
Project description
SHAPBoost
Python implementation of SHAPBoost. See the paper for details. R implementation is available here.
Usage
pip install shapboost
Example regression
from shapboost import SHAPBoostRegressor
from xgboost import XGBRegressor
X = ... # feature matrix
y = ... # target vector
clf = SHAPBoostRegressor(
XGBRegressor(),
metric="mae",
verbose=2,
siso_ranking_size=20,
max_number_of_features=2,
num_resets=1,
use_shap=True,
collinearity_check=True,
)
clf.fit(X, y)
print(clf.selected_subset_)
For a more detailed example, see the regression example.
Example survival
from shapboost import SHAPBoostSurvivalRegressor
from shapboost.helpers import XGBSurvivalRegressor, RandomSurvivalForestWrapper
import pandas as pd
df = ... # df with event, upper_bound, lower_bound and features
X = df.drop(columns=["event", "upper_bound", "lower_bound"])
y = df[["lower_bound", "upper_bound"]]
clf = SHAPBoostSurvivalRegressor(estimator=estimator)
feature_selector = SHAPBoostSurvivalRegressor(
[XGBSurvivalRegressor(**best_params), RandomSurvivalForestWrapper()],
metric="c_index",
verbose=0,
siso_ranking_size=50,
max_number_of_features=100,
num_resets=1,
)
feature_selector.fit(X, y)
print(clf.selected_subset_)
For a more detailed example, see the survival example.
Feature selection methods
SHAPBoost is available for regression, and survival problems.
- Regression supports the
mae,mse, andr2objectives through theSHAPBoostRegressor-class and can be optimized throughadaptiveboosting. - Survival supports the
c_indexobjective through theSHAPBoostRegressor-class and can be optimized throughadaptiveboosting.
Important notes
- The
estimatorhyperparameter sets the estimators used for the SISO- and MISO steps, and for the updating of the sample weights (or the boosting), the first estimator is used. Thus, this first estimator needs to be a tree model that supports thesample_weightparameter.
Illustration of SHAPBoost
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shapboost-1.0.1.tar.gz.
File metadata
- Download URL: shapboost-1.0.1.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75fa8d6d0d9b4d8dfc2eab7c077fa8cf51b9fb7c7d257893e63596eab38a2240
|
|
| MD5 |
80e408f3a79bdad3794f1fcbf6269bfe
|
|
| BLAKE2b-256 |
a02232c77dc5dc457cead852249ff20ff9bd619ff654f8044ddd2fbf0d94d0a2
|
File details
Details for the file shapboost-1.0.1-py3-none-any.whl.
File metadata
- Download URL: shapboost-1.0.1-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
561440d992c231d7eb1021eb34c69e7bbda5ae4c3d45a097a3ab0dfd1783c014
|
|
| MD5 |
87ba2c258fae13f32b3e012f3cd5d38d
|
|
| BLAKE2b-256 |
584e278d57f267a6f14273c1ef38465ce3bc87f12518fc0dd8d20ad5a5df1245
|