Class: Rumale::Tree::VRTreeRegressor

Inherits:
DecisionTreeRegressor show all
Defined in:
rumale-tree/lib/rumale/tree/vr_tree_regressor.rb

Overview

VRTreeRegressor is a class that implements Variable-Random (VR) tree for regression.

Reference

  • Liu, F. T., Ting, K. M., Yu, Y., and Zhou, Z. H., “Spectrum of Variable-Random Trees,” Journal of Artificial Intelligence Research, vol. 32, pp. 355–384, 2008.

Examples:

require 'rumale/tree/vr_tree_regressor'

estimator =
  Rumale::Tree::VRTreeRegressor.new(
    max_depth: 3, max_leaf_nodes: 10, min_samples_leaf: 5, random_seed: 1)
estimator.fit(training_samples, traininig_values)
results = estimator.predict(testing_samples)

Instance Attribute Summary collapse

Attributes inherited from Base::Estimator

#params

Instance Method Summary collapse

Methods inherited from DecisionTreeRegressor

#fit, #predict

Methods included from Base::Regressor

#fit, #predict, #score

Methods inherited from BaseDecisionTree

#apply

Constructor Details

#initialize(criterion: 'mse', alpha: 0.5, max_depth: nil, max_leaf_nodes: nil, min_samples_leaf: 1, max_features: nil, random_seed: nil) ⇒ VRTreeRegressor

Create a new regressor with variable-random tree algorithm.

Parameters:

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

    The function to evaluate spliting point. Supported criteria are ‘mae’ and ‘mse’.

  • alpha (Float) (defaults to: 0.5)

    The probability of choosing a deterministic or random spliting point. If 1.0 is given, the tree is the same as the normal decision tree.

  • max_depth (Integer) (defaults to: nil)

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

  • max_leaf_nodes (Integer) (defaults to: nil)

    The maximum number of leaves on variable-random 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.



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

def initialize(criterion: 'mse', alpha: 0.5, max_depth: nil, max_leaf_nodes: nil, min_samples_leaf: 1, max_features: nil,
               random_seed: nil)
  super(criterion: criterion, max_depth: max_depth, max_leaf_nodes: max_leaf_nodes, min_samples_leaf: min_samples_leaf,
        max_features: max_features, random_seed: random_seed)
  @params[:alpha] = alpha.clamp(0.0, 1.0)
end

Instance Attribute Details

#feature_importancesNumo::DFloat (readonly)

Return the importance for each feature.

Returns:

  • (Numo::DFloat)

    (size: n_features)



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

def feature_importances
  @feature_importances
end

#leaf_valuesNumo::DFloat (readonly)

Return the values assigned each leaf.

Returns:

  • (Numo::DFloat)

    (shape: [n_leafs, n_outputs])



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

def leaf_values
  @leaf_values
end

#rngRandom (readonly)

Return the random generator for random selection of feature index.

Returns:

  • (Random)


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

def rng
  @rng
end

#treeNode (readonly)

Return the learned tree.

Returns:



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

def tree
  @tree
end