lib/rumale/tree/decision_tree_classifier.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::Int32] (shape: [n_samples]) The labels to be used for fitting the model.
# @return [DecisionTreeClassifier] The learned classifier 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_label_array(y)
        check_sample_label_size(x, y)
        n_samples, n_features = x.shape
        @params[:max_features] = n_features if @params[:max_features].nil?
        @params[:max_features] = [@params[:max_features], n_features].min
        uniq_y = y.to_a.uniq.sort
        @classes = Numo::Int32.asarray(uniq_y)
        @n_leaves = 0
        @leaf_labels = []
        @sub_rng = @rng.dup
        build_tree(x, y.map { |v| uniq_y.index(v) })
        eval_importance(n_samples, n_features)
        @leaf_labels = Numo::Int32[*@leaf_labels]
        self
      end
def fit ( x , y ) x = check_convert_sample_array ( x ) y = check_convert_label_array ( y ) check_sample_label_size ( x , y ) n_samples , n_features = x . shape @params [ :max_features ] = n_features if @params [ :max_features ] . nil? @params [ :max_features ] = [ @params [ :max_features ] , n_features ] . min uniq_y = y . to_a . uniq . sort @classes = Numo :: Int32 . asarray ( uniq_y ) @n_leaves = 0 @leaf_labels = [ ] @sub_rng = @rng . dup build_tree ( x , y . map { | v | uniq_y . index ( v ) } ) eval_importance ( n_samples , n_features ) @leaf_labels = Numo :: Int32 [ * @leaf_labels ] self end
Fit the model with given training data.
Fit the model with given training data .
The learned classifier itself.
The learned classifier itself .
DecisionTreeClassifier
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 labels to be used for fitting the model.
[ n_samples ] ) The labels to be used for fitting the model .