Learn R Programming

MLmetrics (version 1.1.3)

F1_Score: F1 Score

Description

Compute the F1 Score.

Usage

F1_Score(y_true, y_pred, positive = NULL)

Value

F1 Score

Arguments

y_true

Ground truth (correct) 0-1 labels vector

y_pred

Predicted labels vector, as returned by a classifier

positive

An optional character string for the factor level that corresponds to a "positive" result

Examples

Run this code
data(cars)
logreg <- glm(formula = vs ~ hp + wt,
              family = binomial(link = "logit"), data = mtcars)
pred <- ifelse(logreg$fitted.values < 0.5, 0, 1)
F1_Score(y_pred = pred, y_true = mtcars$vs, positive = "0")
F1_Score(y_pred = pred, y_true = mtcars$vs, positive = "1")

Run the code above in your browser using DataLab