Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[compat]
Distances = "0.8, 0.9, 0.10"
Distances = "0.10.9"
NearestNeighbors = "0.4"
StatsBase = "0.25, 0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34"
julia = "1"
Expand Down
6 changes: 3 additions & 3 deletions src/kmeans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ function _kmeans!(X::AbstractMatrix{<:Real}, # in: data matrix (d
end

if t == 1 || num_affected > 0.75 * k
pairwise!(dmat, distance, centers, X, dims=2)
pairwise!(distance, dmat, centers, X, dims=2)
else
# if only a small subset is affected, only compute for that subset
affected_inds = findall(to_update)
pairwise!(view(dmat, affected_inds, :), distance,
pairwise!(distance, view(dmat, affected_inds, :),
view(centers, :, affected_inds), X, dims=2)
end

Expand Down Expand Up @@ -387,7 +387,7 @@ function repick_unused_centers(X::AbstractMatrix{<:Real}, # in: the data matrix
tcosts[j] = 0
v = view(X, :, j)
centers[:, i] = v
colwise!(ds, distance, v, X)
colwise!(distance, ds, v, X)
tcosts = min(tcosts, ds)
end
end
2 changes: 1 addition & 1 deletion src/seeding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function initseeds!(iseeds::AbstractVector{<:Integer}, alg::KmppAlg,

# update mincosts
c = view(X, :, p)
colwise!(tmpcosts, metric, X, view(X, :, p))
colwise!(metric, tmpcosts, X, view(X, :, p))
updatemin!(mincosts, tmpcosts)
mincosts[p] = 0
end
Expand Down
2 changes: 1 addition & 1 deletion test/kmeans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rng = StableRNG(42)
struct MySqEuclidean <: SemiMetric end

# redefinition of Distances.pairwise! for MySqEuclidean type
function Distances.pairwise!(r::AbstractMatrix, dist::MySqEuclidean,
function Distances.pairwise!(dist::MySqEuclidean, r::AbstractMatrix,
a::AbstractMatrix, b::AbstractMatrix; dims::Integer=2)
dims == 2 || throw(ArgumentError("only dims=2 supported for MySqEuclidean distance"))
mul!(r, transpose(a), b)
Expand Down