Sha256: 30274ad1926929780551da447ff0f4bc1a5aecd5a7207caac16480b7246068fb
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
require 'test/unit' require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/zero_r' require File.dirname(__FILE__) + '/../../lib/ai4r/data/data_set' class ZeroRTest < Test::Unit::TestCase include Ai4r::Classifiers include Ai4r::Data @@data_examples = [ ['New York', '[30-50)', 'F', 'N'], ['New York', '<30', 'M', 'Y'], ['Chicago', '<30', 'M', 'Y'], ['New York', '<30', 'M', 'Y'], ['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(DataSet.new) } classifier = ZeroR.new.build(DataSet.new(:data_items => @@data_examples)) assert_equal("Y", classifier.class_value) assert_equal("attribute_1", classifier.data_set.data_labels.first) assert_equal("class_value", classifier.data_set.data_labels.last) classifier = ZeroR.new.build(DataSet.new(:data_items => @@data_examples, :data_labels => @@data_labels)) assert_equal("Y", classifier.class_value) assert_equal("city", classifier.data_set.data_labels.first) assert_equal("marketing_target", classifier.data_set.data_labels.last) end def test_eval classifier = ZeroR.new.build(DataSet.new(:data_items => @@data_examples)) assert_equal('Y', classifier.eval(@@data_examples.first) ) assert_equal('Y', classifier.eval(@@data_examples.last) ) end def test_get_rules classifier = ZeroR.new.build(DataSet.new(:data_items => @@data_examples, :data_labels => @@data_labels)) marketing_target = nil eval(classifier.get_rules) assert_equal('Y', marketing_target) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nirvdrum-ai4r-1.9.1 | test/classifiers/zero_r_test.rb |