mlpack
Static Public Member Functions | Static Public Attributes | List of all members
mlpack::cv::Precision< AS, PositiveClass > Class Template Reference

Precision is a metric of performance for classification algorithms that for binary classification is equal to \( tp / (tp + fp) \), where \( tp \) and \( fp \) are the numbers of true positives and false positives respectively. More...

#include <precision.hpp>

Static Public Member Functions

template<typename MLAlgorithm , typename DataType >
static double Evaluate (MLAlgorithm &model, const DataType &data, const arma::Row< size_t > &labels)
 Run classification and calculate precision. More...
 

Static Public Attributes

static const bool NeedsMinimization = false
 Information for hyper-parameter tuning code. More...
 

Detailed Description

template<AverageStrategy AS, size_t PositiveClass = 1>
class mlpack::cv::Precision< AS, PositiveClass >

Precision is a metric of performance for classification algorithms that for binary classification is equal to \( tp / (tp + fp) \), where \( tp \) and \( fp \) are the numbers of true positives and false positives respectively.

For multiclass classification the precision metric can be used with the following strategies for averaging.

  1. Micro. If there are \( N + 1 \) classes in total, the result is equal to

    \[ (tp_0 + tp_1 + \ldots + tp_N) / (tp_0 + tp_1 + \ldots + tp_N + fp_0 + fp_1 + \ldots + fp_N), \]

    where \( tp_i \) and \( fp_i \) are the numbers of true positives and false positives respectively for the class (label) \( i \).
  2. Macro. If there are \( N + 1 \) classes in total, the result is equal to the mean of the values

    \[ tp_0 / (tp_0 + fp_0), tp_1 / (tp_1 + fp_1), \ldots, tp_N / (tp_N + fp_N), \]

    where \( tp_i \) and \( fp_i \) are the numbers of true positives and false positives respectively for the class (label) \( i \).
Template Parameters
ASAn average strategy.
PositiveClassIn the case of binary classification (AS = Binary) positives are assumed to have labels equal to this value.

Member Function Documentation

◆ Evaluate()

template<AverageStrategy AS, size_t PC>
template<typename MLAlgorithm , typename DataType >
double mlpack::cv::Precision< AS, PC >::Evaluate ( MLAlgorithm &  model,
const DataType &  data,
const arma::Row< size_t > &  labels 
)
static

Run classification and calculate precision.

Parameters
modelA classification model.
dataColumn-major data containing test items.
labelsGround truth (correct) labels for the test items.

Member Data Documentation

◆ NeedsMinimization

template<AverageStrategy AS, size_t PositiveClass = 1>
const bool mlpack::cv::Precision< AS, PositiveClass >::NeedsMinimization = false
static

Information for hyper-parameter tuning code.

It indicates that we want to maximize the metric.


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