Sha256: c99970a5c7a8c99574e6b56d2e8d13071e7173d317d70cdf26dd8fbb555c1a1d

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

== KMeans

This is another KMeans implementation.  I have a few things that I need to work on:

* Extract the NodeList information out of the Node to make it more flexible
* Work on an online version of this code

The basic idea is that I wanted to solve a problem for a client, but I didn't want to throw the code away.  So you get this.

==Usage

For now, a very quick demonstration.  This creates a one-dimensional node list with number ranges between 1 and 3, 5, and 6 through 10.  

  @node_list =  (1..100).map { while (n = rand(10) + 1) == 4 or n == 6; end;  n} 
  @kmeans = KMeans::Agent.call(:k => 3, *@node_list)
  puts @kmeans.centroids.inspect
  # => [KMeans::Centroid:[223/26], KMeans::Centroid:[37/17], KMeans::Centroid:[5]]
  @kmeans.centroids.map {|c| c.position.first.to_f} 
  # => [8.57692307692308, 2.17647058823529, 5.0]

I'll put a more interesting example together at another time.

==Installation

sudo gem install davidrichards-kmeans

=== Dependencies

* TeguGears

==COPYRIGHT

Copyright (c) 2009 David Richards. See LICENSE for details.

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
davidrichards-kmeans-0.0.3 README.rdoc
davidrichards-kmeans-0.0.4 README.rdoc