kmeans 0.2.0
kmeans: ^0.2.0 copied to clipboard
A Dart library for k-means clustering
A simple implementation of k-means clustering.
Clusters are initialized using the k-means++ method.
To evaluate the goodness of a clustering, and to find good values for k when one is not known a priori, this library includes a calculation of the silhouette of a clustering.
Usage #
A simple usage example:
import 'package:kmeans/kmeans.dart';
main() {
var kmeans = KMeans([
[0.0, 0.0], [1.1, 1.1], [-5.0, -0.50], ...
]);
var k = 3;
var clusters = kmeans.compute(k);
var silhouette = clusters.silhouette;
print('The clusters have silhouette $silhouette');
for (int i = 0; i < kmeans.points.length; i++) {
var point = kmeans.points[i];
var cluster = kmeans.clusters[i];
var mean = kmeans.means[cluster];
print('$point is in cluster $cluster with mean $mean.');
}
...
var bestCluster = kmeans.computeBest(
minK: 3,
maxK: 10,
);
}
Features and bugs #
Please file feature requests and bugs at the issue tracker.