mirror of
https://github.com/dkam/decisiontree.git
synced 2025-12-27 22:54:52 +00:00
Fix examples in README.md
`test` variables were missing, second example referenced missing `data` variable.
This commit is contained in:
14
README.md
14
README.md
@@ -37,8 +37,9 @@ training = [
|
|||||||
dec_tree = DecisionTree::ID3Tree.new(attributes, training, 'sick', :continuous)
|
dec_tree = DecisionTree::ID3Tree.new(attributes, training, 'sick', :continuous)
|
||||||
dec_tree.train
|
dec_tree.train
|
||||||
|
|
||||||
decision = dec_tree.predict([37, 'sick'])
|
test = [37, 'sick']
|
||||||
puts "Predicted: #{decision} ... True decision: #{test.last}";
|
decision = dec_tree.predict(test)
|
||||||
|
puts "Predicted: #{decision} ... True decision: #{test.last}"
|
||||||
|
|
||||||
# => Predicted: sick ... True decision: sick
|
# => Predicted: sick ... True decision: sick
|
||||||
|
|
||||||
@@ -55,11 +56,14 @@ training = [
|
|||||||
[1, "red", "not angry"]
|
[1, "red", "not angry"]
|
||||||
]
|
]
|
||||||
|
|
||||||
dec_tree = DecisionTree::ID3Tree.new(labels, data, "not angry", color: :discrete, hunger: :continuous)
|
dec_tree = DecisionTree::ID3Tree.new(labels, training, "not angry", color: :discrete, hunger: :continuous)
|
||||||
dec_tree.train
|
dec_tree.train
|
||||||
|
|
||||||
decision = dec_tree.predict([7, "red"])
|
test = [7, "red", "angry"]
|
||||||
puts "Predicted: #{decision} ... True decision: #{test.last}";
|
decision = dec_tree.predict(test)
|
||||||
|
puts "Predicted: #{decision} ... True decision: #{test.last}"
|
||||||
|
|
||||||
|
# => Predicted: angry ... True decision: angry
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
Reference in New Issue
Block a user