davidrichards / kmeans
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (3)
- Wiki (1)
- Graphs
-
Branch:
master
David Richards (author)
Thu Jul 30 20:14:42 -0700 2009
kmeans /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sun Jul 19 10:52:58 -0700 2009 | |
| |
LICENSE | Sun Jul 19 10:52:58 -0700 2009 | |
| |
README.rdoc | ||
| |
Rakefile | ||
| |
VERSION.yml | ||
| |
bin/ | ||
| |
features/ | Sun Jul 19 10:52:58 -0700 2009 | |
| |
kmeans.gemspec | ||
| |
lib/ | ||
| |
spec/ |
README.rdoc
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 © 2009 David Richards. See LICENSE for details.

