Skip to content

Commit

Permalink
Merge pull request #43 from Juice-jl/issue#42
Browse files Browse the repository at this point in the history
fix bug for k-means in em
  • Loading branch information
MhDang authored Dec 3, 2020
2 parents ec771f5 + 109f6e3 commit 6340103
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mixtures/em.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ function clustering(data, mix_num::Int64; maxiter=200)::Vector
return [data]
end
data = Matrix(data)
R = kmeans(data, mix_num; maxiter=maxiter)
R = kmeans(data', mix_num; maxiter=maxiter)
@assert nclusters(R) == mix_num
a = assignments(R)

clustered_data = Vector()
for k in 1 : mix_num
push!(clustered_data, DataFrame(data[:, findall(x -> x == k, a)]'))
push!(clustered_data, DataFrame(data[findall(x -> x == k, a), :]))
end

return clustered_data
Expand Down

0 comments on commit 6340103

Please sign in to comment.