get_hamming_loss: Hamming loss

Description Usage Arguments Value Examples

View source: R/API.R

Description

Compute the hamming loss. When there is only one category, this measure the accuracy.

Usage

1
get_hamming_loss(labels, predictions)

Arguments

labels

list of labels

predictions

list returned by the predict command (including both the probability and the categories)

Value

a scalar with the loss

Examples

1
2
3
4
5
6
7
8
library(fastrtext)
data("test_sentences")
model_test_path <- system.file("extdata", "model_classification_test.bin", package = "fastrtext")
model <- load_model(model_test_path)
sentences <- test_sentences[, "text"]
test_labels <- test_sentences[, "class.text"]
predictions <- predict(model, sentences)
get_hamming_loss(as.list(test_labels), predictions)

fastrtext documentation built on Dec. 10, 2017, 1:03 a.m.