This example is from Data Science for dummies:
digits = load_digits()
X = digits.data
ground_truth = digits.target
pca = PCA(n_components=40)
Cx = pca.fit_transform(scale(X))
DB = DBSCAN(eps=4.35, min_samples=25, random_state=1)
DB.fit(Cx)
for k,cl in enumerate(np.unique(DB.labels_)):
if cl >= 0:
example = np.min(np.where(DB.labels_==cl)) # question 1
plt.subplot(2, 3, k)
plt.imshow(digits.images[example],cmap='binary', # question 2
interpolation='none')
plt.title('cl '+str(cl))
plt.show()
My questions are:
- np.where(DB.labels_==cl) I don't understand on which array we apply np.where when I print np.where(DB.labels_==cl) it is looks like it applied to DB.core_sample_indices_. But I don't understand why. As I could understand from documentation for np.where, np.where(DB.labels_==cl) should be applied on DB.labels_.
- How come np.min(np.where(DB.labels_==cl)) gives me indice which in digits.images plots me correct image. Thank you.