Class: Idhja22::Tree
Overview
The main entry class for a training, viewing and evaluating a decision tree.
Instance Attribute Summary collapse
Instance Method Summary
collapse
train, train_and_validate, train_and_validate_from_csv, train_from_csv, #validate
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
6
7
8
|
# File 'lib/idhja22/tree.rb', line 6
def root
@root
end
|
Instance Method Details
#==(other) ⇒ Object
21
22
23
|
# File 'lib/idhja22/tree.rb', line 21
def ==(other)
return self.root == other.root
end
|
#evaluate(query) ⇒ Object
25
26
27
|
# File 'lib/idhja22/tree.rb', line 25
def evaluate query
@root.evaluate(query)
end
|
#get_rules ⇒ Object
16
17
18
19
|
# File 'lib/idhja22/tree.rb', line 16
def get_rules
rules = root.get_rules
"if " + rules.join("\nelsif ")
end
|
#train(dataset, attributes_available) ⇒ Object
10
11
12
13
14
|
# File 'lib/idhja22/tree.rb', line 10
def train(dataset, attributes_available)
raise Idhja22::Dataset::InsufficientData, "require at least #{Idhja22.config.min_dataset_size} data points, only have #{dataset.size} in data set provided" if(dataset.size < Idhja22.config.min_dataset_size)
@root = Node.build_node(dataset, attributes_available, 0)
return self
end
|