<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateMLComponents",
  "identifier" : "/documentation/CreateMLComponents/ObjectDetectionMetrics",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents22ObjectDetectionMetricsV"
  },
  "title" : "ObjectDetectionMetrics"
}
-->

# ObjectDetectionMetrics

Metrics for object detection model.

```
struct ObjectDetectionMetrics<Label> where Label : Comparable, Label : Decodable, Label : Encodable, Label : Hashable
```

## Topics

### Creating a metrics object

[`init()`](/documentation/CreateMLComponents/ObjectDetectionMetrics/init())

### Getting the properties Properties

[`var defaultConfidenceThreshold: Float`](/documentation/CreateMLComponents/ObjectDetectionMetrics/defaultConfidenceThreshold)

The default confidence threshold. It is used as the confidence threshold for any label which does not have an explicit confidence threshold, while calculating
averagePrecision and meanAveragePrecision.

[`var labels: Set<Label>`](/documentation/CreateMLComponents/ObjectDetectionMetrics/labels)

A set of labels present in the dataset.

### Calculating the precision

[`func averageOfAveragePrecisionAtVariedThresholds<Scalar>(predictions: [[DetectedObject<Label>]], annotations: [ObjectDetectionAnnotation<Label>], confidenceThresholds: [Label : Float]) -> [Label : Scalar]`](/documentation/CreateMLComponents/ObjectDetectionMetrics/averageOfAveragePrecisionAtVariedThresholds(predictions:annotations:confidenceThresholds:))

Calculates average of average precision for all the labels, computed at varied bounding box overlap thresholds.
The overlap thresholds range is from `[0.05, 0.95]` with a stride of `0.05`.

[`func averageOfMeanAveragePrecisionAtVariedThresholds<Scalar>(predictions: [[DetectedObject<Label>]], annotations: [ObjectDetectionAnnotation<Label>], confidenceThresholds: [Label : Float]) -> Scalar`](/documentation/CreateMLComponents/ObjectDetectionMetrics/averageOfMeanAveragePrecisionAtVariedThresholds(predictions:annotations:confidenceThresholds:))

Calculates the average of mean average precision, computed at varied bounding box overlap thresholds.
The overlap thresholds range is from `[0.05, 0.95]` with a stride of `0.05`.

[`func averagePrecision<Scalar>(predictions: [[DetectedObject<Label>]], annotations: [ObjectDetectionAnnotation<Label>], confidenceThresholds: [Label : Float], overlapThreshold: Double) -> [Label : Scalar]`](/documentation/CreateMLComponents/ObjectDetectionMetrics/averagePrecision(predictions:annotations:confidenceThresholds:overlapThreshold:))

Calculates average precision for all the labels at the bounding box overlap threshold.

[`func meanAveragePrecision<Scalar>(predictions: [[DetectedObject<Label>]], annotations: [ObjectDetectionAnnotation<Label>], confidenceThresholds: [Label : Float], overlapThreshold: Double) -> Scalar`](/documentation/CreateMLComponents/ObjectDetectionMetrics/meanAveragePrecision(predictions:annotations:confidenceThresholds:overlapThreshold:))

Calculates the mean average precision at the bounding box overlap threshold.

### Extracting labels

[`static func extractLabels(from: [ObjectDetectionAnnotation<Label>]) -> Set<Label>`](/documentation/CreateMLComponents/ObjectDetectionMetrics/extractLabels(from:))

Extracts all the labels from a list of annotations.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)