Skip to main content

.. -- mode: rst --

|pypi_version|_ |pypi_downloads|_

.. |pypi_version| image:: https://img.shields.io/pypi/v/shap-selection.svg .. _pypi_version: https://pypi.python.org/pypi/shap-selection/

.. |pypi_downloads| image:: https://pepy.tech/badge/shap-selection/month .. _pypi_downloads: https://pepy.tech/project/shap-selection

===== SHAP-Selection: Selecting feature using SHAP values

Due to the increasing concerns about machine learning interpretability, we believe that interpretation could be added to pre-processing steps. Using this library, you will be able to select the most important features from a multidimensional dataset while explaining your decisions!

To use SHAP-Selection, you will need:

  • SHAP <https://github.com/slundberg/shap>_

Instalation

.. code:: python

   pip install shap-selection

Citation

.. code:: bibtex

   @INPROCEEDINGS{MarcilioJr2020shapselection,  
     author={W. E. {Marcílio} and D. M. {Eler}}, 
     booktitle={2020 33rd SIBGRAPI Conference on Graphics, Patterns and Images (SIBGRAPI)},   
     title={From explanations to feature selection: assessing SHAP values as feature selection mechanism},   
     year={2020},  
     pages={340-347},  
     doi={10.1109/SIBGRAPI51738.2020.00053}
   }

Usage

To use SHAP-Selection, you must have a trained model. It works both for classification and regression purposes!

Load a dataset

.. code:: python

   iris_data = load_iris()

   X, y = iris_data.data, iris_data.target
   feature_names = np.array(iris_data.feature_names)

   X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)

Fit a model

.. code:: python

   model = cb.CatBoostClassifier(verbose=False)    
   model.fit(X_train, y_train)

Use SHAP-Selection

.. code:: python

   from shap_selection import feature_selection

   # please, use agnostic = True to use with any model...
   # agnostic = False will only work with tree-based models
   feature_order = feature_selection.shap_select(model, X_train, X_test, feature_names, agnostic=False)

Support

Please, if you have any questions feel free to contact me at wilson_jr@outlook.com

Metadata

Release files for shap-selection 0.1.6

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

Built distribution (wheel)

Table of built distributions (wheels) for shap-selection 0.1.6
File Interpreter ABI Platform Actions
shap_selection-0.1.6-py3-none-any.whl Python 3 none any Details for shap_selection-0.1.6-py3-none-any.whl

Release files / shap_selection-0.1.6-py3-none-any.whl

Download URL shap_selection-0.1.6-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea315b097af1c9676d2d87fa628a251c670bc567ff4fcfe347694e24a016c69e
BLAKE2b-256 checksum
How to use checksums
83651e94774a6bf42659f87dd0b131c76395a4c9dede4cfc02473acd346460c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.3

Security for shap-selection 0.1.6

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.

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