Skip to content

Commit

Permalink
deprecate kmpp() and kmpp_by_costs()
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst committed Mar 29, 2019
1 parent d7030fd commit 8c4cbc6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
14 changes: 4 additions & 10 deletions doc/source/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@ KmppAlg
KmCentralityAlg
RandSeedAlg
```
In practice, we have found that *Kmeans++* is the most effective choice.

For convenience, the package also defines the two wrapper methods that take
the name of the seeding algorithm and the number of clusters and take care of
allocating `iseeds` and applying the proper `SeedingAlgorithm` instance:
For convenience, the package defines the two wrapper functions that accept
the short name of the seeding algorithm and the number of clusters and take
care of allocating `iseeds` and applying the proper `SeedingAlgorithm`:
```@docs
initseeds
initseeds_by_costs
```

In practice, we found that *Kmeans++* is the most effective seeding method. To
simplify its usage we provide:
```@docs
kmpp
kmpp_by_costs
```
3 changes: 3 additions & 0 deletions src/deprecate.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
## Deprecated

# deprecated at 0.13
@deprecate kmpp(X, k) initseeds(:kmpp, X, k)
@deprecate kmpp_by_costs(costs, k) initseeds_by_costs(:kmpp, costs, k)
15 changes: 0 additions & 15 deletions src/seeding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,6 @@ function initseeds_by_costs!(iseeds::IntegerVector, alg::KmppAlg,
return iseeds
end

"""
kmpp(X, k)
Use *Kmeans++* to choose `k` seeds from the ``d×n`` data matrix `X`.
"""
kmpp(X::AbstractMatrix{<:Real}, k::Int) = initseeds(KmppAlg(), X, k)

"""
kmpp_by_costs(C, k)
Use *Kmeans++* to choose `k` seeds based on the ``n×n`` cost matrix `C`.
"""
kmpp_by_costs(costs::AbstractMatrix{<:Real}, k::Int) = initseeds(KmppAlg(), costs, k)


"""
K-medoids initialization based on centrality (`:kmcen`).
Expand Down
8 changes: 4 additions & 4 deletions test/seeding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ end
@test min_interdist((Xt')[:, iseeds]) > 20 * md0

Random.seed!(34568)
iseeds = kmpp(X, k)
iseeds = initseeds(:kmpp, X, k)
@test length(iseeds) == k
@test alldistinct(iseeds)
Random.seed!(34568)
iseeds_t = kmpp(Xt', k)
iseeds_t = initseeds(:kmpp, Xt', k)
@test iseeds_t == iseeds

Random.seed!(34568)
iseeds = kmpp_by_costs(C, k)
iseeds = initseeds_by_costs(:kmpp, C, k)
@test length(iseeds) == k
@test alldistinct(iseeds)
Random.seed!(34568)
iseeds_t = kmpp_by_costs(Ct', k)
iseeds_t = initseeds_by_costs(:kmpp, Ct', k)
@test iseeds_t == iseeds
end

Expand Down

0 comments on commit 8c4cbc6

Please sign in to comment.