Skip to content

Commit 7c97dfb

Browse files
authored
Update kmeans.jl
minor updates
1 parent bcaf0d7 commit 7c97dfb

File tree

1 file changed

+5
-3
lines changed
  • Tutorials/kmeans_implementation_project

1 file changed

+5
-3
lines changed

Tutorials/kmeans_implementation_project/kmeans.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ scatter3d!(cluster_centres[:, 1], cluster_centres[:, 2], cluster_centres[:, 3],
9898
markershape=:star4, markersize=15, color="red",legend=false)
9999

100100

101-
function sum_of_squares(x, centroid, labels, k)
101+
function sum_of_squares(x, labels, k)
102102
N = length(x)
103103
ss = 0
104104

@@ -108,8 +108,10 @@ function sum_of_squares(x, centroid, labels, k)
108108
group_length = length(group_data)
109109
group_center = mean(group_data)
110110

111+
println(group_center)
112+
111113
for ex = 1:group_length
112-
group_distance = group_data[ex] .- centroid[j]
114+
group_distance = group_data[ex] .- group_center
113115
squared_distance = group_distance .^ 2
114116
total_squared_distance = sum(squared_distance)
115117

@@ -122,4 +124,4 @@ end
122124

123125
X_list = collect(eachrow(X))
124126

125-
@time sum_of_squares(X_list, cluster_centres, predicted_labels, 3)
127+
@time sum_of_squares(X_list, predicted_labels, 3)

0 commit comments

Comments
 (0)