lib/rumale/ensemble/voting_classifier.rb
# Predict class labels for samples.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to predict the labels.
# @return [Numo::Int32] (shape: [n_samples]) The predicted class label per sample.
Predict class labels for samples.
Predict class labels for samples .
def predict(x)
        x = check_convert_sample_array(x)
        n_samples = x.shape[0]
        n_classes = @classes.size
        z = decision_function(x)
        predicted = z.max_index(axis: 1) - Numo::Int32.new(n_samples).seq * n_classes
        Numo::Int32.cast(@encoder.inverse_transform(predicted))
      end
def predict ( x ) x = check_convert_sample_array ( x ) n_samples = x . shape [ 0 ] n_classes = @classes . size z = decision_function ( x ) predicted = z . max_index ( axis : 1 ) - Numo :: Int32 . new ( n_samples ) . seq * n_classes Numo :: Int32 . cast ( @encoder . inverse_transform ( predicted ) ) end
Predict class labels for samples.
Predict class labels for samples .
[n_samples]) The predicted class label per sample.
[ n_samples ] ) The predicted class label per sample .
Numo::Int32
x
[n_samples, n_features]) The samples to predict the labels.
[ n_samples n_features ] ) The samples to predict the labels .