k_means_cluster 0.1.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 50

k-means-cluster

A very simple implementation of k-means clustering.

Usage

A clustering session typically involves:

  • Setting a distance measureme to use.
distanceMeasure = DistanceType.squaredEuclidian; // default
  • Creating a List of Instances. This is generally done by mapping a list of whatever data structures is available.
// For example, data might be a List<String> such
// that each String represents an individual instance.
List<Instance> instances = data.map((datum) {
  List<num> coordinates = ...;
  String id = ...;
  return new Instance(coordinates, id: id); 
}).tolist();
  • Creating a List of Clusters. This can be done manually (e.g. create a set of randomly placed clusters). A convenience function initialClusters exists that takes in the list of Instances already created and randomly generates clusters from the instances such that instances more distant to the previous cluster are more likely to seed the next cluster.
List<Cluster> clusters = initialClusters(3, instances, seed: 0);
  • Running the algorithm using the kmeans function. This is a side-effect heavy function that iteratively shifts the clusters towards the mean position of the associated instances and reassigns instances to the nearest cluster.
kmeans(clusters: clusters, instances: instances);
  • Inspecting the instances property of each cluster.
clusters.forEach((cluster) {
  print(cluster);
  cluster.instances.forEach((instance) {
    print("  - $instance");
  });
});

Please see the associated wiki for more details and examples.

Please file feature requests and bugs at the issue tracker.

Changelog

0.1.0

  • Initial version.
  • Basic knn-clustering.
  • Distance measures: square Euclidian, city block.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  k_means_cluster: "^0.1.1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:k_means_cluster/k_means_cluster.dart';
  
Version Uploaded Documentation Archive
0.1.1 Jun 6, 2017 Go to the documentation of k_means_cluster 0.1.1 Download k_means_cluster 0.1.1 archive
0.1.0 Jun 6, 2017 Go to the documentation of k_means_cluster 0.1.0 Download k_means_cluster 0.1.0 archive
0.0.1 Jun 6, 2017 Go to the documentation of k_means_cluster 0.0.1 Download k_means_cluster 0.0.1 archive

Analysis

We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
98 / 100
Overall score:
Weighted score of the above. [more]
50
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:k_means_cluster/k_means_cluster.dart.

Suggestions

  • Package is getting outdated.

    The package was released 53 weeks ago.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use k_means_cluster.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
Dev dependencies
test ^0.12.0