Passer au contenu

Calcule la précision (accuracy) pour les problèmes de classification binaire pour un modèle avec des logits en sortie. Le plus souvent, associé à torch::nn_bce_with_logits_loss().

Utilisation

luz_metric_binary_accuracy_with_logits(threshold = 0.5)

Arguments

threshold

valeur de seuil pour classifier les observations en 0 ou 1.

Valeur de retour

Renvoie la nouvelle métrique luz.

Détails

Les probabilités sont calcullées avec torch::nnf_sigmoid() et le threshold permet de classifier en 0 ou 1.

Exemples

if (torch::torch_is_installed()) {
library(torch)
metric <- luz_metric_binary_accuracy_with_logits(threshold = 0.5)
metric <- metric$new()
metric$update(torch_randn(100), torch::torch_randint(0, 1, size = 100))
metric$compute()
}
#> Error in luz_metric_binary_accuracy_with_logits(threshold = 0.5): impossible de trouver la fonction "luz_metric_binary_accuracy_with_logits"