Sha256: 3c80f2fcbfc6f94d5dbe571442fde8a121fcdfc15af36549dc464c3446e8f806
Contents?: true
Size: 616 Bytes
Versions: 1
Compression:
Stored size: 616 Bytes
Contents
#!/usr/bin/env ruby require File.expand_path('../../lib/clusterable', __FILE__) require 'csv' require 'benchmark' points = [] CSV.foreach(File.expand_path('../points.csv', __FILE__)) do |row| latitude = row[0].to_f longitude = row[1].to_f if latitude > 0.0 && longitude > 0.0 points << Clusterable::Point.new(latitude, longitude) end end time = Benchmark.measure do clusters = Clusterable::Cluster.kmeans(points, 12, 0.05) clusters.each do |cluster| puts "#{cluster.center} has #{cluster.points.size} #{cluster.points.size == 1 ? 'point' : 'points'}" end end puts "Time taken: #{time}"
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clusterable-0.0.1 | benchmark/benchmark.rb |