mirror of
https://github.com/dkam/decisiontree.git
synced 2025-12-28 15:14:52 +00:00
importing from rubyforge & cleanup
This commit is contained in:
26
test/test_decisiontree.rb
Normal file
26
test/test_decisiontree.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
#The MIT License
|
||||
|
||||
###Copyright (c) 2007 Ilya Grigorik <ilya AT fortehost DOT com>
|
||||
|
||||
require File.dirname(__FILE__) + '/test_helper.rb'
|
||||
require 'decisiontree'
|
||||
|
||||
class TestDecisionTree < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@labels = %w(sun rain)
|
||||
@data = [
|
||||
[1, 0, 1],
|
||||
[0, 1, 0]
|
||||
]
|
||||
end
|
||||
|
||||
def test_truth
|
||||
dec_tree = DecisionTree::ID3Tree.new(@labels, @data, 1, :discrete)
|
||||
dec_tree.train
|
||||
|
||||
assert 1, dec_tree.predict([1, 0])
|
||||
assert 0, dec_tree.predict([0, 1])
|
||||
end
|
||||
end
|
||||
|
||||
2
test/test_helper.rb
Normal file
2
test/test_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
require 'test/unit'
|
||||
require File.dirname(__FILE__) + '/../lib/decisiontree'
|
||||
Reference in New Issue
Block a user