Contents

AnnotatedFeatureProvider

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

Declaration

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

Getting the properties

Encoding and decoding

Fitting

Default Implementations

See Also

Annotations