metric_F1: metric_F1

Description Usage Arguments Value See Also Examples

View source: R/metric_Fbeta.R

Description

Returns the F1 [2 * (precision * recall) / (precision + recall)] of a classification using the confusion matrix Note: Predictions should be annualized (independent of exposure) Note: Perfect F1 is 1, poor model is 0

Usage

1
metric_F1(actual, predicted, weight = NULL, na.rm = FALSE, threshold = 0.5)

Arguments

actual

Array[Numeric] - Values we are aiming to predict.

predicted

Array[Numeric] - Values that we have predicted.

weight

Optional: Array[Numeric] - Weighting of predictions. If NULL even weighting is used

na.rm

Optional: boolean - If FALSE function will return NA is any value in NA

threshold

Optional: Numeric between 0 and 1. If prediction proablity is below threshold the predicted value is 0.

Value

precision of classification TP / (TP + FN)

See Also

metric_precision, metric_recall and metric_Fbeta

Examples

1
2
3
4
5
metric_F1(actual=c(0,1,0,0), predicted=c(0.1,0.9,0.4,0.6))
metric_Fbeta(actual=c(0,1,0,0), predicted=c(0.1,0.9,0.4,0.6), threshold=0.7)

## metric_F1 is a specific value of metric_Fbeta
metric_Fbeta(actual=c(0,1,0,0), predicted=c(0.1,0.9,0.4,0.6), beta=1)

gloverd2/admr documentation built on Dec. 2, 2020, 11:16 p.m.