lib/rumale/ensemble/extra_trees_regressor.rb in rumale-0.13.8 vs lib/rumale/ensemble/extra_trees_regressor.rb in rumale-0.14.0
- old
+ new
@@ -50,13 +50,13 @@
# @param random_seed [Integer] The seed value using to initialize the random generator.
# It is used to randomly determine the order of features when deciding spliting point.
def initialize(n_estimators: 10,
criterion: 'mse', max_depth: nil, max_leaf_nodes: nil, min_samples_leaf: 1,
max_features: nil, n_jobs: nil, random_seed: nil)
- check_params_type_or_nil(Integer, max_depth: max_depth, max_leaf_nodes: max_leaf_nodes,
- max_features: max_features, n_jobs: n_jobs, random_seed: random_seed)
- check_params_integer(n_estimators: n_estimators, min_samples_leaf: min_samples_leaf)
+ check_params_numeric_or_nil(max_depth: max_depth, max_leaf_nodes: max_leaf_nodes,
+ max_features: max_features, n_jobs: n_jobs, random_seed: random_seed)
+ check_params_numeric(n_estimators: n_estimators, min_samples_leaf: min_samples_leaf)
check_params_string(criterion: criterion)
check_params_positive(n_estimators: n_estimators, max_depth: max_depth,
max_leaf_nodes: max_leaf_nodes, min_samples_leaf: min_samples_leaf,
max_features: max_features)
super
@@ -66,12 +66,12 @@
#
# @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 [ExtraTreesRegressor] 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)
# Initialize some variables.
n_features = x.shape[1]
@params[:max_features] = Math.sqrt(n_features).to_i unless @params[:max_features].is_a?(Integer)
@params[:max_features] = [[1, @params[:max_features]].max, n_features].min
@@ -96,19 +96,19 @@
# 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 value per sample.
def predict(x)
- check_sample_array(x)
+ x = check_convert_sample_array(x)
super
end
# Return the index of the leaf that each sample reached.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to assign each leaf.
# @return [Numo::Int32] (shape: [n_samples, n_estimators]) Leaf index for sample.
def apply(x)
- check_sample_array(x)
+ x = check_convert_sample_array(x)
super
end
# Dump marshal data.
# @return [Hash] The marshal data about ExtraTreesRegressor.