Class: Rumale::Tree::ExtraTreeClassifier

Inherits:
DecisionTreeClassifier show all
Defined in:
rumale-tree/lib/rumale/tree/extra_tree_classifier.rb

Overview

ExtraTreeClassifier is a class that implements extra randomized tree for classification.

Reference

  • Geurts, P., Ernst, D., and Wehenkel, L., “Extremely randomized trees,” Machine Learning, vol. 63 (1), pp. 3–42, 2006.

Examples:

require 'rumale/tree/extra_tree_classifier'

estimator =
  Rumale::Tree::ExtraTreeClassifier.new(
    criterion: 'gini', max_depth: 3, max_leaf_nodes: 10, min_samples_leaf: 5, random_seed: 1)
estimator.fit(training_samples, traininig_labels)
results = estimator.predict(testing_samples)

Instance Attribute Summary collapse

Attributes inherited from Base::Estimator

#params

Instance Method Summary collapse

Methods inherited from DecisionTreeClassifier

#fit, #predict, #predict_proba

Methods included from Base::Classifier

#fit, #predict, #score

Methods inherited from BaseDecisionTree

#apply

Constructor Details

#initialize(criterion: 'gini', max_depth: nil, max_leaf_nodes: nil, min_samples_leaf: 1, max_features: nil, random_seed: nil) ⇒ ExtraTreeClassifier

Create a new classifier with extra randomized tree algorithm.

Parameters:

  • criterion (String) (defaults to: 'gini')

    The function to evaluate spliting point. Supported criteria are ‘gini’ and ‘entropy’.

  • max_depth (Integer) (defaults to: nil)

    The maximum depth of the tree. If nil is given, extra tree grows without concern for depth.

  • max_leaf_nodes (Integer) (defaults to: nil)

    The maximum number of leaves on extra tree. If nil is given, number of leaves is not limited.

  • min_samples_leaf (Integer) (defaults to: 1)

    The minimum number of samples at a leaf node.

  • max_features (Integer) (defaults to: nil)

    The number of features to consider when searching optimal split point. If nil is given, split process considers all features.

  • random_seed (Integer) (defaults to: nil)

    The seed value using to initialize the random generator. It is used to randomly determine the order of features when deciding spliting point.



53
54
55
56
# File 'rumale-tree/lib/rumale/tree/extra_tree_classifier.rb', line 53

def initialize(criterion: 'gini', max_depth: nil, max_leaf_nodes: nil, min_samples_leaf: 1, max_features: nil,
               random_seed: nil)
  super
end

Instance Attribute Details

#classesNumo::Int32 (readonly)

Return the class labels.

Returns:

  • (Numo::Int32)

    (size: n_classes)



23
24
25
# File 'rumale-tree/lib/rumale/tree/extra_tree_classifier.rb', line 23

def classes
  @classes
end

#feature_importancesNumo::DFloat (readonly)

Return the importance for each feature.

Returns:

  • (Numo::DFloat)

    (size: n_features)



27
28
29
# File 'rumale-tree/lib/rumale/tree/extra_tree_classifier.rb', line 27

def feature_importances
  @feature_importances
end

#leaf_labelsNumo::Int32 (readonly)

Return the labels assigned each leaf.

Returns:

  • (Numo::Int32)

    (size: n_leafs)



39
40
41
# File 'rumale-tree/lib/rumale/tree/extra_tree_classifier.rb', line 39

def leaf_labels
  @leaf_labels
end

#rngRandom (readonly)

Return the random generator for random selection of feature index.

Returns:

  • (Random)


35
36
37
# File 'rumale-tree/lib/rumale/tree/extra_tree_classifier.rb', line 35

def rng
  @rng
end

#treeNode (readonly)

Return the learned tree.

Returns:



31
32
33
# File 'rumale-tree/lib/rumale/tree/extra_tree_classifier.rb', line 31

def tree
  @tree
end