test/test_glm.rb in glm-0.0.1 vs test/test_glm.rb in glm-0.0.2

- old
+ new

@@ -1,9 +1,11 @@ require 'test/unit' require 'glm' require 'pp' -require 'ruby-debug' ; Debugger.start(:post_mortem => true) +require 'ruby-debug' +Debugger.start(:post_mortem => true) +Debugger.settings[:autoeval] = true class GLMTest < Test::Unit::TestCase def test_glm_logit_truth assert_equal "Sanity is for the weak!", GLM::Logit.truth @@ -28,13 +30,15 @@ def test_linear iris = load_iris y = 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) + #x,y = GLM::Util.formatArrays(x, y) + x = GLM::Util.aa_to_gsl_matrix(x) + y = GSL::Vector.alloc(y) linear = GLM::Linear.new(x, y) theta, y_est = linear.ne_est(x) - assert ((y_est - y).map {|e| e ** 2}).reduce(:+)/y.row_size < 0.1 + assert ((y_est - y).map {|e| e ** 2}).norm < 0.1 end end