Skip to content

Feature importance for mixed data and/or high cardinality data #16023

Closed

Description

@hugwi

In this article https://link.springer.com/article/10.1186/1471-2105-8-25 concerns about using gini for feature importance is being raised.

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.

Activity

  1. ogrisel commented on Jan 5, 2020

    @ogrisel
    Member

    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

  2. jnothman commented on Jan 7, 2020

    @jnothman
    Member

    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.

  3. added
    good first issue
    on Jan 7, 2020
  4. ogrisel commented on Jan 8, 2020

    @ogrisel
    Member

    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 the RandomForestClassifier/Regressor, ExtraTreesClassifier/Regressor, GradientBoostingClassifier/Regressor, and DecisionTreeClassifier/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.

  5. ogrisel commented on Jan 8, 2020

    @ogrisel
    Member

    @jnothman I had started writing my last comment yesterday before reading yours :) We agree.

  6. akilat90 commented on Jan 20, 2020

    @akilat90

    Hi @ogrisel, I would like to give this a try. Is this something I can work on?

  7. ogrisel commented on Jan 21, 2020

    @ogrisel
    Member

    @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.

  8. juliapiscioniere commented on Jan 28, 2020

    @juliapiscioniere

    Hey @akilat90 ! Are you planning on submitting a pull request for this issue?

  9. akilat90 commented on Jan 29, 2020

    @akilat90

    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.

  10. ogrisel commented on Feb 4, 2020

    @ogrisel
    Member

    Note that some of the above was addressed in #14528 which was merged recently.

  11. ogrisel commented on Feb 5, 2020

    @ogrisel
    Member

    More is being addressed in #16382.

  12. adrinjalali commented on Feb 26, 2020

    @adrinjalali
    Member

    @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) :)

  13. nilichen commented on Mar 11, 2020

    @nilichen
    Contributor

    take

  14. nilichen commented on Mar 19, 2020

    @nilichen
    Contributor

    @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?

  15. ogrisel commented on Mar 19, 2020

    @ogrisel
    Member

    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.

  16. tevfikaytekin commented on Jan 10, 2024

    @tevfikaytekin

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

DocumentationSprintgood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions