All Projects → ThomasBury → arfs

ThomasBury / arfs

Licence: MIT License
All Relevant Feature Selection

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to arfs

laravel-rollout
A package to integrate rollout into your Laravel project.
Stars: ✭ 23 (+9.52%)
Mutual labels:  feature-selection
autogbt-alt
An experimental Python package that reimplements AutoGBT using LightGBM and Optuna.
Stars: ✭ 76 (+261.9%)
Mutual labels:  lightgbm
xgboost-lightgbm-hyperparameter-tuning
Bayesian Optimization and Grid Search for xgboost/lightgbm
Stars: ✭ 40 (+90.48%)
Mutual labels:  lightgbm
FEAST
A FEAture Selection Toolbox for C/C+, Java, and Matlab/Octave.
Stars: ✭ 67 (+219.05%)
Mutual labels:  feature-selection
aws-machine-learning-university-dte
Machine Learning University: Decision Trees and Ensemble Methods
Stars: ✭ 119 (+466.67%)
Mutual labels:  lightgbm
kaggle-plasticc
Solution to Kaggle's PLAsTiCC Astronomical Classification Competition
Stars: ✭ 50 (+138.1%)
Mutual labels:  lightgbm
py ml utils
Python utilities for Machine Learning competitions
Stars: ✭ 29 (+38.1%)
Mutual labels:  feature-selection
stg
Python/R library for feature selection in neural nets. ("Feature selection using Stochastic Gates", ICML 2020)
Stars: ✭ 47 (+123.81%)
Mutual labels:  feature-selection
recsys2019
The complete code and notebooks used for the ACM Recommender Systems Challenge 2019
Stars: ✭ 26 (+23.81%)
Mutual labels:  lightgbm
Tencent2017 Final Rank28 code
2017第一届腾讯社交广告高校算法大赛Rank28_code
Stars: ✭ 85 (+304.76%)
Mutual labels:  lightgbm
Apartment-Interest-Prediction
Predict people interest in renting specific NYC apartments. The challenge combines structured data, geolocalization, time data, free text and images.
Stars: ✭ 17 (-19.05%)
Mutual labels:  lightgbm
SynapseML
Simple and Distributed Machine Learning
Stars: ✭ 3,355 (+15876.19%)
Mutual labels:  lightgbm
Kaggle-Competition-Sberbank
Top 1% rankings (22/3270) code sharing for Kaggle competition Sberbank Russian Housing Market: https://www.kaggle.com/c/sberbank-russian-housing-market
Stars: ✭ 31 (+47.62%)
Mutual labels:  lightgbm
mltb
Machine Learning Tool Box
Stars: ✭ 25 (+19.05%)
Mutual labels:  lightgbm
featurewiz
Use advanced feature engineering strategies and select best features from your data set with a single line of code.
Stars: ✭ 229 (+990.48%)
Mutual labels:  feature-selection
LightGBM.jl
LightGBM.jl provides a high-performance Julia interface for Microsoft's LightGBM.
Stars: ✭ 40 (+90.48%)
Mutual labels:  lightgbm
zoofs
zoofs is a python library for performing feature selection using a variety of nature-inspired wrapper algorithms. The algorithms range from swarm-intelligence to physics-based to Evolutionary. It's easy to use , flexible and powerful tool to reduce your feature size.
Stars: ✭ 142 (+576.19%)
Mutual labels:  feature-selection
ai-deployment
关注AI模型上线、模型部署
Stars: ✭ 149 (+609.52%)
Mutual labels:  lightgbm
lleaves
Compiler for LightGBM gradient-boosted trees, based on LLVM. Speeds up prediction by ≥10x.
Stars: ✭ 132 (+528.57%)
Mutual labels:  lightgbm
Market-Mix-Modeling
Market Mix Modelling for an eCommerce firm to estimate the impact of various marketing levers on sales
Stars: ✭ 31 (+47.62%)
Mutual labels:  feature-selection

drawing

buy me caffeine

PyPI version Downloads Documentation Status Code Style

ARFS readthedocs

All relevant feature selection

All relevant feature selection means trying to find all features carrying information usable for prediction, rather than finding a possibly compact subset of features on which some particular model has a minimal error. This might include redundant predictors. All relevant feature selection is model agnostic in the sense that it doesn't optimize a scoring function for a specific model but rather tries to select all the predictors which are related to the response.

This package implements 3 different methods (Leshy is an evolution of Boruta, BoostAGroota is an evolution of BoostARoota and GrootCV is a new one). They are sklearn compatible. See hereunder for details about those methods. You can use any sklearn compatible estimator with Leshy and BoostAGroota but I recommend lightGBM. It's fast, accurate and has SHAP values builtin.

Moreover, it provides a module for performing pre-filtering (columns with too many missing values, zero variance, high-cardinality, highly correlated, etc.). Examples and detailled methods hereunder.

Installation

$ pip install arfs, requires python <3.10

Example

Working examples for:

For imbalanced classification:

  • GrootCV will automatically detect imbalanced data and set the lightGBM 'is_unbalance' = True
  • For Leshy and BoostAGroota, you can pass the estimator with the relevant parameter (e.g. class_weight = 'balanced')

Boruta

The Boruta algorithm tries to capture all the important features you might have in your dataset with respect to an outcome variable. The procedure is the following:

  • Create duplicate copies of all independent variables. When the number of independent variables in the original data is less than 5, create at least 5 copies using existing variables.
  • Shuffle the values of added duplicate copies to remove their correlations with the target variable. It is called shadow features or permuted copies.
  • Combine the original ones with shuffled copies
  • Run a random forest classifier on the combined dataset and performs a variable importance measure (the default is Mean Decrease Accuracy) to evaluate the importance of each variable where higher means more important.
  • Then Z score is computed. It means mean of accuracy loss divided by the standard deviation of accuracy loss.
  • Find the maximum Z score among shadow attributes (MZSA)
  • Tag the variables as 'unimportant' when they have importance significantly lower than MZSA. Then we permanently remove them from the process.
  • Tag the variables as 'important' when they have importance significantly higher than MZSA.
  • Repeat the above steps for a predefined number of iterations (random forest runs), or until all attributes are either tagged 'unimportant' or 'important', whichever comes first.

At every iteration, the algorithm compares the Z-scores of the shuffled copies of the features and the original features to see if the latter performed better than the former. If it does, the algorithm will mark the feature as important. In essence, the algorithm is trying to validate the importance of the feature by comparing with randomly shuffled copies, which increases the robustness. This is done by simply comparing the number of times a feature did better with the shadow features using a binomial distribution. Since the whole process is done on the same train-test split, the variance of the variable importance comes only from the different re-fit of the model over the different iterations.

BoostARoota

BoostARoota follows closely the Boruta method but modifies a few things:

  • One-Hot-Encode the feature set
  • Double width of the data set, making a copy of all features in the original dataset
  • Randomly shuffle the new features created in (2). These duplicated and shuffled features are referred to as "shadow features"
  • Run XGBoost classifier on the entire data set ten times. Running it ten times allows for random noise to be smoothed, resulting in more robust estimates of importance. The number of repeats is a parameter than can be changed.
  • Obtain importance values for each feature. This is a simple importance metric that sums up how many times the particular feature was split on in the XGBoost algorithm.
  • Compute "cutoff": the average feature importance value for all shadow features and divide by four. Shadow importance values are divided by four (parameter can be changed) to make it more difficult for the variables to be removed. With values lower than this, features are removed at too high of a rate.
  • Remove features with average importance across the ten iterations that is less than the cutoff specified in (6)
  • Go back to (2) until the number of features removed is less than ten per cent of the total.
  • Method returns the features remaining once completed.

In the spirit, the same heuristic than Boruta but using Boosting (originally Boruta was supporting only random forest). The validation of the importance is done by comparing to the maximum of the median var. imp of the shadow predictors (in Boruta, a statistical test is performed using the Z-score). Since the whole process is done on the same train-test split, the variance of the variable importance comes only from the different re-fit of the model over the different iterations.

Modifications to Boruta and BoostARoota

I forked both Boruta and BoostARoota and made the following changes (under PR):

Boruta --> Leshy:

  • The categorical features (they are detected, encoded. The tree-based models are working better with integer encoding rather than with OHE, which leads to deep and unstable trees). If Catboost is used, then the cat.pred (if any) are set up
  • Using lightGBM as the default speeds up by an order of magnitude the running time
  • Work with Catboost, sklearn API
  • Allow using sample_weight, for applications like Poisson regression or any requiring weights
  • Supports 3 different feature importances: native, SHAP and permutation. Native being the least consistent(because of the imp. biased towards numerical and large cardinality categorical) but the fastest of the 3. Indeed, the impurity var.imp. are biased en sensitive to large cardinality (see scikit demo)

BoostARoota --> BoostAGroota:

  • Replace XGBoost with LightGBM, you can still use tree-based scikitlearn models
  • Replace native var.imp by SHAP var.imp. Indeed, the impurity var.imp. are biased en sensitive to large cardinality (see scikit demo). Moreover, the native var. imp are computed on the train set, here the data are split (internally) in train and test, var. imp computed on the test set.
  • Handling categorical predictors. Cat. predictors should NOT be one-hot encoded, it leads to deep unstable trees. Instead, it's better to use the native method of lightGBM or CatBoost. A preprocessing step is needed to encode (ligthGBM and CatBoost use integer encoding and reference to categorical columns. The splitting strategies are different then, see official doc).
  • Work with sample_weight, for Poisson or any application requiring a weighting.

GrootCV, a new method

New: GrootCV:

  • Cross-validated feature importance to smooth out the noise, based on lightGBM only (which is, most of the time, the fastest and more accurate Boosting).
  • the feature importance is derived using SHAP importance
  • Taking the max of the median of the shadow var. imp over folds otherwise not enough conservative and it improves the convergence (needs less evaluation to find a threshold)
  • Not based on a given percentage of cols needed to be deleted
  • Plot method for var. imp

References

Theory

Applications

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].