Hey there,
my name is Daniel. I am right now working on the above mentioned project. But I end up with my cluster centers having indexes that differ from those in the solution:
Is anyone else experience this?
I am totally new to this field so I might be missing something, but anyone has an explanation?
Thanks in andvance!
In the end I used the exact same code as seen in the hints:
import codecademylib3_seaborn
import numpy as np
from matplotlib import pyplot as plt
from sklearn import datasets
from sklearn.cluster import KMeans
digits = datasets.load_digits()
#leaving out the initial visualisation part
##7
model = KMeans(n_clusters=10, random_state=42)
model.fit(digits.data)
##9
fig = plt.figure(figsize=(8, 3))
fig.suptitle(‘Cluser Center Images’, fontsize=14, fontweight=‘bold’)
##10
for i in range(10):
#Initialize subplots in a grid of 2X5, at i+1th position
ax = fig.add_subplot(2, 5, 1 + i)
#Display images
ax.imshow(model.cluster_centers_[i].reshape((8, 8)), cmap=plt.cm.binary)
plt.show()