---
title: "f1Score(for:)"
framework: createmlcomponents
role: symbol
role_heading: Instance Method
path: "createmlcomponents/multilabelclassificationmetrics/f1score(for:)"
---

# f1Score(for:)

Computes the F1 score from predicted and ground truth values.

## Declaration

```swift
func f1Score(for label: Label) -> Float
```

## Parameters

- `label`: The label to use as true positive.

## Return Value

Return Value The F1 score for the given label.

## Discussion

Discussion The balanced F-score, or F1 score, is computed as the harmonic mean of the precision and recall. If the provided label does not have a confidence threshold, the F1 score is NaN.

## See Also

### Computing and scoring

- [count(of:)](createmlcomponents/multilabelclassificationmetrics/count(of:).md)
- [falseNegativeCount(of:)](createmlcomponents/multilabelclassificationmetrics/falsenegativecount(of:).md)
- [falsePositiveCount(of:)](createmlcomponents/multilabelclassificationmetrics/falsepositivecount(of:).md)
- [precisionScore(for:)](createmlcomponents/multilabelclassificationmetrics/precisionscore(for:).md)
- [recallScore(for:)](createmlcomponents/multilabelclassificationmetrics/recallscore(for:).md)
- [trueNegativeCount(of:)](createmlcomponents/multilabelclassificationmetrics/truenegativecount(of:).md)
- [truePositiveCount(of:)](createmlcomponents/multilabelclassificationmetrics/truepositivecount(of:).md)
