<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateMLComponents",
  "identifier" : "/documentation/CreateMLComponents/ClassificationDistribution",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents26ClassificationDistributionV"
  },
  "title" : "ClassificationDistribution"
}
-->

# ClassificationDistribution

A classification distribution that contains a probability for each classification label.

```
struct ClassificationDistribution<Label> where Label : Hashable
```

## Topics

### Creating the distribution

[`init<C>(C)`](/documentation/CreateMLComponents/ClassificationDistribution/init(_:))

Creates a classification distribution.

### Getting the properties

[`var endIndex: Int`](/documentation/CreateMLComponents/ClassificationDistribution/endIndex)

The index of the final element in the classification distribution.

[`var labelsSortedByProbability: [Label]`](/documentation/CreateMLComponents/ClassificationDistribution/labelsSortedByProbability)

The labels sorted  by decreasing probability.

[`var mostLikelyLabel: Label?`](/documentation/CreateMLComponents/ClassificationDistribution/mostLikelyLabel)

The label with the highest probability.

[`var startIndex: Int`](/documentation/CreateMLComponents/ClassificationDistribution/startIndex)

The index of the initial element in the classification distribution.

### Getting the index

[`func index(after: Int) -> Int`](/documentation/CreateMLComponents/ClassificationDistribution/index(after:))

Returns the index immediately after an element index.

[`func index(before: Int) -> Int`](/documentation/CreateMLComponents/ClassificationDistribution/index(before:))

Returns the index immediately before an element index.

### Labeling and mapping

[`func topLabels(Int) -> [Label]`](/documentation/CreateMLComponents/ClassificationDistribution/topLabels(_:))

Computes the most likely labels in the classification set.

[`func map<T>((Classification<Label>) throws -> Classification<T>) rethrows -> ClassificationDistribution<T>`](/documentation/CreateMLComponents/ClassificationDistribution/map(_:))

Creates a new classification distribution by applying a transformation to every element.

### Accessing by subscript

[`subscript(_:)`](/documentation/CreateMLComponents/ClassificationDistribution/subscript(_:))

Accesses a contiguous range of elements.

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

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

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

---

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)