4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/idhja22/tree/node.rb', line 4
def build_node(dataset, attributes_available, depth, parent_probability = nil)
if(dataset.size < Idhja22.config.min_dataset_size)
return Idhja22::LeafNode.new(dataset.m_estimate(parent_probability), dataset.category_label)
end
if(dataset.terminating? && depth > 0) return Idhja22::LeafNode.new(dataset.m_estimate(parent_probability), dataset.category_label)
end
if(depth >= 3) return Idhja22::LeafNode.new(dataset.m_estimate(parent_probability), dataset.category_label)
end
if(attributes_available.empty?)
return Idhja22::LeafNode.new(dataset.m_estimate(parent_probability), dataset.category_label)
end
node = DecisionNode.build(dataset, attributes_available, depth, dataset.m_estimate(parent_probability))
return node
end
|