lib/rumale/linear_model/lasso.rb in rumale-0.13.8 vs lib/rumale/linear_model/lasso.rb in rumale-0.14.0
- old
+ new
@@ -46,26 +46,25 @@
# If zero or less is given, it becomes equal to the number of processors.
# This parameter is ignored if the Parallel gem is not loaded.
# @param random_seed [Integer] The seed value using to initialize the random generator.
def initialize(reg_param: 1.0, fit_bias: false, bias_scale: 1.0, max_iter: 1000, batch_size: 10, optimizer: nil,
n_jobs: nil, random_seed: nil)
- check_params_float(reg_param: reg_param, bias_scale: bias_scale)
- check_params_integer(max_iter: max_iter, batch_size: batch_size)
+ check_params_numeric(reg_param: reg_param, bias_scale: bias_scale, max_iter: max_iter, batch_size: batch_size)
check_params_boolean(fit_bias: fit_bias)
- check_params_type_or_nil(Integer, n_jobs: n_jobs, random_seed: random_seed)
+ check_params_numeric_or_nil(n_jobs: n_jobs, random_seed: random_seed)
check_params_positive(reg_param: reg_param, max_iter: max_iter, batch_size: batch_size)
super
end
# 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::Int32] (shape: [n_samples, n_outputs]) The target values to be used for fitting the model.
# @return [Lasso] The learned regressor itself.
def fit(x, y)
- check_sample_array(x)
- check_tvalue_array(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]
@@ -87,10 +86,10 @@
# Predict values for samples.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to predict the values.
# @return [Numo::DFloat] (shape: [n_samples, n_outputs]) Predicted values per sample.
def predict(x)
- check_sample_array(x)
+ x = check_convert_sample_array(x)
x.dot(@weight_vec.transpose) + @bias_term
end
# Dump marshal data.
# @return [Hash] The marshal data about Lasso.