Skip to content

Instantly share code, notes, and snippets.

@komiya-atsushi
Created December 21, 2012 12:27
Show Gist options
  • Save komiya-atsushi/4352519 to your computer and use it in GitHub Desktop.
Save komiya-atsushi/4352519 to your computer and use it in GitHub Desktop.
require 'arow'
model = AROW::Model.new(2, 0.1)
File.foreach("CodeIQ_auth.txt") do |line|
elems = line.chomp.split(/\s/)
next if elems.size < 3
features = { 0 => elems[0].to_f, 1 => elems[1].to_f }
label = (elems[2] == "1")
model.update(features, label)
#vectors << { :feature => features, :label => label }
end
File.foreach("CodeIQ_mycoins.txt") do |line|
elems = line.chomp.split(/\s/)
next if elems.size < 2
features = { 0 => elems[0].to_f, 1 => elems[1].to_f }
puts model.predict(features) ? 1 : 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment