lib/rumale/ensemble/gradient_boosting_classifier.rb
# Return the index of the leaf that each sample reached.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to predict the labels.
# @return [Numo::Int32] (shape: [n_samples, n_estimators, n_classes]) Leaf index for sample.
Return the index of the leaf that each sample reached.
Return the index of the leaf that each sample reached .
def apply(x)
        x = check_convert_sample_array(x)
        n_classes = @classes.size
        leaf_ids = if n_classes > 2
                     Array.new(n_classes) { |n| @estimators[n].map { |tree| tree.apply(x) } }
                   else
                     @estimators.map { |tree| tree.apply(x) }
                   end
        Numo::Int32[*leaf_ids].transpose.dup
      end
def apply ( x ) x = check_convert_sample_array ( x ) n_classes = @classes . size leaf_ids = if n_classes > 2 Array . new ( n_classes ) { | n | @estimators [ n ] . map { | tree | tree . apply ( x ) } } else @estimators . map { | tree | tree . apply ( x ) } end Numo :: Int32 [ * leaf_ids ] . transpose . dup end
Return the index of the leaf that each sample reached.
Return the index of the leaf that each sample reached .
[n_samples, n_estimators, n_classes]) Leaf index for sample.
[ n_samples n_estimators n_classes ] ) Leaf index for sample .
Numo::Int32
x
[n_samples, n_features]) The samples to predict the labels.
[ n_samples n_features ] ) The samples to predict the labels .