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