Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'rubygems'
require 'decisiontree'
training = [
[98.7, 'healthy'],
[99.1, 'healthy'],
[99.5, 'sick'],
[100.5, 'sick'],
[102.5, 'crazy sick'],
[107.5, 'dead'],
[106.5, 'crazy sick'],
]
attributes = ['Temp']
dec_tree = DecisionTree::ID3Tree.new(attributes, training, 'sick', :continuous)
dec_tree.train
test = [105.5]
decision = dec_tree.predict(test)
puts "Prediction: #{decision}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment