lib/rumale/linear_model/lasso.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, n_outputs]) The target values to be used for fitting the model.
# @return [Lasso] 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_outputs = y.shape[1].nil? ? 1 : y.shape[1]
        n_features = x.shape[1]
        if n_outputs > 1
          @weight_vec = Numo::DFloat.zeros(n_outputs, n_features)
          @bias_term = Numo::DFloat.zeros(n_outputs)
          if enable_parallel?
            models = parallel_map(n_outputs) { |n| partial_fit(x, y[true, n]) }
            n_outputs.times { |n| @weight_vec[n, true], @bias_term[n] = models[n] }
          else
            n_outputs.times { |n| @weight_vec[n, true], @bias_term[n] = partial_fit(x, y[true, n]) }
          end
        else
          @weight_vec, @bias_term = partial_fit(x, y)
        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_outputs = y . shape [ 1 ] . nil? ? 1 : y . shape [ 1 ] n_features = x . shape [ 1 ] if n_outputs > 1 @weight_vec = Numo :: DFloat . zeros ( n_outputs , n_features ) @bias_term = Numo :: DFloat . zeros ( n_outputs ) if enable_parallel? models = parallel_map ( n_outputs ) { | n | partial_fit ( x , y [ true , n ] ) } n_outputs . times { | n | @weight_vec [ n , true ] , @bias_term [ n ] = models [ n ] } else n_outputs . times { | n | @weight_vec [ n , true ] , @bias_term [ n ] = partial_fit ( x , y [ true , n ] ) } end else @weight_vec , @bias_term = partial_fit ( x , y ) end self end
Fit the model with given training data.
Fit the model with given training data .
The learned regressor itself.
The learned regressor itself .
Lasso
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, n_outputs]) The target values to be used for fitting the model.
[ n_samples n_outputs ] ) The target values to be used for fitting the model .