Sha256: ce6b96058c87ab7c829974542f5df215bf100a5ec1bd589bd8fe36254ee80805

Contents?: true

Size: 509 Bytes

Versions: 2

Compression:

Stored size: 509 Bytes

Contents

require 'glm'
require 'pp'
require 'ruby-debug' ; Debugger.start(:post_mortem => true)
Debugger.settings[:autoeval] = true
require 'prepare'

T = 200

iris = load_iris
y_arr = iris.map {|r| r[-1].to_i}
x = iris.map {|r| r[0...-2]}
x = x.map{|r| r << 1}
x,y = GLM::Util.formatArrays(x, y_arr)

glm = GLM::Logit.new(x, y, 0.1)

(1..T).each do |i|
  glm.sto_update

  est_y =  glm.est(x)
  err = (y.zip(est_y).map{|e| (e[0]!=e[1])?1:0}).reduce(:+)#/y.row_size
#  pp y.zip(est_y)
  
  puts err
  pp glm.theta
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
glm-0.0.1 examples/test_glm_logit.rb
glm-0.0.0 examples/test_glm_logit.rb