Closed JonoSax closed 4 years ago
Thanks @JonoSax for pointing this out. Seems that the sklearn folks replaced this function in version 0.23 that was released last month. Will take a look into it. As a temporary fix you could downgrade your scikit-learn version to 0.22
Using Jupyter Notebook (Python 3.7)
# Evaluation Metrices
from sklearn.metrics import jaccard_similarity_score, f1_score, log_loss
ImportError Traceback (most recent call last)
Update
from sklearn.metrics import jaccard_similarity_score
needs to be replaced by from sklearn.metrics import jaccard_score
and new parameter pos_label
is required, for e.g. - jaccard_score(y_test, dt_yhat,pos_label = "PAIDOFF")
. Valid labels for pos_label
are: array(['COLLECTION', 'PAIDOFF'], dtype='<U10')
found this issue when searching for something similar in another project. i found that downgrading scikit-learn to 0.20.4 restored to the last version where that format was used.
pip uninstall scikit-learn
Found existing installation: scikit-learn 0.23.2
Uninstalling scikit-learn-0.23.2:
Would remove:
/opt/conda/lib/python3.7/site-packages/scikit_learn-0.23.2.dist-info/*
/opt/conda/lib/python3.7/site-packages/sklearn/*
Proceed (y/n)? y
Successfully uninstalled scikit-learn-0.23.2
daveccampbell@tensorflow-115-vm:~/projects$ pip install scikit-learn==0.20.4
Thank you @JonoSax , I struggled a bit with this - Cheers
Using Jupyter Notebook (Python 3.7)
# Evaluation Metrices from sklearn.metrics import jaccard_similarity_score, f1_score, log_loss
ImportError Traceback (most recent call last) in 1 # Evaluation Metrices ----> 2 from sklearn.metrics import jaccard_similarity_score, f1_score, log_loss
ImportError: cannot import name 'jaccard_similarity_score' from 'sklearn.metrics' (/opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/sklearn/metrics/init.py)
Tried
!pip install scikit-learn==0.22
&!conda install scikit-learn=0.22
but I still get the same error. @OllyK
Did u find a solution?
Using Jupyter Notebook (Python 3.7)
# Evaluation Metrices from sklearn.metrics import jaccard_similarity_score, f1_score, log_loss
ImportError Traceback (most recent call last) in 1 # Evaluation Metrices ----> 2 from sklearn.metrics import jaccard_similarity_score, f1_score, log_loss ImportError: cannot import name 'jaccard_similarity_score' from 'sklearn.metrics' (/opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/sklearn/metrics/init.py) Tried
!pip install scikit-learn==0.22
&!conda install scikit-learn=0.22
but I still get the same error. @OllyKDid u find a solution?
Importing jaccard_score
rather than jaccard_similarity_score
seems to work for me
Using Jupyter Notebook (Python 3.7)
# Evaluation Metrices from sklearn.metrics import jaccard_similarity_score, f1_score, log_loss
ImportError Traceback (most recent call last) in 1 # Evaluation Metrices ----> 2 from sklearn.metrics import jaccard_similarity_score, f1_score, log_loss ImportError: cannot import name 'jaccard_similarity_score' from 'sklearn.metrics' (/opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/sklearn/metrics/init.py) Tried
!pip install scikit-learn==0.22
&!conda install scikit-learn=0.22
but I still get the same error. @OllyKDid u find a solution?
Hi there! Yes, do not import jaccad_similarity_score, instead import jaccard_score And it will work. I have a machine learning video where I import only jaccard_score, and it's working perfectly, check it out : https://www.youtube.com/watch?v=zIsk5fN0aSs&t=1064s [minute 3:15]
Using Jupyter Notebook (Python 3.7)
# Evaluation Metrices from sklearn.metrics import jaccard_similarity_score, f1_score, log_loss
ImportError Traceback (most recent call last) in 1 # Evaluation Metrices ----> 2 from sklearn.metrics import jaccard_similarity_score, f1_score, log_loss ImportError: cannot import name 'jaccard_similarity_score' from 'sklearn.metrics' (/opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/sklearn/metrics/init.py) Tried
!pip install scikit-learn==0.22
&!conda install scikit-learn=0.22
but I still get the same error. @OllyKDid u find a solution?
Hi,
I found the solution - https://github.com/DiamondLightSource/SuRVoS/issues/103#issuecomment-731122304
jaccard_score solves the problem of syntax error but, it produces a different value than that of jaccard_similarity_score. Can anyone suggest what are the parameters that are needed to be tuned in jaccard_score() to get those values which are obtained by using jaccard_similarity_score.
This link might help(downgrade to 0.22 version): https://www.gitmemory.com/issue/DiamondLightSource/SuRVoS/103/638711139 . For me this is working
Update
from sklearn.metrics import jaccard_similarity_score
needs to be replaced byfrom sklearn.metrics import jaccard_score
and new parameterpos_label
is required, for e.g. -jaccard_score(y_test, dt_yhat,pos_label = "PAIDOFF")
. Valid labels forpos_label
are:array(['COLLECTION', 'PAIDOFF'], dtype='<U10')
Hi, could you explain me, I am confused here. I got different jaccard_score when using pos_label = 'PAIDOFF' and using pos_label = 'COLLECTION' Thanks
from sklearn.metrics import jaccard_score
can you explain more about pos_label replacement ? thank you
puedes resolverlo usando from sklearn.metrics import jaccard_score print(jaccard_score(y_test, yhat, average='macro'))
Te invito a que busques en la documentacion oficial https://scikit-learn.org/stable/modules/generated/sklearn.metrics.jaccard_score.html Saludos!
I had to replace jaccard_similarity_score with jaccard_score and add pos_label="PAIDOFF"
jaccard_score(test_y, LR_yhat, pos_label="PAIDOFF")
As you can see here, the last version of scikit-learn replaced jaccard_similarity_score with jaccard_score
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.jaccard_score.html
Using Windows, python 3.6.10
File ".\Anaconda3\envs\survos-env\lib\site-packages\survos\actions\seganalysis.py", line 8, in
from sklearn.metrics import cohen_kappa_score, jaccard_similarity_score
ImportError: cannot import name 'jaccard_similarity_score'
--> I went into seganalysis.py and changed the module being imported to jaccard_score (from sklearn.metrics import cohen_kappa_score, jaccard_score). I haven't used the software extensively so don't know if this is a substantial change, however it now opens and it would appear that it is a change in import name.....