b_cubed_f#
- er_evaluation.metrics.b_cubed_f(prediction, reference, beta=1.0)[source]#
B-cubed F score for the inner join of two clusterings.
- B-cubed F score:
B-cubed F score is defined as the weighted harmonic mean of B-cubed precision \(P\) and B-cubed recall \(R\):
\[F_\beta = \frac{(1 + \beta^2)PR}{ \beta^2 P+R}\]The \(\beta\) parameter controls the relative weight of precision and recall. When \(\beta = 1\), the F score is the harmonic mean of precision and recall. When \(\beta < 1\), the F score is weighted towards precision. When \(\beta > 1\), the F score is weighted towards recall.
- Parameters:
prediction (Series) – Membership vector for the predicted clustering.
reference (Series) – Membership vector for the reference clustering.
beta (float) – Weight of precision in the F score.
- Returns:
B-cubed F score for the inner join of prediction and reference.
- Return type:
float
Examples
>>> prediction = pd.Series(index=[1,2,3,4,5,6,7,8], data=[1,1,2,3,2,4,4,4]) >>> reference = pd.Series(index=[1,2,3,4,5,6,7,8], data=["c1", "c1", "c1", "c2", "c2", "c3", "c3", "c4"]) >>> b_cubed_f(prediction, reference) 0.6999178981937602
Notes
NA values are dropped from membership vectors prior to computing the metric.