Yellowbrick Module NotFoundError in Python

偶尔善良 提交于 2021-02-11 15:08:42

问题


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'


回答1:


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

pip install -U yellowbrick



回答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!



来源:https://stackoverflow.com/questions/64963619/yellowbrick-module-notfounderror-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!