mt_fscore: FScore Calculator

View source: R/ac_metrics.R

mt_fscoreR Documentation

FScore Calculator

Description

Class for the F-beta score of one batch. f = 1 (the default) gives the usual F1 score; values below 1 weight precision more heavily and values above 1 weight recall more heavily.

It is computed from the confusion-matrix counts, ⁠(1 + f^2) TP / ((1 + f^2) TP + f^2 FN + FP)⁠, so it returns 0 when the batch has positives yet the prediction gets them all wrong (TP = 0, FP + FN > 0) and NA only when the batch has no positive at all (real or predicted). This is the behaviour needed to score a model in model selection: penalise an all-wrong model (score 0), do not skip it (NA). It is the metric the adp_recurrent() error-based and hybrid selectors (slct_error_metrics(), slct_psi_then_error()) use, and it matches the aggregate f1_aggregate().

Usage

mt_fscore(f = 1)

Arguments

f

The beta parameter of the F-beta score (a single positive number).

Value

Metric object

Examples

library(daltoolbox)
obj <- mt_fscore(f = 1)
evaluate(obj, c(TRUE, FALSE, TRUE), c(TRUE, TRUE, TRUE))

heimdall documentation built on Dec. 2, 2026, 5:08 p.m.