Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_check_weights() no longer exists in SciKit-learn #41

Open
franzhuettinger opened this issue Apr 19, 2024 · 0 comments
Open

_check_weights() no longer exists in SciKit-learn #41

franzhuettinger opened this issue Apr 19, 2024 · 0 comments

Comments

@franzhuettinger
Copy link

_check_weights() was removed from sklearn after version 1.2.X. Therefore, missingpy is no longer compatible with the latest version of SciKit-learn.

As a quick fix I copied the original code from the sklearn/neighbors/_base.py file (version 0.22.X) to my local copy of missingpy/knnimpute.py:

def _check_weights(weights):
    """Check to make sure weights are valid"""
    if weights in (None, 'uniform', 'distance'):
        return weights
    elif callable(weights):
        return weights
    else:
        raise ValueError("weights not recognized: should be 'uniform', "
                         "'distance', or a callable function")

... and removed the import:

# from sklearn.neighbors.base import _check_weight
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant