Last active
August 29, 2015 14:01
-
-
Save j138/7ac9635d3e26ebb2df80 to your computer and use it in GitHub Desktop.
新艦娘XXXの大きさ予測
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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
host = '127.0.0.1' | |
port = 9199 | |
name = 'test' | |
require 'jubatus/classifier/client' | |
client = Jubatus::Classifier::Client::Classifier.new(host, port, name) | |
train_data = | |
['huge', Jubatus::Common::Datum.new('name' => '長門', 'type' => '戦艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '陸奥', 'type' => '戦艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '伊勢', 'type' => '戦艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '日向', 'type' => '戦艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '雪風', 'type' => '駆逐艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '赤城', 'type' => '正規空母')], | |
['huge', Jubatus::Common::Datum.new('name' => '加賀', 'type' => '正規空母')], | |
['huge', Jubatus::Common::Datum.new('name' => '蒼龍', 'type' => '正規空母')], | |
['huge', Jubatus::Common::Datum.new('name' => '飛龍', 'type' => '正規空母')], | |
['flat', Jubatus::Common::Datum.new('name' => '島風', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '吹雪', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '白雪', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '初雪', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '深雪', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '叢雲', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '磯波', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '綾波', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '敷波', 'type' => '駆逐艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '大井', 'type' => '軽巡洋艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '北上', 'type' => '軽巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '金剛', 'type' => '高速戦艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '比叡', 'type' => '高速戦艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '榛名', 'type' => '高速戦艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '霧島', 'type' => '高速戦艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '鳳翔', 'type' => '軽空母')], | |
['huge', Jubatus::Common::Datum.new('name' => '扶桑', 'type' => '戦艦')], | |
# ['huge', Jubatus::Common::Datum.new('name' => '山城', 'type' => '戦艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '天龍', 'type' => '軽巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '龍田', 'type' => '軽巡洋艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '龍驤', 'type' => '軽空母')], | |
['flat', Jubatus::Common::Datum.new('name' => '睦月', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '如月', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '皐月', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '文月', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '長月', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '菊月', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '三日月', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '望月', 'type' => '駆逐艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '球磨', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '多摩', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '木曾', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '長良', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '五十鈴', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '名取', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '由良', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '川内', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '神通', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '那珂', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '千歳', 'type' => '水上機母艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '千代田', 'type' => '水上機母艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '最上', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '古鷹', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '加古', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '青葉', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '妙高', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '那智', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '足柄', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '羽黒', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '高雄', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '愛宕', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '摩耶', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '鳥海', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '利根', 'type' => '重巡洋艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '筑摩', 'type' => '重巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '飛鷹', 'type' => '軽空母')], | |
['middle', Jubatus::Common::Datum.new('name' => '隼鷹', 'type' => '軽空母')], | |
['flat', Jubatus::Common::Datum.new('name' => '朧', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '曙', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '漣', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '潮', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '暁', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '響', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '雷', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '電', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '初春', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '子日', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '若葉', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '初霜', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '白露', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '時雨', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '村雨', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '夕立', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '五月雨', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '涼風', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '朝潮', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '大潮', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '満潮', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '荒潮', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '霰', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '霞', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '陽炎', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '不知火', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '黒潮', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '祥鳳', 'type' => '軽空母')], | |
['huge', Jubatus::Common::Datum.new('name' => '翔鶴', 'type' => '正規空母')], | |
['huge', Jubatus::Common::Datum.new('name' => '瑞鶴', 'type' => '正規空母')], | |
['middle', Jubatus::Common::Datum.new('name' => '鬼怒', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '阿武隈', 'type' => '軽巡洋艦')], | |
['middle', Jubatus::Common::Datum.new('name' => '夕張', 'type' => '軽巡洋艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '瑞鳳', 'type' => '軽空母')], | |
['flat', Jubatus::Common::Datum.new('name' => '大鳳', 'type' => '装甲空母')], | |
['huge', Jubatus::Common::Datum.new('name' => '伊401', 'type' => '潜水空母')], | |
['huge', Jubatus::Common::Datum.new('name' => 'あきつ丸', 'type' => '揚陸艦')], | |
['flat', Jubatus::Common::Datum.new('name' => 'まるゆ', 'type' => '潜水艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '弥生', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '卯月', 'type' => '駆逐艦')], | |
['flat', Jubatus::Common::Datum.new('name' => '谷風', 'type' => '駆逐艦')], | |
['huge', Jubatus::Common::Datum.new('name' => '浜風', 'type' => '駆逐艦')], | |
['huge', Jubatus::Common::Datum.new('name' => 'Bismarck', 'type' => '高速戦艦')] | |
client.train(train_data) | |
new_ships = | |
[ | |
Jubatus::Common::Datum.new('name' => '大和', 'type' => '戦艦'), | |
Jubatus::Common::Datum.new('name' => '信濃', 'type' => '正規空母'), | |
Jubatus::Common::Datum.new('name' => '龍鳳', 'type' => '正規空母'), | |
Jubatus::Common::Datum.new('name' => '大淀', 'type' => '軽巡洋艦'), | |
Jubatus::Common::Datum.new('name' => '神風', 'type' => '駆逐艦'), | |
Jubatus::Common::Datum.new('name' => '東雲', 'type' => '駆逐艦'), | |
Jubatus::Common::Datum.new('name' => '夏雲', 'type' => '駆逐艦') | |
] | |
new_ships.each do | target | | |
results = client.classify([target]) | |
p target.string_values[0][1] | |
results.each do |result| | |
result.each do |r| | |
puts(' ' + r.label + ' ' + r.score.to_s) | |
end | |
end | |
puts '--------' | |
end |
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
"大和" | |
middle -0.0791015625 | |
flat -0.063629150390625 | |
huge 0.826324462890625 | |
-------- | |
"信濃" | |
middle -0.23388671875 | |
flat -0.46875 | |
huge 0.70263671875 | |
-------- | |
"龍鳳" | |
middle -0.23388671875 | |
flat -0.46875 | |
huge 0.70263671875 | |
-------- | |
"大淀" | |
middle 0.6005610823631287 | |
flat -0.31250137090682983 | |
huge -0.28805971145629883 | |
-------- | |
"神風" | |
middle -0.3333333432674408 | |
flat 0.6666353344917297 | |
huge -0.33330196142196655 | |
-------- | |
"東雲" | |
middle -0.3333333432674408 | |
flat 0.6666353344917297 | |
huge -0.33330196142196655 | |
-------- | |
"夏雲" | |
middle -0.3333333432674408 | |
flat 0.6666353344917297 | |
huge -0.33330196142196655 | |
-------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment