dens /= npoints
// Choose initial centroids based on distance and density.
centroids[0] = X[np.argmax(dens)]
if n_clusters > 1:
// For the remaining centroids, choose maximum dens * dissim to the
// (already assigned) centroid with the lowest dens * dissim.
for ik in range(1, n_clusters):
dd = np.empty((ik, npoints))
for ikk in range(ik):
dd[ikk] = dissim(X, centroids[ikk]) * dens
centroids[ik] = X[np.argmax(np.min(dd, axis=0))]
return centroids
After Change
dens /= npoints
// Choose initial centroids based on distance and density.
centroids[0] = X[np.argmax(dens)]
if n_clusters > 1:
// For the remaining centroids, choose maximum dens * dissim to the
// (already assigned) centroid with the lowest dens * dissim.
for ik in range(1, n_clusters):
dd = np.empty((ik, npoints))
for ikk in range(ik):
dd[ikk] = dissim(X, centroids[ikk]) * dens
centroids[ik] = X[np.argmax(np.min(dd, axis=0))]
return centroids