Class: Rumale::Tree::Node

Inherits:
Object
  • Object
show all
Defined in:
rumale-tree/lib/rumale/tree/node.rb

Overview

Node is a class that implements node used for construction of decision tree. This class is used for internal data structures.

Instance Method Summary collapse

Constructor Details

#initialize(depth: 0, impurity: 0.0, n_samples: 0, probs: 0.0, leaf: false, leaf_id: nil, left: nil, right: nil, feature_id: 0, threshold: 0.0) ⇒ Node

Create a new node for decision tree.

Parameters:

  • depth (Integer) (defaults to: 0)

    The depth of the node in tree.

  • impurity (Float) (defaults to: 0.0)

    The impurity of the node.

  • n_samples (Integer) (defaults to: 0)

    The number of the samples in the node.

  • probs (Float) (defaults to: 0.0)

    The probability of the node.

  • leaf (Boolean) (defaults to: false)

    The flag indicating whether the node is a leaf.

  • leaf_id (Integer) (defaults to: nil)

    The leaf index of the node.

  • left (Node) (defaults to: nil)

    The left node.

  • right (Node) (defaults to: nil)

    The right node.

  • feature_id (Integer) (defaults to: 0)

    The feature index used for evaluation.

  • threshold (Float) (defaults to: 0.0)

    The threshold value of the feature for splitting the node.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'rumale-tree/lib/rumale/tree/node.rb', line 23

def initialize(depth: 0, impurity: 0.0, n_samples: 0, probs: 0.0,
               leaf: false, leaf_id: nil,
               left: nil, right: nil, feature_id: 0, threshold: 0.0)
  @depth = depth
  @impurity = impurity
  @n_samples = n_samples
  @probs = probs
  @leaf = leaf
  @leaf_id = leaf_id
  @left = left
  @right = right
  @feature_id = feature_id
  @threshold = threshold
end