Skip to content

@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

ts
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:

  1. Start with K_min clusters using KMeans
  2. For each cluster, try splitting it into 2 sub-clusters
  3. If BIC improves after splitting, keep the split
  4. Run KMeans again with all (old + new) centroids
  5. Repeat until K_max is reached or no more improvements

Parameters

ParameterTypeDescription
pointsInputTypeThe data points to cluster
parameters?Partial<ParametersXMeans>Configuration parameters

Returns

XMeans

See

Overrides

ts
Clustering.constructor

Properties

PropertyTypeInherited fromDefined in
_best_kmeansKMeans | null-clustering/XMeans.js:67
_DnumberClustering._Dclustering/Clustering.js:19
_matrixMatrixClustering._matrixclustering/Clustering.js:15
_NnumberClustering._Nclustering/Clustering.js:17
_parametersParametersXMeansClustering._parametersclustering/Clustering.js:13
_pointsInputTypeClustering._pointsclustering/Clustering.js:11
_randomizerRandomizer-clustering/XMeans.js:64

Accessors

centroids

Get Signature

ts
get centroids(): Float64Array<ArrayBufferLike>[];

Defined in: clustering/XMeans.js:344

Get the final centroids

Returns

Float64Array<ArrayBufferLike>[]

Array of centroids


k

Get Signature

ts
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()

ts
get_cluster_list(): number[];

Defined in: clustering/XMeans.js:332

Returns

number[]

The cluster list

Overrides

ts
Clustering.get_cluster_list

get_clusters()

ts
get_clusters(): number[][];

Defined in: clustering/XMeans.js:324

Get the computed clusters

Returns

number[][]

Array of clusters, each containing indices of points

Overrides

ts
Clustering.get_clusters