Created
December 23, 2019 16:15
-
-
Save briverse17/ab081a0491ce4a7aaa2c884f830d4416 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(self.max_iter): | |
#Labels for this iteration | |
cur_labels = [] | |
for medoid in range(0,self.k): | |
#Dissimilarity cost of the current cluster | |
self.medoids_cost[medoid] = 0 | |
for k in range(len(X)): | |
#Distances from a data point to each of the medoids | |
d_list = [] | |
for j in range(0,self.k): | |
d_list.append(euclideanDistance(self.medoids[j], X[k])) | |
#Data points' label is the medoid which has minimal distance to it | |
cur_labels.append(d_list.index(min(d_list))) | |
self.medoids_cost[medoid] += min(d_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment