<!--
{
  "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 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateMLComponents",
  "identifier" : "/documentation/CreateMLComponents/ClassificationMetrics/mapLabels(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents21ClassificationMetricsV9mapLabelsyACyqd__Gqd__xKXEKSHRd__lF"
  },
  "title" : "mapLabels(_:)"
}
-->

# mapLabels(_:)

Returns new classification metrics where the labels are the result of applying a transformation.

```
func mapLabels<T>(_ transform: (Label) throws -> T) rethrows -> ClassificationMetrics<T> where T : Hashable
```

## Discussion

The transformation can combine separate labels into one. The metrics will be adjusted accordingly by combining
counts from the original labels. An example of this is combining mixed cased labels into lowercase:

```swift
let metrics = ClassificationMetrics(predicted, groundTruth).map({ $0.lowercased() })
```

---

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)