@@ -6,44 +6,37 @@ import Base.Threads: @spawn, @threads
66export kmeans
77
88
9+ # All Abstract types defined
10+ """
11+ TODO: Docs
12+ """
913abstract type AbstractKMeansAlg end
10- abstract type CalculationMode end
1114
12- struct Lloyd <: AbstractKMeansAlg end
13- struct LightElkan <: AbstractKMeansAlg end
14-
15- # Single thread class to control the calculation type based on the CalculationMode
16- struct SingleThread <: CalculationMode
17- end
18-
19- # Multi threaded implementation to control the calculation type based avaialble threads
20- struct MultiThread <: CalculationMode
21- n:: Int
22- end
23-
24- # Get the number of avaialble threads for multithreading implementation
25- MultiThread () = MultiThread (Threads. nthreads ())
15+ """
16+ TODO: Docs
17+ """
18+ abstract type CalculationMode end
2619
27- # TODO here we mimic `Clustering` data structure, should thing how to integrate these
28- # two packages more closely.
2920
3021"""
3122 ClusteringResult
3223Base type for the output of clustering algorithm.
3324"""
3425abstract type ClusteringResult end
3526
36- # C is the type of centers, an (abstract) matrix of size (d x k)
37- # D is the type of pairwise distance computation from points to cluster centers
38- # WC is the type of cluster weights, either Int (in the case where points are
39- # unweighted) or eltype(weights) (in the case where points are weighted).
27+
28+ # Here we mimic `Clustering` output structure
4029"""
4130 KmeansResult{C,D<:Real,WC<:Real} <: ClusteringResult
4231The output of [`kmeans`](@ref) and [`kmeans!`](@ref).
4332# Type parameters
4433 * `C<:AbstractMatrix{<:AbstractFloat}`: type of the `centers` matrix
4534 * `D<:Real`: type of the assignment cost
4635 * `WC<:Real`: type of the cluster weight
36+ # C is the type of centers, an (abstract) matrix of size (d x k)
37+ # D is the type of pairwise distance computation from points to cluster centers
38+ # WC is the type of cluster weights, either Int (in the case where points are
39+ # unweighted) or eltype(weights) (in the case where points are weighted).
4740"""
4841struct KmeansResult{C<: AbstractMatrix{<:AbstractFloat} ,D<: Real ,WC<: Real } <: ClusteringResult
4942 centers:: C # cluster centers (d x k)
@@ -56,6 +49,32 @@ struct KmeansResult{C<:AbstractMatrix{<:AbstractFloat},D<:Real,WC<:Real} <: Clus
5649 converged:: Bool # whether the procedure converged
5750end
5851
52+ # All Structs/Classess defined
53+ """
54+ TODO: Docs
55+ """
56+ struct Lloyd <: AbstractKMeansAlg end
57+
58+
59+ """
60+ TODO: Docs
61+ """
62+ struct LightElkan <: AbstractKMeansAlg end
63+
64+ # Single thread class to control the calculation type based on the CalculationMode
65+ struct SingleThread <: CalculationMode
66+ end
67+
68+ # Multi threaded implementation to control the calculation type based avaialble threads
69+ struct MultiThread <: CalculationMode
70+ n:: Int
71+ end
72+
73+ # Get the number of avaialble threads for multithreading implementation
74+ MultiThread () = MultiThread (Threads. nthreads ())
75+
76+
77+
5978"""
6079 colwise!(target, x, y, mode)
6180
0 commit comments