Skip to main content

MLCore::BinaryClassificationMetrics

MLCore::BinaryClassificationMetrics

Metrics for a binary (two-class) classification problem. More…

#include <ClassificationMetrics.hpp>

Public Functions

Name
bool isValid() const
Check if any predictions were counted.
std::size_t getTotalPredictions() const
Total number of predictions (TP + TN + FP + FN).

Public Attributes

Name
double accuracy
(TP + TN) / Total
double sensitivity
TP / (TP + FN) — also called recall.
double specificity
TN / (TN + FP).
double dice_score
2·TP / (2·TP + FP + FN) — also called F1
std::size_t true_positives
std::size_t true_negatives
std::size_t false_positives
std::size_t false_negatives

Detailed Description

struct MLCore::BinaryClassificationMetrics;

Metrics for a binary (two-class) classification problem.

All rate metrics (accuracy, sensitivity, specificity, dice_score) are in [0, 1]. When a denominator is zero (e.g., no actual positives for sensitivity), the corresponding metric is 0.0.

Public Functions Documentation

function isValid

inline bool isValid() const

Check if any predictions were counted.

Return: true if at least one prediction contributed to the confusion matrix

function getTotalPredictions

inline std::size_t getTotalPredictions() const

Total number of predictions (TP + TN + FP + FN).

Public Attributes Documentation

variable accuracy

double accuracy = 0.0;

(TP + TN) / Total

variable sensitivity

double sensitivity = 0.0;

TP / (TP + FN) — also called recall.

variable specificity

double specificity = 0.0;

TN / (TN + FP).

variable dice_score

double dice_score = 0.0;

2·TP / (2·TP + FP + FN) — also called F1

variable true_positives

std::size_t true_positives = 0;

variable true_negatives

std::size_t true_negatives = 0;

variable false_positives

std::size_t false_positives = 0;

variable false_negatives

std::size_t false_negatives = 0;

Updated on 2026-11-13 at 20:25:41 +0000