---
title: OneHotEncoder
framework: createmlcomponents
role: symbol
role_heading: Structure
path: createmlcomponents/onehotencoder
---

# OneHotEncoder

An estimator that encodes categorical values to an integer array.

## Declaration

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

## Overview

Overview The encoded array has an element count equal to the number of categories to encode. The encoded array for a given category has repeating zero values except at one index where the value is 1.

## Topics

### Creating the estimator

- [init()](createmlcomponents/onehotencoder/init().md)

### Fitting

- [fitted(to:eventHandler:)](createmlcomponents/onehotencoder/fitted(to:eventhandler:).md)

### Default Implementations

- [Estimator Implementations](createmlcomponents/onehotencoder/estimator-implementations.md)
- [UpdatableEstimator Implementations](createmlcomponents/onehotencoder/updatableestimator-implementations.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [Escapable](swift/escapable.md)
- [Estimator](createmlcomponents/estimator.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [UpdatableEstimator](createmlcomponents/updatableestimator.md)

## See Also

### Preprocessors

- [LinearTransformer](createmlcomponents/lineartransformer.md)
- [ImputeTransformer](createmlcomponents/imputetransformer.md)
- [OrdinalEncoder](createmlcomponents/ordinalencoder.md)
- [NumericImputer](createmlcomponents/numericimputer.md)
- [Reshaper](createmlcomponents/reshaper.md)
- [CategoricalImputer](createmlcomponents/categoricalimputer.md)
- [OptionalUnwrapper](createmlcomponents/optionalunwrapper.md)
