Skip to contents

This function computes the F-beta score.

Usage

fbeta_score(true, pred, beta = 1, weights = NULL, multi, ...)

Arguments

true

a vector (or a matrix) of observed values. If a matrix is provided, a multi-response is assumed

pred

a vector (or a matrix) of predicted values

beta

a length-one numeric vector, the beta value to consider. Default is beta = 1

weights

observation weights (not implemented yet)

multi

what to do when response has multiple output values

average

errors of multiple outputs are averaged to get a single value for each observation

micro

the score is computed by using the global number of true positives, false negatives and false positives

macro

scores of different classes are averaged by unweighted mean to get a single value. Class imbalance is not taken into account

weighted

scores of different classes are averaged by weighted mean to get a single value. Weights are number of true instances per class. It takes into account label imbalance

raw

returns a vector containing one score for each class

binary

returns the score for the class specified by positive

...

further arguments to multiresponse_classification_metric

Value

A single score for the selected class if multi = "binary", a vector containing one score for each class if multi = "raw", a summary score computed by using the global metrics if multi = "micro" or averaging the results from different classes if multi = "macro". A summary score produced by a weighted average of the results from different class is produced if multi = "weighted"

Details

The F-beta score is a measure of accuracy based on precision and recall. It is defined as

$$F_{\beta} = (1 + \beta^{2}) \frac{precision \times recall}{(\beta^{2} precision) + recall} = (1 + \beta^{2}) \frac{TP}{(1 + \beta^{2})TP + \beta^{2} FN + FP)}$$

The highest possible value of an F-score is 1.0, indicating perfect precision and recall. The lowest possible value is 0.

See also

f1_score a special case of F-beta score where beta = 1

Author

Alessandro Barberis