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

AttributeError: module 'sklearn.metrics' has no attribute 'jaccard_similarity_score' #131

Open
petraknovak opened this issue Jul 6, 2020 · 12 comments

Comments

@petraknovak
Copy link

I am using scikit-learn version 0.23.1 and I get the following error:
AttributeError: module 'sklearn.metrics' has no attribute 'jaccard_similarity_score'
when calling the function ConfusionMatrix.

@guitarzero
Copy link

Same here. Thanks

@blaze515
Copy link

blaze515 commented Jul 18, 2020

I'm also getting this error...

It looks like jaccard_similarity_score was deprecated since sckiti-learn 0.21 in favor of newer implementation, jaccard_score, and was removed in 0.23:

https://scikit-learn.org/0.22/modules/generated/sklearn.metrics.jaccard_similarity_score.html?highlight=jaccard#sklearn.metrics.jaccard_similarity_score

scikit-learn/scikit-learn#13151

@aparente-nurix
Copy link

Same here, there's also a stack overflow for a different error that suggests this is an sklearn version issue.

https://stackoverflow.com/questions/61819628/is-pandas-ml-broken

@benlevitas
Copy link

Looks like they changed the sklearn function to 'jaccard_score'
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.jaccard_score.html

@hawk-praxs
Copy link

Agree with @benlevitas if you want the library to function correctly, make the following change:
In ~/anaconda3/Lib/site-packages/pandas_ml/skaccessors/metrics.py
Line 249: change jaccard_similarity_score to jaccard_score

The _classification_methods list has the list of accuracy metrics. Changing it leads to the proper functioning of the library. I hope they update this in the file as well.

@ipesanz
Copy link

ipesanz commented Jul 20, 2021

In addition to what @hawk-praxs mentioned, then another dependency change will appear related to Imputer, and then another.. an so [. . .]

AttributeError: module 'sklearn.preprocessing' has no attribute 'Imputer'

@hawk-praxs
Copy link

In addition to what @hawk-praxs mentioned, then another dependency change will appear related to Imputer, and then another.. an so [. . .]

AttributeError: module 'sklearn.preprocessing' has no attribute 'Imputer'

Fixing the Imputer class in the library makes it work.

No further errors after this.

@ipesanz
Copy link

ipesanz commented Jul 20, 2021

I changed on file:
[..]/lib/python3.8/site-packages/pandas_ml/skaccessors/preprocessing.py the only coincidence to Imputer.

pp.imputer >> pp.SimpleImputer [Bear in Mind that SimpleImputer is no longer in preprocessing, is in "Imputer" class]

New in version 0.20: SimpleImputer replaces the previous sklearn.preprocessing.Imputer estimator which is now removed.

image

From the SkLearn docs

Error after:
image

@averner
Copy link

averner commented Aug 9, 2022

SimpleImputer is now in sklearn.impute (https://scikit-learn.org/stable/modules/generated/sklearn.impute.SimpleImputer.html). My solution was to change preprocessing.py as followins:
...
if _SKLEARN_INSTALLED:
import sklearn.preprocessing as pp
from sklearn.impute import SimpleImputer
_keep_col_classes = [pp.Binarizer,
pp.FunctionTransformer,
SimpleImputer,
...

I still get "AttributeError: type object 'NDFrame' has no attribute 'groupby'" after these changes though.

@robertson809
Copy link

How has this not been fixed in the pandas ml library yet?

@averner
Copy link

averner commented Dec 21, 2022 via email

@olchemist
Copy link

I got a new one concerning seaborn.factorplot, so I changed ~/opt/anaconda3/lib/python3.9/site-packages/pandas_ml/snsaccessors/base.py

replace "factorplot" with "catplot" in line 223

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

10 participants