I need to use balanced_accuracy_score function. When I type from sklearn.metrics import balanced_accuracy_score
I get the Import Error. A version of scikit-learn
on my computer is 0.21.0. I haven't trouble with importing the other functions from sklearn
. I tried to reinstall numpy
(now 1.16.3) and pip
(now 19.1.1). What else could you advise me to check?
Asked
Active
Viewed 684 times
0

Alyona
- 9
- 2
-
1Can you please include the error message you get in your question? That would help a lot to analyze the problem. – sekky May 12 '19 at 09:10
-
https://stackoverflow.com/questions/52919980/cannot-import-name-balanced-accuracy-score – Amitoj Singh Ahuja May 12 '19 at 09:15
-
Does `import sklearn` work? How about `import sklearn.metrics`? – John Zwinck May 12 '19 at 09:29
-
In Jupyter ImportError is `cannot import name 'balanced_accuracy_score' from 'sklearn.metrics' (C:\ProgramData\Anaconda3\lib\site-packages\sklearn\metrics\__init__.py)`, in command line long message, briethly it is: `DLL load failed`. I tried run `import sklearn.metrics` and in Jupyter it's OK, but in command line I get the same Import Error. – Alyona May 12 '19 at 09:40
-
`import sklearn` and `import numpy` behave like `import sklearn.metrics`: in Jupyter work, in the command line don't (`DLL load failed`). – Alyona May 12 '19 at 10:01
-
It's strange, that the library works differently in Jupyter and in the command line. Even version has different values. `pip list` gives 0.21.0 and Jupyter command `sklearn.__version__` shows 0.19.2. Has anyone come across this? – Alyona May 12 '19 at 10:25
-
1It is not of course that the library behaves differently, it is that your Jupyter notebook probably runs in a different environment, where you have an older version of scikit-learn (0.19.2), which [does not include](https://scikit-learn.org/0.19/modules/classes.html#sklearn-metrics-metrics) `balanced_accuracy_score`. – desertnaut May 12 '19 at 15:32
-
Does this answer your question? [ValueError: 'balanced\_accuracy' is not a valid scoring value in scikit-learn](https://stackoverflow.com/questions/53349331/valueerror-balanced-accuracy-is-not-a-valid-scoring-value-in-scikit-learn) – Trenton McKinney May 03 '21 at 16:41