Yellowbrick Module NotFoundError in Python
Asked Answered
D

3

1

I am trying to using Yellowbrick to make an elbow plot.(to make the k-means clustering)

I have installed Yellowbrick in jupyter notebook. but, it keeps returning the error message like below.

The error message and information are attached as pictures below. I would be very happy if you could help me.

from yellowbrick.cluster import KElbowVisualizer

model = KMeans()

visualizer = KElbowVisualizer(model, k=(1,250))

visualizer.fit(x.reshape(-1,1))
 

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-84-390153c57930> in <module>
----> 1 from yellowbrick.cluster import KElbowVisualizer
      2 model = KMeans()
      3 visualizer = KElbowVisualizer(model, k=(1,250))
      4 visualizer.fit(x.reshape(-1,1))
      5 

~/.local/lib/python3.7/site-packages/yellowbrick/__init__.py in <module>
     37 from .anscombe import anscombe
     38 from .datasaurus import datasaurus
---> 39 from .classifier import ROCAUC, ClassBalance, ClassificationScoreVisualizer
     40 
     41 # from .classifier import crplot, rocplot

~/.local/lib/python3.7/site-packages/yellowbrick/classifier/__init__.py in <module>
     24 from ..base import ScoreVisualizer
     25 from .base import ClassificationScoreVisualizer
---> 26 from .class_prediction_error import ClassPredictionError, class_prediction_error
     27 from .classification_report import ClassificationReport, classification_report
     28 from .confusion_matrix import ConfusionMatrix, confusion_matrix

~/.local/lib/python3.7/site-packages/yellowbrick/classifier/class_prediction_error.py in <module>
     22 
     23 from sklearn.utils.multiclass import unique_labels
---> 24 from sklearn.metrics._classification import _check_targets
     25 
     26 from yellowbrick.draw import bar_stack

ModuleNotFoundError: No module named 'sklearn.metrics._classification'

Deliadelian answered 23/11, 2020 at 6:42 Comment(0)
E
2

Hello and thanks for checking out Yellowbrick!

The sklearn.metrics.classification module was deprecated in sklearn v0.22, so we have updated our package to import from sklearn.metrics._classification instead.

Try updating your version of scikit-learn (e.g. pip install -U scikit-learn or conda update scikit-learn) and see if that helps!

Erelong answered 24/11, 2020 at 0:26 Comment(1)
Thanks a lot~~~~! Following your answer, I can solve the problem!Veterinary
P
1

Looks like your yellowbrick has not been installed properly. Try installing only for user:

pip install -U yellowbrick
Preliminary answered 23/11, 2020 at 6:59 Comment(0)
L
0

Try this:

conda install -c districtdatalabs yellowbrick 

Source: https://anaconda.org/DistrictDataLabs/yellowbrick

Lawrence answered 26/9, 2021 at 13:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.