Sha256: 480856f447bfad2d7214c82d22d21ee56e227decc0ad7a09970a5889495a67df
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
$:.unshift File.join(File.dirname(__FILE__),'..','lib') require 'test/unit' require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/zero_r' class ZeroRTest < Test::Unit::TestCase include Ai4r::Classifiers @@data_examples = [ ['New York', '<30', 'M', 'Y'], ['Chicago', '<30', 'M', 'Y'], ['New York', '<30', 'M', 'Y'], ['New York', '[30-50)', 'F', 'N'], ['Chicago', '[30-50)', 'F', 'Y'], ['New York', '[30-50)', 'F', 'N'], ['Chicago', '[50-80]', 'M', 'N'], ] @@data_labels = [ 'city', 'age_range', 'gender', 'marketing_target' ] def test_build assert_raise(ArgumentError) { ZeroR.new.build(nil) } assert_raise(ArgumentError) { ZeroR.new.build([]) } classifier = ZeroR.new.build(@@data_examples) assert_equal("Y", classifier.class_value) assert_equal("attribute_1", classifier.data_labels.first) assert_equal("class_value", classifier.data_labels.last) classifier = ZeroR.new.build(@@data_examples, @@data_labels) assert_equal("Y", classifier.class_value) assert_equal("city", classifier.data_labels.first) assert_equal("marketing_target", classifier.data_labels.last) end def test_eval classifier = ZeroR.new.build(@@data_examples) assert_equal('Y', classifier.eval(@@data_examples.first) ) assert_equal('Y', classifier.eval(@@data_examples.last) ) end def test_to_s classifier = ZeroR.new.build(@@data_examples, @@data_labels) marketing_target = nil eval(classifier.to_s) assert_equal('Y', marketing_target) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ai4r-1.2 | test/classifiers/zero_r_test.rb |