@saehrimnir/druidjs / XMeans
Class: XMeans
Defined in: clustering/XMeans.js:34
X-Means Clustering
An extension of K-Means that automatically determines the number of clusters (K) using the Bayesian Information Criterion (BIC).
Extends
Clustering
Constructors
Constructor
new XMeans(points: InputType, parameters?: Partial<ParametersXMeans>): XMeans;Defined in: clustering/XMeans.js:54
XMeans clustering algorithm that automatically determines the optimal number of clusters.
X-Means extends K-Means by starting with a minimum number of clusters and iteratively splitting clusters to improve the Bayesian Information Criterion (BIC).
Algorithm:
- Start with K_min clusters using KMeans
- For each cluster, try splitting it into 2 sub-clusters
- If BIC improves after splitting, keep the split
- Run KMeans again with all (old + new) centroids
- Repeat until K_max is reached or no more improvements
Parameters
| Parameter | Type | Description |
|---|---|---|
points | InputType | The data points to cluster |
parameters? | Partial<ParametersXMeans> | Configuration parameters |
Returns
XMeans
See
- https://www.cs.cmu.edu/~dpelleg/download/xmeans.pdf
- https://github.com/annoviko/pyclustering/blob/master/pyclustering/cluster/xmeans.py
- https://github.com/haifengl/smile/blob/master/core/src/main/java/smile/clustering/XMeans.java
Overrides
Clustering.constructorProperties
| Property | Type | Inherited from | Defined in |
|---|---|---|---|
_best_kmeans | KMeans | null | - | clustering/XMeans.js:67 |
_D | number | Clustering._D | clustering/Clustering.js:19 |
_matrix | Matrix | Clustering._matrix | clustering/Clustering.js:15 |
_N | number | Clustering._N | clustering/Clustering.js:17 |
_parameters | ParametersXMeans | Clustering._parameters | clustering/Clustering.js:13 |
_points | InputType | Clustering._points | clustering/Clustering.js:11 |
_randomizer | Randomizer | - | clustering/XMeans.js:64 |
Accessors
centroids
Get Signature
get centroids(): Float64Array<ArrayBufferLike>[];Defined in: clustering/XMeans.js:344
Get the final centroids
Returns
Float64Array<ArrayBufferLike>[]
Array of centroids
k
Get Signature
get k(): number;Defined in: clustering/XMeans.js:356
Get the optimal number of clusters found
Returns
number
The number of clusters
Methods
get_cluster_list()
get_cluster_list(): number[];Defined in: clustering/XMeans.js:332
Returns
number[]
The cluster list
Overrides
Clustering.get_cluster_listget_clusters()
get_clusters(): number[][];Defined in: clustering/XMeans.js:324
Get the computed clusters
Returns
number[][]
Array of clusters, each containing indices of points
Overrides
Clustering.get_clusters