Sha256: 5f79bfc54545c760e870fb248873979f1c9ba31ed5db1518cb4f3dafd3ba2f6a

Contents?: true

Size: 659 Bytes

Versions: 2

Compression:

Stored size: 659 Bytes

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

require 'kmeans/pair'
require 'kmeans/pearson'
require 'kmeans/cluster'

uniform_hash = {
"test01"=> {"hoge"=>0, "fuga"=>1, "piyo"=>0 },
"test02"=> {"hoge"=>2, "fuga"=>1, "piyo"=>3 },
"test03"=> {"hoge"=>3, "fuga"=>0, "piyo"=>1 },
"test04"=> {"hoge"=>0, "fuga"=>2, "piyo"=>0 },
"test05"=> {"hoge"=>4, "fuga"=>2, "piyo"=>3 },
"test06"=> {"hoge"=>3, "fuga"=>1, "piyo"=>1 }}

result = Kmeans::Cluster.new(uniform_hash, {
  :centroids => 5,
  :loop_max => 10
})
result.make_cluster

# The results differ for each run
p result.cluster.values #=> [["test01", "test04"], ["test02"], ["test03", "test05"], ["test06"], []]

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kmeans-0.1.1 demo.rb
kmeans-0.1.0 demo.rb