Initialize attributes and typo fix

This commit is contained in:
Danielius
2015-11-22 19:12:51 +02:00
parent 2155771683
commit 287ff7a685

View File

@@ -5,6 +5,8 @@ require 'decisiontree'
# Read in the training data # Read in the training data
training = [] training = []
attributes = nil
File.open('data/discrete-training.txt', 'r').each_line do |line| File.open('data/discrete-training.txt', 'r').each_line do |line|
data = line.strip.split(',') data = line.strip.split(',')
attributes ||= data attributes ||= data
@@ -45,7 +47,7 @@ File.open('data/discrete-test.txt', 'r').each_line do |line|
v v
end end
end end
training.push(test_data) test.push(test_data)
end end
# Let the tree predict the output and compare it to the true specified value # Let the tree predict the output and compare it to the true specified value