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...

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.

Definition at line 48 of file precision.hpp.

Member Function Documentation

◆ Evaluate()

static double 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

const bool NeedsMinimization = false
static

Information for hyper-parameter tuning code.

It indicates that we want to maximize the metric.

Definition at line 67 of file precision.hpp.


The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/core/cv/metrics/precision.hpp