lib/rumale/polynomial_model/factorization_machine_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]) Confidence score per sample.
Calculate confidence scores for samples.
Calculate confidence scores for samples .
def decision_function(x)
        x = check_convert_sample_array(x)
        linear_term = @bias_term + x.dot(@weight_vec.transpose)
        factor_term = if multiclass_problem?
                        0.5 * (@factor_mat.dot(x.transpose)**2 - (@factor_mat**2).dot(x.transpose**2)).sum(1).transpose
                      else
                        0.5 * (@factor_mat.dot(x.transpose)**2 - (@factor_mat**2).dot(x.transpose**2)).sum(0)
                      end
        linear_term + factor_term
      end
def decision_function ( x ) x = check_convert_sample_array ( x ) linear_term = @bias_term + x . dot ( @weight_vec . transpose ) factor_term = if multiclass_problem? 0.5 * ( @factor_mat . dot ( x . transpose ) ** 2 - ( @factor_mat ** 2 ) . dot ( x . transpose ** 2 ) ) . sum ( 1 ) . transpose else 0.5 * ( @factor_mat . dot ( x . transpose ) ** 2 - ( @factor_mat ** 2 ) . dot ( x . transpose ** 2 ) ) . sum ( 0 ) end linear_term + factor_term end
Calculate confidence scores for samples.
Calculate confidence scores for samples .
[n_samples]) Confidence score per sample.
[ n_samples ] ) 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 .