Package smile.validation.metric
Class FScore
java.lang.Object
smile.validation.metric.FScore
- All Implemented Interfaces:
Serializable
,ToDoubleBiFunction<int[],
,int[]> ClassificationMetric
The F-score (or F-measure) considers both the precision and the recall of the test
to compute the score. The precision p is the number of correct positive results
divided by the number of all positive results, and the recall r is the number of
correct positive results divided by the number of positive results that should
have been returned.
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.
- See Also:
-
Field Details
-
F1
The F_1 score, the harmonic mean of precision and recall. -
F2
The F_2 score, which weighs recall higher than precision. -
FHalf
The F_0.5 score, which weighs recall lower than precision.
-
-
Constructor Details
-
FScore
public FScore()Constructor of F1 score. -
FScore
Constructor of general F-score.- Parameters:
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.strategy
- The aggregating strategy for multi-classes.
-
-
Method Details
-
score
public double score(int[] truth, int[] prediction) Description copied from interface:ClassificationMetric
Returns a score to measure the quality of classification.- Specified by:
score
in interfaceClassificationMetric
- Parameters:
truth
- the true class labels.prediction
- the predicted class labels.- Returns:
- the metric.
-
toString
-
of
Calculates the F1 score.- Parameters:
truth
- the ground truth.prediction
- the 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.- Returns:
- the metric.
-