mirror of
https://github.com/dkam/decisiontree.git
synced 2025-12-28 15:14:52 +00:00
cleanup, updated tests
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
require 'test/unit'
|
||||
require File.dirname(__FILE__) + '/../lib/decisiontree'
|
||||
Reference in New Issue
Block a user