Sha256: 84abc2c2848c0a6d3ec64c11a34a9bb8f73aacefd27009ce7bb959e617afff0d
Contents?: true
Size: 573 Bytes
Versions: 2
Compression:
Stored size: 573 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]} x = iris.map {|r| r[1...-1]} x = x.map{|r| r << 1} x,y = GLM::Util.formatArrays(x, y_arr) linear = GLM::Linear.new(x, y) (1..T).each do |i| linear.sto_update est_y = linear.est(x) err = (y.zip(est_y).map{|e| (e[0]-e[1])**2}).reduce(:+)/y.row_size 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
glm-0.0.1 | examples/test_glm_linear.rb |
glm-0.0.0 | examples/test_glm_linear.rb |