Sha256: 8fd2e3184c09e3a9a22fa1c7b7db20b72ef565492c0df56aa3af5a2c2e307cb7

Contents?: true

Size: 511 Bytes

Versions: 3

Compression:

Stored size: 511 Bytes

Contents

#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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decisiontree-0.1.0 test/test_decisiontree.rb
decisiontree-0.2.0 test/test_decisiontree.rb
decisiontree-0.3.0 test/test_decisiontree.rb