Sha256: b9e387df46426e0c595591053e02f3a106d6039757c2872b2661516b09a9ae32

Contents?: true

Size: 822 Bytes

Versions: 19

Compression:

Stored size: 822 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
require 'rbbt/vector/model/svm'
require 'rbbt/util/R'
require 'test/unit'

class TestSVMModel < Test::Unit::TestCase

  def test_model
    text =<<-EOF
1 0;1;1
1 1;0;1
1 1;1;1
1 0;1;1
1 1;1;1
0 0;1;0
0 1;0;0
0 0;1;0
0 1;0;0
    EOF

    TmpFile.with_file() do |dir|
      FileUtils.mkdir_p dir
      model = SVMModel.new(dir)

      model.extract_features = Proc.new{|element|
        element.split(";")
      }

      text.split(/\n/).each do |line|
        label, features = line.split(" ")
        model.add(features, label)
      end

      model.train

      assert model.eval("1;1;1") == "1"
      assert model.eval("0;0;0") == "0"

      assert_equal [true, false], model.eval_list(%w(1;1;1 0;0;0)).collect{|v| v == "1"}
    end
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rbbt-dm-1.3.2 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.3.0 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.2.10 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.2.9 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.2.7 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.2.6 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.2.4 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.2.3 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.2.1 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.1.63 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.1.62 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.1.61 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.1.60 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.1.59 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.1.58 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.1.57 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.1.56 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.1.55 test/rbbt/vector/model/test_svm.rb
rbbt-dm-1.1.54 test/rbbt/vector/model/test_svm.rb