enhance documentation

This commit is contained in:
Marshall Shen
2013-03-22 13:01:24 -05:00
parent 7bf93a3a5e
commit 5fa6d1c181

View File

@@ -41,6 +41,25 @@ decision = dec_tree.predict([37, 'sick'])
puts "Predicted: #{decision} ... True decision: #{test.last}";
# => Predicted: sick ... True decision: sick
# Specify type ("discrete" or "continuous") in the training data
labels = ["hunger", "color"]
training = [
[8, "red", "angry"],
[6, "red", "angry"],
[7, "red", "angry"],
[7, "blue", "not angry"],
[2, "red", "not angry"],
[3, "blue", "not angry"],
[2, "blue", "not angry"],
[1, "red", "not angry"]
]
dec_tree = DecisionTree::ID3Tree.new(labels, data, "not angry", color: :discrete, hunger: :continuous)
dec_tree.train
decision = dec_tree.predict([7, "red"]
puts "Predicted: #{decision} ... True decision: #{test.last}";
```
## License