Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (35 sloc) 818 Bytes
require "decisiontree"
# Defined methods
def rofl # Rolling on the floor laughing.
puts "BIANCA: Somebody help me up! I'm dying."
end
def fwtoj # Face with tears of joy.
puts "BIANCA: Somebody bring me a tissue!"
end
def relieved
puts "BIANCA: Man, that was weight loss!"
end
def nuetral
puts "BIANCA: And, what's your point?"
end
# Main decision tree
attributes = ["Joy"]
training = [
[ 0.3, 'neutral'],
[50.3, 'relieved'],
[75.3, 'fwtoj'],
[99.1, 'rofl'],
]
dec_tree = DecisionTree::ID3Tree.new(attribute, training, 'nuetral', :continuous)
dec_tree.train
test = [joy_num, 'relieved']
tone = dec_tree.predict(test)
if tone == 'relieved'
mood = relieved
elsif tone == 'fwtoj'
mood = fwtoj
elsif tone == 'rofl'
mood = rofl
elsif tone == 'nuetral'
mood = nuetral
end
You can’t perform that action at this time.