Skip to content

Commit 117b2d8

Browse files
committed
Minor cleanup for v0.1.7
1 parent cd2a135 commit 117b2d8

File tree

8 files changed

+9
-10
lines changed

8 files changed

+9
-10
lines changed

Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Distances = "0.8.2"
1515
MLJModelInterface = "0.2.1"
1616
StatsBase = "0.32, 0.33"
1717
julia = "1.3"
18+
UnsafeArrays = "1"
1819

1920
[extras]
2021
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ________________________________________________________________________________
1111
_________________________________________________________________________________________________________
1212

1313
<div align="center">
14-
<b>Classic & Contemporary Variants Of K-Means In Sonic Mode<b>
14+
<b>Classic & Contemporary Variants Of K-Means In Sonic Mode</b>
1515
</div>
1616

1717
<p align="center">

benchmark/bench01_distance.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ suite = BenchmarkGroup()
99
Random.seed!(2020)
1010
X = rand(3, 100_000)
1111
centroids = rand(3, 2)
12-
d = Vector{Float64}(undef, 100_000)
13-
suite["100kx3"] = @benchmarkable ParallelKMeans.chunk_colwise($d, $X, $centroids, 1, nothing, Euclidean(), 1:100_000, 1)
12+
d = fill(-Inf, 100_000)
13+
suite["100kx3"] = @benchmarkable ParallelKMeans.chunk_colwise(d1, $X, $centroids, 1, nothing, Euclidean(), 1:100_000, 1) setup=(d1 = copy(d))
1414

1515
X = rand(10, 100_000)
1616
centroids = rand(10, 2)
17-
d = Vector{Float64}(undef, 100_000)
18-
suite["100kx10"] = @benchmarkable ParallelKMeans.chunk_colwise($d, $X, $centroids, 1, nothing, Euclidean(), 1:100_000, 1)
17+
d = fill(-Inf, 100_000)
18+
suite["100kx10"] = @benchmarkable ParallelKMeans.chunk_colwise(d1, $X, $centroids, 1, nothing, Euclidean(), 1:100_000, 1) setup=(d1 = copy(d))
1919

2020
end # module
2121

docs/src/index.md

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ pkg> free ParallelKMeans
8080
- [X] Support of MLJ Random generation hyperparameter.
8181
- [ ] Support for other distance metrics supported by [Distances.jl](https://github.com/JuliaStats/Distances.jl#supported-distances).
8282
- [ ] Implementation of [Geometric methods to accelerate k-means algorithm](http://cs.baylor.edu/~hamerly/papers/sdm2016_rysavy_hamerly.pdf).
83-
- [ ] Support of MLJ Random generation hyperparameter.
8483
- [ ] Native support for tabular data inputs outside of MLJModels' interface.
8584
- [ ] Refactoring and finalization of API design.
8685
- [ ] GPU support.

src/hamerly.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ function update_containers(::Hamerly, containers, centroids, n_threads, metric)
149149
s .= T(Inf)
150150
@inbounds for i in axes(centroids, 2)
151151
for j in i+1:size(centroids, 2)
152-
d = distance(metric, centroids, centroids, i, j)
153-
d = T(centers_coefficient(metric)) * d
152+
d = T(centers_coefficient(metric)) * distance(metric, centroids, centroids, i, j)
154153
s[i] = s[i] > d ? d : s[i]
155154
s[j] = s[j] > d ? d : s[j]
156155
end

src/kmeans.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,4 @@ end
205205

206206
# Special center co-efficent dispatched on Euclidean or different metrics supported by Distances.jl
207207
centers_coefficient(::Euclidean) = 0.25
208-
centers_coefficient(::Distances.Metric) = 0.5
208+
centers_coefficient(::Metric) = 0.5

test/test04_elkan.jl

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ end
108108
res = kmeans(Elkan(), X, 2; tol = 1e-16, metric = Cityblock(), rng = rng)
109109
@test res.totalcost 60.893492629945044
110110
@test res.converged
111+
@test res.iterations == 6
111112
end
112113

113114
end # module

test/test05_hamerly.jl

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ using ParallelKMeans
44
using ParallelKMeans: chunk_initialize, double_argmax
55
using Test
66
using StableRNGs
7-
using Random
87
using Distances
98

109

0 commit comments

Comments
 (0)