Skip to content

Commit

Permalink
update text
Browse files Browse the repository at this point in the history
  • Loading branch information
yoninazarathy committed Jul 3, 2020
1 parent 038bc69 commit eb84a8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions 9_chapter/kMeans.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Clustering, RDatasets, Random, Measures, Plots; pyplot()
Random.seed!(0)

K = 3
df = dataset("cluster", "xclara")
data = copy(convert(Array{Float64}, df)')

seeds = initseeds(:rand, data, 3)
xclaraKmeans = kmeans(data, 3, init = seeds)
seeds = initseeds(:rand, data, K)
xclaraKmeans = kmeans(data, K, init = seeds)

println("Number of clusters: ", nclusters(xclaraKmeans))
println("Counts of clusters: ", counts(xclaraKmeans))
Expand Down
9 changes: 4 additions & 5 deletions 9_chapter/kMeansManual.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using RDatasets, Distributions, Random
Random.seed!(0)

k = 3

xclara = dataset("cluster", "xclara")
n,_ = size(xclara)
dataPoints = [convert(Array{Float64,1},xclara[i,:]) for i in 1:n]
K = 3
df = dataset("cluster", "xclara")
n,_ = size(df)
dataPoints = [convert(Array{Float64,1},df[i,:]) for i in 1:n]
shuffle!(dataPoints)

xMin,xMax = minimum(first.(dataPoints)),maximum(first.(dataPoints))
Expand Down

0 comments on commit eb84a8f

Please sign in to comment.