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

# AnnotatedFeatureProvider

An adaptor that converts a regular estimator to a tabular estimator by selecting features and annotations from columns.

```
struct AnnotatedFeatureProvider<Base, UnwrappedInput> where Base : SupervisedEstimator, Base.Transformer.Input == UnwrappedInput?
```

## Overview

Tabular estimators use multiple features columns as input. When there is a single column of features, you may use
a non-tabular estimator. Do this by combining multiple columns with a `ColumnConcatenator` transformer. Once
there is a single column of features, use `AnnotatedFeatureProvider` to specify which column contains the features,
which column contains the annotations, and which column should hold the results.

When using `AnnotatedFeatureProvider`, make sure to handle missing values before using a non-tabular estimator
that takes non-optional values. This example includes an `OptionalUnwrapper` transformer.

```
let concatenation = ColumnConcatenator<Float>(
    columnSelection: .include(columnNames: ["type", "region"]),
    concatenatedColumnName: "features"
)
let regression = AnnotatedFeatureProvider(
    OptionalUnwrapper<MLShapedArray<Float>>().appending(LinearRegressor<Float>()),
    annotationsColumnName: "price",
    featuresColumnName: "features",
    resultsColumnName: "result"
)
let task = concatenation.appending(regression)
```

## Topics

### Creating the provider

[`init(Base, annotationsColumnName: String, featuresColumnName: String, resultsColumnName: String)`](/documentation/CreateMLComponents/AnnotatedFeatureProvider/init(_:annotationsColumnName:featuresColumnName:resultsColumnName:))

Creates an adaptor that converts a regular estimator to a tabular estimator.

### Getting the properties

[`var annotationColumnID: ColumnID<AnnotatedFeatureProvider<Base, UnwrappedInput>.Annotation>`](/documentation/CreateMLComponents/AnnotatedFeatureProvider/annotationColumnID)

The annotation column identifier.

[`typealias Annotation`](/documentation/CreateMLComponents/AnnotatedFeatureProvider/Annotation)

The annotation type.

[`var base: Base`](/documentation/CreateMLComponents/AnnotatedFeatureProvider/base)

The base estimator.

[`var featuresColumnName: String`](/documentation/CreateMLComponents/AnnotatedFeatureProvider/featuresColumnName)

The features column name.

[`var resultsColumnName: String`](/documentation/CreateMLComponents/AnnotatedFeatureProvider/resultsColumnName)

The results column name.

### Encoding and decoding

[`func encode(AnnotatedFeatureProvider<Base, UnwrappedInput>.Transformer, to: inout any EstimatorEncoder) throws`](/documentation/CreateMLComponents/AnnotatedFeatureProvider/encode(_:to:))

Encodes a fitted transformer.

[`func decode(from: inout any EstimatorDecoder) throws -> AnnotatedFeatureProvider<Base, UnwrappedInput>.Transformer`](/documentation/CreateMLComponents/AnnotatedFeatureProvider/decode(from:))

Decodes a previously fitted transformer.

### Fitting

[`func fitted(to: DataFrame, validateOn: DataFrame?, eventHandler: EventHandler?) async throws -> ColumnSelectorTransformer<Base.Transformer, UnwrappedInput>`](/documentation/CreateMLComponents/AnnotatedFeatureProvider/fitted(to:validateOn:eventHandler:))

Fits a transformer to a data frame

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

The transformer type created by this estimator.

### Default Implementations

[UpdatableSupervisedTabularEstimator Implementations](/documentation/CreateMLComponents/AnnotatedFeatureProvider/UpdatableSupervisedTabularEstimator-Implementations)

## Relationships

### Conforms To

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

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

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

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

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

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

---

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)