Skip to content

Instantly share code, notes, and snippets.

@moccos
Created February 19, 2013 15:42
Show Gist options
  • Save moccos/4986980 to your computer and use it in GitHub Desktop.
Save moccos/4986980 to your computer and use it in GitHub Desktop.
2/18 第1回 Jubatusハンズオン http://partake.in/events/cf1df52e-9e4e-45e0-b3ec-e64a9674bab9 で遊んだコード断片
host = '127.0.0.1'
port = 9199
name = 'test'
import jubatus
from jubatus.classifier.types import datum
client = jubatus.Classifier(host, port)
train_data = [
('41', datum([],[('STR', 19.0),('AGI', 14.0),('DEX', 13.0),('INT', 18.0),('CHR', 17.0)])),
('12', datum([],[('STR', 21.0),('AGI', 15.0),('DEX', 13.0),('INT', 15.0),('CHR', 18.0)])),
('83', datum([],[('STR', 19.0),('AGI', 20.0),('DEX', 15.0),('INT', 13.0),('CHR', 17.0)])),
('73', datum([],[('STR', 14.0),('AGI', 15.0),('DEX', 16.0),('INT', 21.0),('CHR', 17.0)])),
('15', datum([],[('STR', 28.0),('AGI', 24.0),('DEX', 16.0),('INT', 16.0),('CHR', 21.0)])),
# 6200行くらい略
]
client.train(name, train_data)
host = '127.0.0.1'
port = 9199
name = 'test'
import jubatus
from jubatus.classifier.types import datum
client = jubatus.Classifier(host, port)
test_data = [
# 41: bishop
#datum([],[('STR', 19.0),('AGI', 14.0),('DEX', 13.0),('INT', 18.0),('CHR', 17.0)]),
# 12: general
datum([],[('STR', 21.0),('AGI', 15.0),('DEX', 13.0),('INT', 15.0),('CHR', 18.0)]),
]
results = client.classify(name, test_data)
for result in results:
for r in result:
print r.label, r.score
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment