Class: HybridForest::Trees::LeafNode

Inherits:
Object
  • Object
show all
Defined in:
lib/hybridforest/trees/nodes/leaf_node.rb

Instance Method Summary collapse

Constructor Details

#initialize(instances) ⇒ LeafNode

Returns a new instance of LeafNode.



6
7
8
# File 'lib/hybridforest/trees/nodes/leaf_node.rb', line 6

def initialize(instances)
  @prediction = majority_vote(instances)
end

Instance Method Details

#classify(_instance) ⇒ Object



10
11
12
# File 'lib/hybridforest/trees/nodes/leaf_node.rb', line 10

def classify(_instance)
  @prediction
end


14
15
16
17
# File 'lib/hybridforest/trees/nodes/leaf_node.rb', line 14

def print_string(spacing = "")
  print spacing
  puts to_s
end

#to_sObject



19
20
21
# File 'lib/hybridforest/trees/nodes/leaf_node.rb', line 19

def to_s
  "Predict #{@prediction}"
end