lib/rumale/ensemble/stacking_classifier.rb
# Transform the given data with the learned model.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to be transformed with the learned model.
# @return [Numo::DFloat] (shape: [n_samples, n_components]) The meta features for samples.
Transform the given data with the learned model.
Transform the given data with the learned model .
def transform(x)
        x = check_convert_sample_array(x)
        n_samples = x.shape[0]
        n_components = @output_size.values.inject(:+)
        z = Numo::DFloat.zeros(n_samples, n_components)
        f_start = 0
        @estimators.each_key do |name|
          f_last = f_start + @output_size[name]
          f_position = @output_size[name] == 1 ? f_start : f_start...f_last
          z[true, f_position] = @estimators[name].public_send(@stack_method[name], x)
          f_start = f_last
        end
        z = Numo::NArray.hstack([z, x]) if @params[:passthrough]
        z
      end
def transform ( x ) x = check_convert_sample_array ( x ) n_samples = x . shape [ 0 ] n_components = @output_size . values . inject ( :+ ) z = Numo :: DFloat . zeros ( n_samples , n_components ) f_start = 0 @estimators . each_key do | name | f_last = f_start + @output_size [ name ] f_position = @output_size [ name ] == 1 ? f_start : f_start ... f_last z [ true , f_position ] = @estimators [ name ] . public_send ( @stack_method [ name ] , x ) f_start = f_last end z = Numo :: NArray . hstack ( [ z , x ] ) if @params [ :passthrough ] z end
Transform the given data with the learned model.
Transform the given data with the learned model .
[n_samples, n_components]) The meta features for samples.
[ n_samples n_components ] ) The meta features for samples .
Numo::DFloat
x
[n_samples, n_features]) The samples to be transformed with the learned model.
[ n_samples n_features ] ) The samples to be transformed with the learned model .