public class FScore extends java.lang.Object implements ClassificationMetric
The traditional or balanced F-score (F1 score) is the harmonic mean of precision and recall, where an F1 score reaches its best value at 1 and worst at 0.
The general formula involves a positive real β so that F-score measures the effectiveness of retrieval with respect to a user who attaches β times as much importance to recall as precision.
Modifier and Type | Field and Description |
---|---|
static FScore |
F1
The F_1 score, the harmonic mean of precision and recall.
|
static FScore |
F2
The F_2 score, which weighs recall higher than precision.
|
static FScore |
FHalf
The F_0.5 score, which weighs recall lower than precision.
|
Constructor and Description |
---|
FScore()
Constructor of F1 score.
|
FScore(double beta)
Constructor of general F-score.
|
Modifier and Type | Method and Description |
---|---|
static double |
of(double beta,
int[] truth,
int[] prediction)
Calculates the F1 score.
|
double |
score(int[] truth,
int[] prediction)
Returns a score to measure the quality of classification.
|
java.lang.String |
toString() |
public static final FScore F1
public static final FScore F2
public static final FScore FHalf
public FScore()
public FScore(double beta)
beta
- a positive value such that F-score measures
the effectiveness of retrieval with respect
to a user who attaches β times as much
importance to recall as precision.public double score(int[] truth, int[] prediction)
ClassificationMetric
score
in interface ClassificationMetric
truth
- the true class labels.prediction
- the predicted class labels.public static double of(double beta, int[] truth, int[] prediction)
beta
- a positive value such that F-score measures
the effectiveness of retrieval with respect
to a user who attaches β times as much
importance to recall as precision.public java.lang.String toString()
toString
in class java.lang.Object