From 287ff7a685e6094108a507a0049b56cc3a32421d Mon Sep 17 00:00:00 2001 From: Danielius Date: Sun, 22 Nov 2015 19:12:51 +0200 Subject: [PATCH] Initialize attributes and typo fix --- examples/discrete-id3.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/discrete-id3.rb b/examples/discrete-id3.rb index ef44020..6f06c79 100644 --- a/examples/discrete-id3.rb +++ b/examples/discrete-id3.rb @@ -5,6 +5,8 @@ require 'decisiontree' # Read in the training data training = [] +attributes = nil + File.open('data/discrete-training.txt', 'r').each_line do |line| data = line.strip.split(',') attributes ||= data @@ -45,7 +47,7 @@ File.open('data/discrete-test.txt', 'r').each_line do |line| v end end - training.push(test_data) + test.push(test_data) end # Let the tree predict the output and compare it to the true specified value