lib/rumale/ensemble/gradient_boosting_regressor.rb
# Fit the model with given training data.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The training data to be used for fitting the model.
# @param y [Numo::DFloat] (shape: [n_samples]) The target values to be used for fitting the model.
# @return [GradientBoostingRegressor] The learned regressor itself.
Fit the model with given training data.
Fit the model with given training data .
def fit(x, y)
        x = check_convert_sample_array(x)
        y = check_convert_tvalue_array(y)
        check_sample_tvalue_size(x, y)
        n_features = x.shape[1]
        @params[:max_features] = n_features if @params[:max_features].nil?
        @params[:max_features] = [[1, @params[:max_features]].max, n_features].min
        n_outputs = y.shape[1].nil? ? 1 : y.shape[1]
        @base_predictions = n_outputs > 1 ? y.mean(0) : y.mean
        @estimators = if n_outputs > 1
                        multivar_estimators(x, y)
                      else
                        partial_fit(x, y, @base_predictions)
                      end
        @feature_importances = if n_outputs > 1
                                 multivar_feature_importances
                               else
                                 @estimators.map(&:feature_importances).reduce(&:+)
                               end
        self
      end
def fit ( x , y ) x = check_convert_sample_array ( x ) y = check_convert_tvalue_array ( y ) check_sample_tvalue_size ( x , y ) n_features = x . shape [ 1 ] @params [ :max_features ] = n_features if @params [ :max_features ] . nil? @params [ :max_features ] = [ [ 1 , @params [ :max_features ] ] . max , n_features ] . min n_outputs = y . shape [ 1 ] . nil? ? 1 : y . shape [ 1 ] @base_predictions = n_outputs > 1 ? y . mean ( 0 ) : y . mean @estimators = if n_outputs > 1 multivar_estimators ( x , y ) else partial_fit ( x , y , @base_predictions ) end @feature_importances = if n_outputs > 1 multivar_feature_importances else @estimators . map ( & :feature_importances ) . reduce ( & :+ ) end self end
Fit the model with given training data.
Fit the model with given training data .
# initialize some variables. # train regressor. # calculate feature importances.
The learned regressor itself.
The learned regressor itself .
GradientBoostingRegressor
x
[n_samples, n_features]) The training data to be used for fitting the model.
[ n_samples n_features ] ) The training data to be used for fitting the model .
y
[n_samples]) The target values to be used for fitting the model.
[ n_samples ] ) The target values to be used for fitting the model .