cleanup, updated tests

This commit is contained in:
Ilya Grigorik
2009-02-22 23:47:24 -05:00
parent 966aa2e69c
commit 009764dd21
4 changed files with 16 additions and 344 deletions

View File

@@ -1,26 +1,22 @@
#The MIT License
require 'test/helper.rb'
###Copyright (c) 2007 Ilya Grigorik <ilya AT fortehost DOT com>
describe DecisionTree::ID3Tree do
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]
it "should work with a discrete dataset" do
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 = DecisionTree::ID3Tree.new(labels, data, 1, :discrete)
dec_tree.train
assert 1, dec_tree.predict([1, 0])
assert 0, dec_tree.predict([0, 1])
dec_tree.predict([1,0]).should == 1
dec_tree.predict([0,1]).should == 0
end
it "should work with continuous dataset"
end