KMeans class

A class for organizing k-means computations with utility methods for finding a good solution.

https://en.wikipedia.org/wiki/K-means_clustering

Uses k-means++ (https://en.wikipedia.org/wiki/K-means%2B%2B) for the initial means, and then iterates.

The points accepted by KMeans can have any number of dimensions and are represented by List<double>. The distance function is hard-coded to be the euclidan distance.

Constructors

KMeans(List<List<double>> points, {List<int> ignoredDims = _emptyList, int labelDim = -1})
points gives the list of points to cluster. ignoreDims gives a list of dimensions of points to ignore. labelDim gives the index of a label in each point if there is one.

Properties

hashCode int
The hash code for this object.
no setterinherited
ignoredDims List<int>
Dimensions of points that are ignored.
final
labelDim int
The index of the label. Defaults to -1 if the data is unlabeled.
final
points List<List<double>>
The points to cluster.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

bestFit({int maxIterations = 300, int seed = 42, int minK = 2, int maxK = 20, int trialsPerK = 1, KMeansInitializer init = KMeansInitializers.kMeansPlusPlus, double tolerance = defaultPrecision, bool useExactSilhouette = false}) Clusters
Finds the 'best' k-means Cluster over a range of possible values of 'k'.
fit(int k, {int maxIterations = 300, int seed = 42, KMeansInitializer init = KMeansInitializers.kMeansPlusPlus, double tolerance = defaultPrecision}) Clusters
Returns a Cluster of points into k clusters.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

defaultPrecision → const double
Numbers closer together than this are considered equivalent.