This documentation is for scikit-learn version 0.11-gitOther versions

Citing

If you use the software, please consider citing scikit-learn.

This page

8.17.1.6. sklearn.metrics.fbeta_score

sklearn.metrics.fbeta_score(y_true, y_pred, beta, labels=None, pos_label=1, average='weighted')

Compute fbeta score

The F_beta score is the weighted harmonic mean of precision and recall, reaching its optimal value at 1 and its worst value at 0.

The beta parameter determines the weight of precision in the combined score. beta < 1 lends more weight to precision, while beta > 1 favors precision (beta == 0 considers only precision, beta == inf only recall).

Parameters :

y_true : array, shape = [n_samples]

True targets

y_pred : array, shape = [n_samples]

Predicted targets

beta: float :

Weight of precision in harmonic mean.

labels : array

Integer array of labels

pos_label : int

In the binary classification case, give the label of the positive class (default is 1). Everything else but ‘pos_label’ is considered to belong to the negative class. Set to None in the case of multiclass classification.

average : string, [None, ‘micro’, ‘macro’, ‘weighted’(default)]

In the multiclass classification case, this determines the type of averaging performed on the data.

macro:

Average over classes (does not take imbalance into account).

micro:

Average over instances (takes imbalance into account). This implies that precision == recall == f1

weighted:

Average weighted by support (takes imbalance into account). Can result in f1 score that is not between precision and recall.

Returns :

fbeta_score : float

fbeta_score of the positive class in binary classification or weighted average of the fbeta_score of each class for the multiclass task.

References

R. Baeza-Yates and B. Ribeiro-Neto (2011). Modern Information Retrieval. Addison Wesley, pp. 327-328.

http://en.wikipedia.org/wiki/F1_score