You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature importance for mixed data and/or high cardinality data #16023
We found that for the original random forest method the variable importance measures are affected by the number of categories and scale of measurement of the predictor variables, which are no direct indicators of the true importance of the variable.
However, in studies where continuous variables, such as the folding energy, are used in combination with categorical information from the neighboring nucleotides, or when categorical predictors, as in amino acid sequence data, vary in their number of categories present in the sample variable selection with random forest variable importance measures is unreliable and may even be misleading.
I'm not entirely sure but as I understand the documentation and reading through the documentation and code feature importance is calculated by using either gini or entropy (both suffering from the same issue I suppose). Is their any way circumvent this problem or actions that is supposed to be taken before feature imortance.
In the article they propose a new splitting criteria to combat this problem.
Another alternative is to use permutation importances, that also works with column transformers / pipeline. This example show the different and highlight the issue with cardinality in traditional tree-based feature importances and how permutation importances do not suffer from that bias:
Some of these caveats should be listed in the docs, which should probably cross-reference permutation_importances as often as possible. If this isn't already adequately addressed in documentation around feature importances, then a PR is welcome.
As we have a model agnostic solution to assert feature importances without suffering from cardinality bias, I would be in favor of not extending our Random Forest implementation just to tackle bias issues in their feature importances, unless the method described in this paper is significantly better than permutation based feature importances but this would need to be demonstrated on some example.
However I think we should better document the cardinality bias of the gini/entropy based feature importances and reference the permutation importances as an alternative that does not suffer this problem.
Here are examples of locations in our documentation where we would need to insert or link to such a warning:
@akilat90 no need to ask. If you see that nobody else is actively working on an issue, feel free to submit a PR of your own. Please start by a small PR that edits only a few files if this is the first time you contribute to this project.
Hi @juliapiscioniere I have done some ground work for this but I had to slow down and will not be ready until two weeks. Please go ahead if you wish to (and please let me know), thanks.
@laurenmoos seems like different parts are being/have been addressed in a few PRs as you can see in the discussion. You're more than welcome to go through them, figure what they're covering, and start on a part which is not covered by any of them (if any) :)
@ogrisel I went through the different conversations and it seems like both this and #14528 can be resolved by updating the relevant examples to favour permutation_importance?
I think most of this issue has already been addressed in merged PRs. There a re a few remaining examples that would benefit from being updated to also include permutation_importance (in complement to impurity-based feature importances).
Let's close this and focus the discussion on the remaining examples in #16023 to avoid parallel conversations.
Could there be a normalization method to fix this high cardinality problem such as dividing the importance value of a feature by the total number of nodes the feature appears.
Activity
ogrisel commentedon Jan 5, 2020
Another alternative is to use permutation importances, that also works with column transformers / pipeline. This example show the different and highlight the issue with cardinality in traditional tree-based feature importances and how permutation importances do not suffer from that bias:
https://scikit-learn.org/stable/auto_examples/inspection/plot_permutation_importance.html#sphx-glr-auto-examples-inspection-plot-permutation-importance-py
jnothman commentedon Jan 7, 2020
Some of these caveats should be listed in the docs, which should probably cross-reference
permutation_importancesas often as possible. If this isn't already adequately addressed in documentation around feature importances, then a PR is welcome.ogrisel commentedon Jan 8, 2020
As we have a model agnostic solution to assert feature importances without suffering from cardinality bias, I would be in favor of not extending our Random Forest implementation just to tackle bias issues in their feature importances, unless the method described in this paper is significantly better than permutation based feature importances but this would need to be demonstrated on some example.
However I think we should better document the cardinality bias of the gini/entropy based feature importances and reference the permutation importances as an alternative that does not suffer this problem.
Here are examples of locations in our documentation where we would need to insert or link to such a warning:
https://scikit-learn.org/stable/modules/ensemble.html#feature-importance-evaluation
https://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances_faces.html
https://scikit-learn.org/stable/auto_examples/ensemble/plot_forest_importances.html
and also in the docstring for the
feature_importances_attribute of theRandomForestClassifier/Regressor,ExtraTreesClassifier/Regressor,GradientBoostingClassifier/Regressor, andDecisionTreeClassifier/Regressor, such as:https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier.feature_importances_ for instance.
To get a stable URL we would need to insert a reStructuredText reference anchor in the docstring of https://scikit-learn.org/stable/auto_examples/inspection/plot_permutation_importance.html to be able to use to build the links.
ogrisel commentedon Jan 8, 2020
@jnothman I had started writing my last comment yesterday before reading yours :) We agree.
akilat90 commentedon Jan 20, 2020
Hi @ogrisel, I would like to give this a try. Is this something I can work on?
ogrisel commentedon Jan 21, 2020
@akilat90 no need to ask. If you see that nobody else is actively working on an issue, feel free to submit a PR of your own. Please start by a small PR that edits only a few files if this is the first time you contribute to this project.
juliapiscioniere commentedon Jan 28, 2020
Hey @akilat90 ! Are you planning on submitting a pull request for this issue?
akilat90 commentedon Jan 29, 2020
Hi @juliapiscioniere I have done some ground work for this but I had to slow down and will not be ready until two weeks. Please go ahead if you wish to (and please let me know), thanks.
ogrisel commentedon Feb 4, 2020
Note that some of the above was addressed in #14528 which was merged recently.
ogrisel commentedon Feb 5, 2020
More is being addressed in #16382.
adrinjalali commentedon Feb 26, 2020
@laurenmoos seems like different parts are being/have been addressed in a few PRs as you can see in the discussion. You're more than welcome to go through them, figure what they're covering, and start on a part which is not covered by any of them (if any) :)
nilichen commentedon Mar 11, 2020
take
nilichen commentedon Mar 19, 2020
@ogrisel I went through the different conversations and it seems like both this and #14528 can be resolved by updating the relevant examples to favour permutation_importance?
ogrisel commentedon Mar 19, 2020
I think most of this issue has already been addressed in merged PRs. There a re a few remaining examples that would benefit from being updated to also include permutation_importance (in complement to impurity-based feature importances).
Let's close this and focus the discussion on the remaining examples in #16023 to avoid parallel conversations.
tevfikaytekin commentedon Jan 10, 2024
Could there be a normalization method to fix this high cardinality problem such as dividing the importance value of a feature by the total number of nodes the feature appears.