Skip to content

Commit 30a58d2

Browse files
authored
Update updated_kmeans.jl
Declared types for the function
1 parent a4c4f38 commit 30a58d2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Tutorials/kmeans_implementation_project/updated_kmeans.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ using Distances
1212

1313
"""
1414
"""
15-
function Kmeans(X::Array, k::Int64; max_iters::Int64=300, tol=1e-5)
15+
function Kmeans(design_matrix::Array{Float64, 2}, k::Int64; max_iters::Int64=300, tol=1e-5)
1616
# randomly get centroids for each group
1717
n_row, n_col = size(design_matrix)
1818
rand_indices = rand(1:n_row, k)
1919
centroids = design_matrix[rand_indices, :]
2020

2121
# Update centroids & labels with closest members until convergence
2222
for iter = 1:max_iters
23-
23+
Nothing
2424
end
2525

26+
return centroids
27+
2628
end
29+
30+
Kmeans(X, 3)

0 commit comments

Comments
 (0)