<!--
{
  "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/OrdinalEncoder",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents14OrdinalEncoderV"
  },
  "title" : "OrdinalEncoder"
}
-->

# OrdinalEncoder

An ordinal encoder estimator encodes categorical values to ordinal integer values.

```
struct OrdinalEncoder<Category> where Category : Comparable, Category : Decodable, Category : Encodable, Category : Hashable
```

## Topics

### Creating an encoder

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

Creates an ordinal encoding estimator.

### Fitting

[`func fitted<S>(to: S, eventHandler: EventHandler?) throws -> OrdinalEncoder<Category>.Transformer`](/documentation/CreateMLComponents/OrdinalEncoder/fitted(to:eventHandler:))

Fits an ordinal encoder to a sequence of categories.

### Default Implementations

[Estimator Implementations](/documentation/CreateMLComponents/OrdinalEncoder/Estimator-Implementations)

[UpdatableEstimator Implementations](/documentation/CreateMLComponents/OrdinalEncoder/UpdatableEstimator-Implementations)

## Relationships

### Conforms To

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

[`Estimator`](/documentation/CreateMLComponents/Estimator)

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

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

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

[`UpdatableEstimator`](/documentation/CreateMLComponents/UpdatableEstimator)

---

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)