@@ -6,41 +6,17 @@ export cluster, cluster_number, cluster_labels, cluster_probs
66abstract type ClusteringAlgorithm end
77abstract type ClusteringResults end
88
9- """
10- cluster(ca::ClusteringAlgortihm, data) → cr::ClusteringResults
11-
12- Cluster input `data` according to the algorithm specified by `ca`.
13- All options related to the algorithm are given as keyword arguments when
14- constructing `ca`.
15-
16- The input `data` is a length-m iterable of "vectors" (data points).
17- "Vector" here is considered in the generalized sense, i.e., any objects that
18- a distance can be defined on them so that they can be clustered.
19- In the majority of cases these are vectors of real numbers.
20-
21- The output is always a subtype of `ClusteringResults` that can be further queried.
22- The cluster labels are always the
23- positive integers `1:n` with `n::Int` the number of created clusters,
24- Data points that couldn't get clustered (e.g., outliers or noise)
25- get assigned negative integers, typically just `-1`.
269
27- `ClusteringResults` subtypes always implement the following functions:
28-
29- - `cluster_labels(cr)` returns a length-m vector `labels::Vector{Int}` containing
30- the clustering labels , so that `data[i]` has label `labels[i]`.
31- - `cluster_probs(cr)` returns `probs` a length-m vector of length-`n` vectors
32- containing the "probabilities" or "score" of each point belonging to one of
33- the created clusters (useful for fuzzy clustering algorithms).
34- - `cluster_number(cr)` returns `n`.
35-
36- Other algorithm-related output can be obtained as a field of the result type,
37- or by using other specific functions of the result type.
38- This is described in the individual algorithm implementations docstrings.
39- """
4010function cluster (ca:: ClusteringAlgorithm , data)
4111 throw (ArgumentError (" No implementation for `cluster` for $(typeof (ca)) ." ))
4212end
4313
14+ @doc let # make README the `cluster` function docstring.
15+ path = joinpath (dirname (@__DIR__ ), " README.md" )
16+ include_dependency (path)
17+ read (path, String)
18+ end cluster
19+
4420"""
4521 cluster_number(cr::ClusteringResults) → n::Int
4622
@@ -76,22 +52,4 @@ function cluster_probs(cr::ClusteringResults)
7652 return probs
7753end
7854
79- # two helper functions for agnostic input data type
80- """
81- input_data_size(data) → (d, m)
82-
83- Return the data point dimension and number of data points.
84- """
85- input_data_size (A:: AbstractMatrix ) = size (A)
86- input_data_size (A:: AbstractVector{<:AbstractVector} ) = (length (first (A)), length (A))
87-
88- """
89- each_data_point(data)
90-
91- Return an indexable iterator over each data point in `data`, that can be
92- indexed with indices `1:m`.
93- """
94- each_data_point (A:: AbstractMatrix ) = eachcol (A)
95- each_data_point (A:: AbstractVector{<:AbstractVector} ) = A
96-
9755end
0 commit comments