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

# CategoricalImputer

An estimator that replaces missing values in the categorical input.

```
struct CategoricalImputer<Element> where Element : Decodable, Element : Encodable, Element : Hashable
```

## Topics

### Creating an estimator

[`init(CategoricalImputer<Element>.Strategy)`](/documentation/CreateMLComponents/CategoricalImputer/init(_:))

Creates an imputer with a strategy.

[`init(constant: Element)`](/documentation/CreateMLComponents/CategoricalImputer/init(constant:))

Creates an imputer with a constant value to use when replacing missing values.

### Getting the properties

[`var strategy: CategoricalImputer<Element>.Strategy`](/documentation/CreateMLComponents/CategoricalImputer/strategy-swift.property)

The imputation strategy.

### Fitting

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

Fits a categorical imputer to a sequence of elements.

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

A transformer that takes an input and produces an output.

[`enum Strategy`](/documentation/CreateMLComponents/CategoricalImputer/Strategy-swift.enum)

An imputation strategy.

## Relationships

### Conforms To

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

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

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

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

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

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

---

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)