Skip to content

Instantly share code, notes, and snippets.

@mortenjohs
Created January 4, 2013 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mortenjohs/4452914 to your computer and use it in GitHub Desktop.
Save mortenjohs/4452914 to your computer and use it in GitHub Desktop.
# 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
@mortenjohs
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment