Library consist of two groups of Classes - Feature selectors and DFwrapper to have a deal with outliers and correlation
- Feature selection group
The FeatureSelection calculates the importance of features based on the Shap library for a classification problem.
Only works with trees for better efficiency or models based on
gradient boosting. It is a priority to use such models as:
Catboost - does not require handling of NaN and categories. works with sklearn
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
!pip install shap
!pip install phik
https://pypi.org/project/SHFS/
FeatureSelectionClf - for classification
FeatureSelectionRegression - for regression
FeatureSelectionUniversal - for both classification and regression tasks
Quick start: Collab and Tutorial
Parametrs.
`estimator` :
Supervised learning with the fit method will allow you to retrieve and select indices.
the most important features.
n_features_to_select: int, default = None.
The number of features to select, the default is None.
columns: List, default = None.
The list of attributes of the initial set, the default is None.
Methods
fit - trains and identifies the most important features
tranform - changes the original set and returns the selected attributes
get_index - Returns the selected indexes attributes
only for FeatureSelectionClf and FeatureSelectionRegression:
plot_values - plotting shap values
_estimator_type - @property method
get_feature_importance - Returns DataFrame FI
Note
Nan / Inf are allowed in case they are accepted by the fit method model Example use for classification
cols = list(X_train.columns)
cat_features = list(X_train_cat.select_dtypes(include=['object', 'category']).columns)
num_features = list(X_train_cat.select_dtypes(exclude=['object', 'category']).columns)
estimator = CatBoostClassifier(**params_cat)
selector = FeatureSelectionClf(estimator, n_features_to_select=3, columns=cols)
preprocessor = ColumnTransformer (
transformers = [
('std_scaler' , StandardScaler() , num_features) ,
('cat' , OrdinalEncoder() , cat_features),
]
)
pipe = Pipeline(steps=
[
('preprocessor', preprocessor),
('selector', selector)
]
)
X_train_prep = pipe.fit_transform(X_train)
Example without Pipeline
cols = list(X_train.columns)
estimator = CatBoostClassifier(**params_cat)
selector = FeatureSelectionClf(estimator, n_features_to_select=3, columns=cols)
X = selector.fit(X_train_prep, y_train)
- DFwrapper
DFwrapper - remove multicollinearity and outliers from Pandas DataFrame
Usage example
----------
1. Collinearity
cleaner = DFwrapper()
new_df = cleaner.wrap_corr(df)
2. Outliers. Rough cleaning
cleaner = DFwrapper(low=.05, high=.95)
cleaned = cleaner.quantile_cleaner(df, cols_to_clean)
2. Outliers. Finer cleaning
cleaner = DFwrapper(koeff=1.5)
cleaned = cleaner.frame_irq(df, cols_to_clean)
Metadata
Release files for SHFS 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| SHFS-0.1.5.tar.gz | 7.3 kB | Without provenance | Details for SHFS-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| SHFS-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for SHFS-0.1.5-py3-none-any.whl |
Total release size: 17.3 kB
Release files / SHFS-0.1.5.tar.gz
| Download URL | SHFS-0.1.5.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8187be4fbab247812c8f4a87c5f317a1e82c4762981015ca65409491257992e1
|
|
BLAKE2b-256 checksum How to use checksums |
07c3fc067196c2830990dbcbd609d8860e01bc82dc965e3ed86791560f6ede9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.8.1 requests/2.26.0 setuptools/58.3.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5
|
Release files / SHFS-0.1.5-py3-none-any.whl
| Download URL | SHFS-0.1.5-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
42b0e03007f0899e68ec5bedb9eb9dc041444106de92283ba4ed2141f4050cd1
|
|
BLAKE2b-256 checksum How to use checksums |
150fb69c763857bcd12c74bc557dd8c4a45ad082607db0ff66cd8098c3eb3a5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.8.1 requests/2.26.0 setuptools/58.3.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5
|
Security for SHFS 0.1.5
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.