Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

knn plot the clusters

clusters = range(1, 10)
inertias = []

for k in clusters:
    # Create a KMeans model
    model = KMean(n_clusters)
    
    # Fit model to data
    model.fit(data)
    
    # Append the inertia to the list of inertias
    inertias.append(model.inertia_)
    
# Plot clusters vs inertias
plt.plot(clusters, inertias, '-o')
plt.xlabel('number of clusters, k')
plt.ylabel('inertia')
plt.xticks(clusters)
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: array must not contain infs or NaNs 
Python :: image bad when scaled in pygame 
Python :: how to access a private attribute in child class python 
Python :: resource wordnet not found python 
Python :: how to print something in python 
Python :: pil save image 
Python :: pandas join two columns 
Python :: redis get all keys and values python 
Python :: flask docker 
Python :: python diamond pattern 
Python :: save np array as mat file 
Python :: ubuntu download file command line 
Python :: torch concat matrix 
Python :: binning data dataframe, faire classe statistique dataframe 
Python :: python how to check which int var is the greatest 
Python :: numpy series reset index 
Python :: get all indices of a value in list python 
Python :: python accept user input 
Python :: create df from two arrays 
Python :: python tipi array 
Python :: virtual env in python 
Python :: shuffle rows dataframe 
Python :: python json parse 
Python :: python saveAsTextFile 
Python :: pandas dataframe rename column 
Python :: open administrator command prompt using python 
Python :: start django project 
Python :: polynomial features random forest classifier 
Python :: selenium text returns empty string python 
Python :: clear pygame screen 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =