lib/rumale/ensemble/gradient_boosting_regressor.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 values.
# @return [Numo::Int32] (shape: [n_samples, n_estimators]) 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_outputs = @estimators.first.is_a?(Array) ? @estimators.size : 1
        leaf_ids = if n_outputs > 1
                     Array.new(n_outputs) { |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_outputs = @estimators . first . is_a? ( Array ) ? @estimators . size : 1 leaf_ids = if n_outputs > 1 Array . new ( n_outputs ) { | 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]) Leaf index for sample.
[ n_samples n_estimators ] ) Leaf index for sample .
Numo::Int32
x
[n_samples, n_features]) The samples to predict the values.
[ n_samples n_features ] ) The samples to predict the values .