Skip to contents

Given binary observed and predicted response, estimate Matthews correlation coefficient (MCC) and the F1 score.

Usage

calculate_mcc_f1(observed, predicted)

Arguments

observed

logical or 0/1; the observed binary response.

predicted

logical or 0/1; the predicted binary response. This will typically need to be generated by applying a threshold to the continuous predicted response.

Value

A list with two elements: mcc and f1.

Examples

obs <- c(rep(1L, 1000L), rep(0L, 10000L))
pred <- c(rbeta(300L, 12, 2), rbeta(700L, 3, 4), rbeta(10000L, 2, 3))
calculate_mcc_f1(obs > 0, pred > 0.5)
#> $f1
#> [1] 0.2227891
#> 
#> $mcc
#> [1] 0.125311
#>