luz_metric_binary_accuracy_with_logits: Binary accuracy with logits

luz_metric_binary_accuracy_with_logitsR Documentation

Binary accuracy with logits

Description

Computes accuracy for binary classification problems where the model return logits. Commonly used together with torch::nn_bce_with_logits_loss().

Usage

luz_metric_binary_accuracy_with_logits(threshold = 0.5)

Arguments

threshold

value used to classifiy observations between 0 and 1.

Details

Probabilities are generated using torch::nnf_sigmoid() and threshold is used to classify between 0 or 1.

Value

Returns new luz metric.

See Also

Other luz_metrics: luz_metric_accuracy(), luz_metric_binary_accuracy(), luz_metric_binary_auroc(), luz_metric_mae(), luz_metric_mse(), luz_metric_multiclass_auroc(), luz_metric_rmse(), luz_metric()

Examples

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()
}

mlverse/luz documentation built on Sept. 19, 2024, 11:20 p.m.