Learn R Programming

MetricsWeighted (version 0.5.4)

f1_score: F1 Score

Description

Calculates weighted F1 score or F measure defined as the harmonic mean of precision and recall, see https://en.wikipedia.org/wiki/Precision_and_recall for some background. The higher, the better.

Usage

f1_score(actual, predicted, w = NULL, ...)

Value

A numeric vector of length one.

Arguments

actual

Observed values (0 or 1).

predicted

Predicted values (0 or 1).

w

Optional case weights.

...

Further arguments passed to precision and recall.

See Also

precision, recall.

Examples

Run this code
f1_score(c(0, 0, 1, 1), c(0, 0, 1, 1))
f1_score(c(1, 0, 0, 1), c(0, 0, 1, 1), w = 1:4)

Run the code above in your browser using DataLab