Skip to content

Incompatibility with scikit-learn 1.2+: Deprecation of if_delegate_has_method in eli5 library #426

@e5science

Description

@e5science

I've encountered an import error when trying to use the eli5 library with the latest version of scikit-learn (1.2+). The error message is as follows:
ImportError: cannot import name 'if_delegate_has_method' from 'sklearn.utils.metaestimators' (path_to_sklearn\utils\metaestimators.py)

The if_delegate_has_method decorator has been deprecated and removed from scikit-learn in version 1.2, and it has been replaced by the available_if decorator. This issue arises when attempting to use eli5 for permutation importance with a trained model.

Steps to Reproduce:

Install the latest versions of scikit-learn and eli5.
Attempt to import eli5 and use PermutationImportance.
Observe the ImportError.

Proposed Solution:

Update the import statements in the eli5 library to use the new available_if decorator from scikit-learn's metaestimators module.

Environment:

Python version: 3.x
scikit-learn version: 1.2+
eli5 version: latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions