File confusion_matrix.hpp

template<typename StatisticType>
struct ConfusionMatrix
#include <confusion_matrix.hpp>

A confusion matrix.

Template Parameters:

StatisticType – The type of the elements stored in the confusion matrix

Public Functions

inline ConfusionMatrix()
inline ConfusionMatrix<StatisticType> &operator=(const StatisticType &rhs)

Assigns a specific value to the elements of this confusion matrix.

Parameters:

rhs – A reference to the value to be assigned

Returns:

A reference to the modified confusion matrix

inline ConfusionMatrix<StatisticType> &operator+=(const StatisticType &rhs)

Adds a specific value to the elements of this confusion matrix.

Parameters:

rhs – A reference to the value to be added

Returns:

A reference to the modified confusion matrix

inline ConfusionMatrix<StatisticType> &operator+=(const ConfusionMatrix<StatisticType> &rhs)

Adds the elements of a given confusion matrix to the elements of this confusion matrix.

Parameters:

rhs – A reference to the confusion matrix, whose elements should be added

Returns:

A reference to the modified confusion matrix

inline ConfusionMatrix<StatisticType> &operator-=(const StatisticType &rhs)

Subtracts a specific value from the elements of this confusion matrix.

Parameters:

rhs – A reference to the value to be subtracted

Returns:

A reference to the modified confusion matrix

inline ConfusionMatrix<StatisticType> &operator-=(const ConfusionMatrix<StatisticType> &rhs)

Subtracts the elements of a given confusion matrix from the elements of this confusion matrix.

Parameters:

rhs – A reference to the confusion matrix, whose elements should be subtracted

Returns:

A reference to the modified confusion matrix

inline ConfusionMatrix<StatisticType> &operator*=(const StatisticType &rhs)

Multiplies the elements of this confusion matrix with a specific value.

Parameters:

rhs – A reference to the value to be multiplied by

Returns:

A reference to the modified confusion matrix

inline StatisticType &getElement(bool trueLabel, bool majorityLabel)

Returns a reference to a confusion matrix element, given the ground truth and a prediction.

Parameters:
  • trueLabel – The true label according to the ground truth

  • majorityLabel – The prediction of the default rule. The prediction is assumed to be the inverse

Returns:

A reference to a confusion matrix element

Public Members

StatisticType in

Irrelevant labels for which a rule predicts negatively.

StatisticType ip

Irrelevant labels for which a rule predicts positively.

StatisticType rn

Relevant labels for which a rule predicts negatively.

StatisticType rp

Relevant labels for which a rule predicts positively.

Friends

inline friend ConfusionMatrix<StatisticType> operator+(ConfusionMatrix<StatisticType> lhs, const StatisticType &rhs)

Creates and returns a new confusion matrix that results from adding a specific value to the elements of an existing confusion matrix.

Parameters:
  • lhs – The original confusion matrix

  • rhs – A reference to the value to be added

Returns:

The confusion matrix that has been created

inline friend ConfusionMatrix<StatisticType> operator+(ConfusionMatrix<StatisticType> lhs, const ConfusionMatrix<StatisticType> &rhs)

Creates and returns a new confusion matrix that results from adding the elements of a specific confusion matrix to the elements of an existing confusion matrix.

Parameters:
  • lhs – The original confusion matrix

  • rhs – A reference to the confusion matrix, whose elements should be added

Returns:

The confusion matrix that has been created

inline friend ConfusionMatrix<StatisticType> operator-(ConfusionMatrix<StatisticType> lhs, const StatisticType &rhs)

Creates and returns a new confusion matrix that results from subtracting a specific value from the elements of an existing confusion matrix.

Parameters:
  • lhs – The original confusion matrix

  • rhs – A reference to the value to be subtracted

Returns:

The confusion matrix that has been created

inline friend ConfusionMatrix<StatisticType> operator-(ConfusionMatrix<StatisticType> lhs, const ConfusionMatrix<StatisticType> &rhs)

Creates and returns a new confusion matrix that results from subtracting the elements of a specific confusion matrix from the elements of an existing confusion matrix.

Parameters:
  • lhs – The original confusion matrix

  • rhs – A reference to the value to be subtracted

Returns:

The confusion matrix that has been created

inline friend ConfusionMatrix<StatisticType> operator*(ConfusionMatrix<StatisticType> lhs, const StatisticType &rhs)

Creates and returns a new confusion matrix that results from multiplying the elements of an existing confusion matrix with a specific value.

Parameters:
  • lhs – The original confusion matrix

  • rhs – A reference to the value to be multiplied by

Returns:

The confusion matrix that has been created