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}"