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

# OrdinalEncoder.Transformer

A transformer that encodes a category as an integer.

```
struct Transformer
```

## Topics

### Creating a transformer

[`init(categories: Set<Category?>)`](/documentation/CreateMLComponents/OrdinalEncoder/Transformer/init(categories:))

Creates an ordinal encoder.

### Getting the categories

[`var categories: Set<Category?>`](/documentation/CreateMLComponents/OrdinalEncoder/Transformer/categories)

Unique values to encode

[`func category(at: Int) -> Category?`](/documentation/CreateMLComponents/OrdinalEncoder/Transformer/category(at:))

Retrieves the category at the ordinal encoding index.

### Applying the transformation

[`func applied<S>(S, eventHandler: EventHandler?) throws -> [Int]`](/documentation/CreateMLComponents/OrdinalEncoder/Transformer/applied(_:eventHandler:))

Performs an ordinal encoding on a sequence of inputs.

[`func applied(to: Category?, eventHandler: EventHandler?) throws -> Int`](/documentation/CreateMLComponents/OrdinalEncoder/Transformer/applied(to:eventHandler:))

Performs an ordinal encoding on a single input.

### Default Implementations

[Decodable Implementations](/documentation/CreateMLComponents/OrdinalEncoder/Transformer/Decodable-Implementations)

[Encodable Implementations](/documentation/CreateMLComponents/OrdinalEncoder/Transformer/Encodable-Implementations)

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

---

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)