Skip to content

Commit

Permalink
Merge branch 'dvisockas-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
igrigorik committed Nov 24, 2015
2 parents 15394f8 + 823dd5e commit 4811a51
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/continuous-id3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# Read in the training data
training = []
attributes = nil

File.open('data/continuous-training.txt', 'r').each_line do |line|
data = line.strip.chomp('.').split(',')
attributes ||= data
Expand Down
4 changes: 3 additions & 1 deletion examples/discrete-id3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# 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
Expand Down Expand Up @@ -45,7 +47,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion lib/decisiontree/id3_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def build_tree(tree = @tree)
end
label_text = "#{key} ''"
if type(attr[0].attribute) == :continuous
label_text.gsub!("''", attr[0].threshold)
label_text.gsub!("''", attr[0].threshold.to_s)
end

[parent_text, child_text, label_text]
Expand Down

0 comments on commit 4811a51

Please sign in to comment.