slope 6.6.0
Loading...
Searching...
No Matches
slope::Accuracy Class Reference

Classification Accuracy scoring metric. More...

#include <score.h>

Inheritance diagram for slope::Accuracy:
Collaboration diagram for slope::Accuracy:

Public Member Functions

double eval (const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y, const std::unique_ptr< Loss > &loss) const override
double eval (const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y, const std::unique_ptr< Loss > &loss, const Eigen::VectorXd &observation_weights) const override
Public Member Functions inherited from slope::MaximizeScore
bool isWorse (double a, double b) const override
double initValue () const override
Public Member Functions inherited from slope::Score
std::function< bool(double, double)> getComparator () const

Additional Inherited Members

Static Public Member Functions inherited from slope::Score
static std::unique_ptr< Score > create (const std::string &metric)

Detailed Description

Classification Accuracy scoring metric.

Computes the proportion of correct predictions in classification problems. Inherits from MaximizeScore since higher accuracy values indicate better performance.

Accuracy = (number of correct predictions) / (total number of predictions)

For binary classification, predictions are thresholded at 0.5. For multi-class problems, the class with highest probability is selected as the prediction for each sample.

Definition at line 250 of file score.h.

Member Function Documentation

◆ eval() [1/2]

double slope::Accuracy::eval ( const Eigen::MatrixXd & eta,
const Eigen::MatrixXd & y,
const std::unique_ptr< Loss > & loss ) const
overridevirtual

Evaluates the classification accuracy between predictions and true labels.

Parameters
etaMatrix of model predictions/probabilities
yMatrix of true labels (one-hot encoded)
lossLoss function used to transform predictions if needed
Returns
Proportion of correct predictions (between 0 and 1)

Implements slope::Score.

◆ eval() [2/2]

double slope::Accuracy::eval ( const Eigen::MatrixXd & eta,
const Eigen::MatrixXd & y,
const std::unique_ptr< Loss > & loss,
const Eigen::VectorXd & observation_weights ) const
overridevirtual

Evaluates the metric with observation weights. Empty weights select the unweighted metric. Weights must be finite and nonnegative, and their sum must be positive. Multiplying every weight by a positive constant leaves the score unchanged. Custom metrics can override this overload; the default implementation accepts uniform weights only.

Reimplemented from slope::Score.


The documentation for this class was generated from the following file: