Created
January 4, 2013 14:23
-
-
Save mortenjohs/4452914 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# parameters | |
k = 7 | |
number_of_points = 10000 | |
delta = 0.001 | |
plot_on = false | |
require './k-means.rb' | |
points = [] | |
number_of_points.times do | |
points << Point2D.new(10*rand()-5.0, 10*rand()-5.0) | |
end | |
clusters = k_means points, k, delta, plot_on | |
clusters.each_with_index do |cluster, index| | |
puts "#{ cluster.center.to_s }\t#{ index }" | |
end | |
cluster_plot_2D clusters, "#{k}-final" if plot_on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More info: http://m635j520.blogspot.fr/2013/02/implementing-k-means-clustering-in-ruby.html