Sha256: 3c942e878c0d60165829b88c06b13543ca50903728852f70c2cf9cc8f6d6c79e

Contents?: true

Size: 556 Bytes

Versions: 1

Compression:

Stored size: 556 Bytes

Contents

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

T = 2000

iris = load_iris
y_arr = iris.map {|r| r[0]}
y = GSL::Vector.alloc y_arr
x = iris.map {|r| r[1...-1]}
x = x.map{|r| r << 1}
x = GLM::Util.aa_to_gsl_matrix x

linear = GLM::Linear.new(x, y,0.05)

(1..T).each do |i|
  linear.sto_update
  est_y =  linear.est(x)
  err = (est_y - y).nrm2
  puts err
end

#end

#puts ((y_est - y).map {|e| e ** 2}).reduce(:+)/y.row_size
#    puts "Theta: #{y_est.to_a.to_s}"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glm-0.0.2 examples/test_glm_linear.rb