pythonk-meansyellowbrick

ModuleNotFoundError installing yellowbrick in Python


I am having trouble installing yellowbrick.

I am using Anaconda, hence I took advantage of using the "conda install".

# set number of clusters
kclusters = 5

pittsburgh_grouped_clustering = pittsburgh_grouped.drop('Neighborhood', 1)

X = pittsburgh_grouped.drop('Neighborhood', 1)

from sklearn.cluster import KMeans
!conda install -c districtdatalabs yellowbrick
from yellowbrick.cluster import KElbowVisualizer

# instantiate the model and visualizer
model = KMeans()
visualizer = KElbowVisualizer(model, k=(1,10))

visualizer.fit(X) # fit data to visualizer
visualizer.poof() # draw/show/poof the data

I expect the package to be installed. The error message I am receiving is:

ModuleNotFoundError: No module named 'yellowbrick'.

What am I missing?


Solution

  • First install yellowbrick outside of your code and verify that it actually installed. You can do this through the terminal doing exactly what you say. You may need to upgrade/downgrade your libraries which may not be happening when you install in your script.

    Then try and run your script without the !conda install -c districtdatalabs yellowbrick because once its installed you don't have to install it again.