F1< AS, PositiveClass > Class Template Reference

F1 is a metric of performance for classification algorithms that for binary classification is equal to $ 2 * precision * recall / (precision + recall) $. 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 F1. 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::F1< AS, PositiveClass >

F1 is a metric of performance for classification algorithms that for binary classification is equal to $ 2 * precision * recall / (precision + recall) $.

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

  1. Micro. The result is calculated by the above formula, but microaveraged precision and microaveraged recall are used.
  2. Macro. F1 is calculated for each class (with values used for calculation of macroaveraged precision and macroaveraged recall), and then the F1 values are averaged.

In the case of multiclass classification it is assumed that there are instances of every label from 0 to max(labels) among input data points.

The returned value for F1 will be zero if both precision and recall turn out to be zeros.

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 45 of file f1.hpp.

Member Function Documentation

◆ Evaluate()

static double Evaluate ( MLAlgorithm &  model,
const DataType &  data,
const arma::Row< size_t > &  labels 
)
static

Run classification and calculate F1.

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 64 of file f1.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/f1.hpp