Skip to content

Commit f871201

Browse files
author
Andrey Oskin
committed
typo fixed
1 parent 3506968 commit f871201

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

docs/src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ r.converged # whether the procedure converged
106106
- [Lloyd()](https://cs.nyu.edu/~roweis/csc2515-2006/readings/lloyd57.pdf)
107107
- [Hamerly()](https://www.researchgate.net/publication/220906984_Making_k-means_Even_Faster)
108108
- [Elkan()](https://www.aaai.org/Papers/ICML/2003/ICML03-022.pdf)
109-
- [YingYang()](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/ding15.pdf)
109+
- [Yinyang()](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/ding15.pdf)
110110
- [Geometric()](http://cs.baylor.edu/~hamerly/papers/sdm2016_rysavy_hamerly.pdf) - (Coming soon)
111111
- [MiniBatch()](https://www.eecs.tufts.edu/~dsculley/papers/fastkmeans.pdf) - (Coming soon)
112112

@@ -181,7 +181,7 @@ ________________________________________________________________________________
181181
- 0.1.2 Added `Elkan` algorithm.
182182
- 0.1.3 Faster & optimized execution.
183183
- 0.1.4 Bug fixes
184-
- 0.1.5 Added `YingYang` algorithm.
184+
- 0.1.5 Added `Yinyang` algorithm.
185185

186186
## Contributing
187187

src/ParallelKMeans.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ include("kmeans.jl")
1212
include("lloyd.jl")
1313
include("hamerly.jl")
1414
include("elkan.jl")
15-
include("yingyang.jl")
15+
include("yinyang.jl")
1616
include("mlj_interface.jl")
1717

1818
export kmeans
19-
export Lloyd, Hamerly, Elkan, YingYang
19+
export Lloyd, Hamerly, Elkan, Yinyang
2020

2121
end # module

src/yingyang.jl renamed to src/yinyang.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
YingYang()
2+
Yinyang()
33
4-
YingYang algorithm implementation, based on "Yufei Ding et al. 2015. Yinyang K-Means: A Drop-In
4+
Yinyang algorithm implementation, based on "Yufei Ding et al. 2015. Yinyang K-Means: A Drop-In
55
Replacement of the Classic K-Means with Consistent Speedup. Proceedings of the 32nd International
66
Conference on Machine Learning, ICML 2015, Lille, France, 6-11 July 2015"
77
@@ -13,24 +13,24 @@ It can be used directly in `kmeans` function
1313
```julia
1414
X = rand(30, 100_000) # 100_000 random points in 30 dimensions
1515
16-
kmeans(YingYang(), X, 3) # 3 clusters, YingYang algorithm
16+
kmeans(Yinyang(), X, 3) # 3 clusters, Yinyang algorithm
1717
```
1818
19-
`YingYang` supports following arguments:
19+
`Yinyang` supports following arguments:
2020
`auto`: `Bool`, indicates whether to perform automated or manual grouping
2121
`group_size`: `Int`, estimation of average number of clusters per group. Lower numbers
2222
corresponds to higher calculation speed and higher memory consumption and vice versa.
2323
"""
24-
struct YingYang <: AbstractKMeansAlg
24+
struct Yinyang <: AbstractKMeansAlg
2525
auto::Bool
2626
group_size::Int
2727
end
2828

29-
YingYang() = YingYang(true, 7)
30-
YingYang(auto::Bool) = YingYang(auto, 7)
31-
YingYang(group_size::Int) = YingYang(true, group_size)
29+
Yinyang() = Yinyang(true, 7)
30+
Yinyang(auto::Bool) = Yinyang(auto, 7)
31+
Yinyang(group_size::Int) = Yinyang(true, group_size)
3232

33-
function kmeans!(alg::YingYang, containers, X, k;
33+
function kmeans!(alg::Yinyang, containers, X, k;
3434
n_threads = Threads.nthreads(),
3535
k_init = "k-means++", max_iters = 300,
3636
tol = 1e-6, verbose = false, init = nothing)
@@ -67,7 +67,7 @@ function kmeans!(alg::YingYang, containers, X, k;
6767
J_previous = J
6868

6969
# push!(containers.debug, [0, 0, 0])
70-
# Core calculation of the YingYang, 3.2-3.3 steps of the original paper
70+
# Core calculation of the Yinyang, 3.2-3.3 steps of the original paper
7171
@parallelize n_threads ncol chunk_update_centroids(alg, containers, centroids, X)
7272
collect_containers(alg, containers, n_threads)
7373

@@ -90,7 +90,7 @@ function kmeans!(alg::YingYang, containers, X, k;
9090
return KmeansResult(centroids, containers.labels, Float64[], Int[], Float64[], totalcost, niters, converged)
9191
end
9292

93-
function create_containers(alg::YingYang, k, nrow, ncol, n_threads)
93+
function create_containers(alg::Yinyang, k, nrow, ncol, n_threads)
9494
lng = n_threads + 1
9595
centroids_new = Vector{Array{Float64,2}}(undef, lng)
9696
centroids_cnt = Vector{Vector{Int}}(undef, lng)
@@ -151,7 +151,7 @@ function create_containers(alg::YingYang, k, nrow, ncol, n_threads)
151151
)
152152
end
153153

154-
function initialize(alg::YingYang, containers, centroids, n_threads)
154+
function initialize(alg::Yinyang, containers, centroids, n_threads)
155155
groups = containers.groups
156156
indices = containers.indices
157157
if length(groups) == 1
@@ -165,7 +165,7 @@ function initialize(alg::YingYang, containers, centroids, n_threads)
165165
end
166166
end
167167

168-
function chunk_initialize(alg::YingYang, containers, centroids, X, r, idx)
168+
function chunk_initialize(alg::Yinyang, containers, centroids, X, r, idx)
169169
centroids_cnt = containers.centroids_cnt[idx]
170170
centroids_new = containers.centroids_new[idx]
171171

@@ -178,7 +178,7 @@ function chunk_initialize(alg::YingYang, containers, centroids, X, r, idx)
178178
end
179179
end
180180

181-
function calculate_centroids_movement(alg::YingYang, containers, centroids)
181+
function calculate_centroids_movement(alg::Yinyang, containers, centroids)
182182
p = containers.p
183183
groups = containers.groups
184184
gd = containers.gd
@@ -341,7 +341,7 @@ end
341341
342342
Calculates new labels and upper and lower bounds for all points.
343343
"""
344-
function point_all_centers!(alg::YingYang, containers, centroids, X, i)
344+
function point_all_centers!(alg::Yinyang, containers, centroids, X, i)
345345
ub = containers.ub
346346
lb = containers.lb
347347
labels = containers.labels

test/test06_yingyang.jl renamed to test/test06_yinyang.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,108 @@
1-
module TestYingYang
1+
module TestYinyang
22

33
using ParallelKMeans
44
using Test
55
using Random
66

7-
@testset "basic kmeans yingyang" begin
7+
@testset "basic kmeans Yinyang" begin
88
X = [1. 2. 4.;]
9-
res = kmeans(YingYang(false), X, 1; n_threads = 1, tol = 1e-6, verbose = false)
9+
res = kmeans(Yinyang(false), X, 1; n_threads = 1, tol = 1e-6, verbose = false)
1010
@test res.assignments == [1, 1, 1]
1111
@test res.centers[1] 2.3333333333333335
1212
@test res.totalcost 4.666666666666666
1313
@test res.converged
1414

15-
res = kmeans(YingYang(false), X, 2; n_threads = 1, init = [1.0 4.0], tol = 1e-6, verbose = false)
15+
res = kmeans(Yinyang(false), X, 2; n_threads = 1, init = [1.0 4.0], tol = 1e-6, verbose = false)
1616
@test res.assignments == [1, 1, 2]
1717
@test res.centers [1.5 4.0]
1818
@test res.totalcost 0.5
1919
@test res.converged
2020
end
2121

22-
@testset "yingyang no convergence yield last result" begin
22+
@testset "Yinyang no convergence yield last result" begin
2323
X = [1. 2. 4.;]
24-
res = kmeans(YingYang(false), X, 2; n_threads = 1, init = [1.0 4.0], tol = 1e-6, max_iters = 1, verbose = false)
24+
res = kmeans(Yinyang(false), X, 2; n_threads = 1, init = [1.0 4.0], tol = 1e-6, max_iters = 1, verbose = false)
2525
@test !res.converged
2626
@test res.totalcost 0.5
2727
end
2828

29-
@testset "yingyang singlethread linear separation" begin
29+
@testset "Yinyang singlethread linear separation" begin
3030
Random.seed!(2020)
3131

3232
X = rand(3, 100)
33-
res = kmeans(YingYang(false), X, 3; n_threads = 1, tol = 1e-10, max_iters = 10, verbose = false)
33+
res = kmeans(Yinyang(false), X, 3; n_threads = 1, tol = 1e-10, max_iters = 10, verbose = false)
3434

3535
@test res.totalcost 14.16198704459199
3636
@test !res.converged
3737
@test res.iterations == 10
3838
end
3939

40-
@testset "yingyang multithread linear separation quasi two threads" begin
40+
@testset "Yinyang multithread linear separation quasi two threads" begin
4141
Random.seed!(2020)
4242

4343
X = rand(3, 100)
44-
res = kmeans(YingYang(false), X, 3; n_threads = 2, tol = 1e-6, verbose = false)
44+
res = kmeans(Yinyang(false), X, 3; n_threads = 2, tol = 1e-6, verbose = false)
4545

4646
@test res.totalcost 14.16198704459199
4747
@test res.converged
4848
end
4949

50-
@testset "yingyang different modes" begin
50+
@testset "Yinyang different modes" begin
5151
Random.seed!(2020)
5252
X = rand(3, 100)
5353
init = ParallelKMeans.smart_init(X, 20).centroids
5454
baseline = kmeans(Lloyd(), X, 20, init = init, tol = 1e-10, n_threads = 1, verbose = false, max_iters = 1000)
5555

56-
res = kmeans(YingYang(false), X, 20, init = init, tol = 1e-10, n_threads = 1, verbose = false, max_iters = 1000)
56+
res = kmeans(Yinyang(false), X, 20, init = init, tol = 1e-10, n_threads = 1, verbose = false, max_iters = 1000)
5757
@test res.converged
5858
@test res.totalcost baseline.totalcost
5959
@test res.assignments == baseline.assignments
6060
@test res.centers baseline.centers
6161
@test res.iterations == baseline.iterations
6262

63-
res = kmeans(YingYang(), X, 20, init = init, tol = 1e-10, n_threads = 1, verbose = false, max_iters = 1000)
63+
res = kmeans(Yinyang(), X, 20, init = init, tol = 1e-10, n_threads = 1, verbose = false, max_iters = 1000)
6464
@test res.converged
6565
@test res.totalcost baseline.totalcost
6666
@test res.assignments == baseline.assignments
6767
@test res.centers baseline.centers
6868
@test res.iterations == baseline.iterations
6969

70-
res = kmeans(YingYang(10), X, 20, init = init, tol = 1e-10, n_threads = 1, verbose = false, max_iters = 1000)
70+
res = kmeans(Yinyang(10), X, 20, init = init, tol = 1e-10, n_threads = 1, verbose = false, max_iters = 1000)
7171
@test res.converged
7272
@test res.totalcost baseline.totalcost
7373
@test res.assignments == baseline.assignments
7474
@test res.centers baseline.centers
7575
@test res.iterations == baseline.iterations
7676

77-
res = kmeans(YingYang(7), X, 20, init = init, tol = 1e-10, n_threads = 1, verbose = false, max_iters = 1000)
77+
res = kmeans(Yinyang(7), X, 20, init = init, tol = 1e-10, n_threads = 1, verbose = false, max_iters = 1000)
7878
@test res.converged
7979
@test res.totalcost baseline.totalcost
8080
@test res.assignments == baseline.assignments
8181
@test res.centers baseline.centers
8282
@test res.iterations == baseline.iterations
8383

84-
res = kmeans(YingYang(false), X, 20, init = init, tol = 1e-10, n_threads = 2, verbose = false, max_iters = 1000)
84+
res = kmeans(Yinyang(false), X, 20, init = init, tol = 1e-10, n_threads = 2, verbose = false, max_iters = 1000)
8585
@test res.converged
8686
@test res.totalcost baseline.totalcost
8787
@test res.assignments == baseline.assignments
8888
@test res.centers baseline.centers
8989
@test res.iterations == baseline.iterations
9090

91-
res = kmeans(YingYang(), X, 20, init = init, tol = 1e-10, n_threads = 2, verbose = false, max_iters = 1000)
91+
res = kmeans(Yinyang(), X, 20, init = init, tol = 1e-10, n_threads = 2, verbose = false, max_iters = 1000)
9292
@test res.converged
9393
@test res.totalcost baseline.totalcost
9494
@test res.assignments == baseline.assignments
9595
@test res.centers baseline.centers
9696
@test res.iterations == baseline.iterations
9797

98-
res = kmeans(YingYang(10), X, 20, init = init, tol = 1e-10, n_threads = 2, verbose = false, max_iters = 1000)
98+
res = kmeans(Yinyang(10), X, 20, init = init, tol = 1e-10, n_threads = 2, verbose = false, max_iters = 1000)
9999
@test res.converged
100100
@test res.totalcost baseline.totalcost
101101
@test res.assignments == baseline.assignments
102102
@test res.centers baseline.centers
103103
@test res.iterations == baseline.iterations
104104

105-
res = kmeans(YingYang(7), X, 20, init = init, tol = 1e-10, n_threads = 2, verbose = false, max_iters = 1000)
105+
res = kmeans(Yinyang(7), X, 20, init = init, tol = 1e-10, n_threads = 2, verbose = false, max_iters = 1000)
106106
@test res.converged
107107
@test res.totalcost baseline.totalcost
108108
@test res.assignments == baseline.assignments

0 commit comments

Comments
 (0)