plot not showing up
Sharan Basappa
sharan.basappa at gmail.com
Fri Aug 10 13:46:06 EDT 2018
What is wrong with the following code. Python does not show the plot.
from sklearn.datasets import load_digits
from sklearn.cluster import KMeans
import matplotlib.pyplot as plt
digits = load_digits()
digits.data.shape
kmeans = KMeans(n_clusters=10,random_state=0)
clusters = kmeans.fit_predict(digits.data)
kmeans.cluster_centers_.shape
fig, ax = plt.subplots(2,5,figsize=(8,3))
centers = kmeans.cluster_centers_.reshape(10,8,8)
for axi, center in zip(ax.flat, centers):
axi.set(xticks=[], yticks=[])
axi.imshow(center, interpolation='nearest', cmap=plt.cm.binary)
More information about the Python-list
mailing list