lib/rumale/ensemble/voting_classifier.rb
# Calculate confidence scores for samples.
#
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to compute the scores.
# @return [Numo::DFloat] (shape: [n_samples, n_classes]) The confidence score per sample.
Calculate confidence scores for samples.
Calculate confidence scores for samples .
def decision_function(x)
        x = check_convert_sample_array(x)
        return predict_proba(x) if soft_voting?
        n_samples = x.shape[0]
        n_classes = @classes.size
        z = Numo::DFloat.zeros(n_samples, n_classes)
        @estimators.each do |name, estimator|
          estimator.predict(x).to_a.each_with_index { |c, i| z[i, c] += @params[:weights][name] }
        end
        z
      end
def decision_function ( x ) x = check_convert_sample_array ( x ) return predict_proba ( x ) if soft_voting? n_samples = x . shape [ 0 ] n_classes = @classes . size z = Numo :: DFloat . zeros ( n_samples , n_classes ) @estimators . each do | name , estimator | estimator . predict ( x ) . to_a . each_with_index { | c , i | z [ i , c ] += @params [ :weights ] [ name ] } end z end
Calculate confidence scores for samples.
Calculate confidence scores for samples .
[n_samples, n_classes]) The confidence score per sample.
[ n_samples n_classes ] ) The confidence score per sample .
Numo::DFloat
x
[n_samples, n_features]) The samples to compute the scores.
[ n_samples n_features ] ) The samples to compute the scores .