Class

MLFeatureDescription

The name, type, and constraints of an input or output feature.

Declaration

@interface MLFeatureDescription : NSObject

Overview

In Core ML, a feature is a single input or output of a model. A model can have any number of input features or output features. Each feature has a name and a value type, which are defined in the feature's MLFeatureDescription. Model authors use feature descriptions to help developers integrate their model properly. Each MLFeatureDescription instance has read-only properties that indicate the feature's name, its type, and whether it's optional.

For examples of features, see Integrating a Core ML Model into Your App. Note the three input features named solarPanels, greenhouses, and size, and the output feature is named price. All four features are of type Double.

An MLFeatureDescription may also include constraints, which specify the limitations of the model's input and output features. For each input feature, the constraints describe what values the model expects from your app. For each output feature, the constraints describe what values your app should expect from the model. You can also write code to inspect these descriptions before using the model in your app.

Topics

Inspecting a Feature

name

The name of this feature.

type

The type of this feature.

MLFeatureType

The possible types for feature values, input features, and output features.

optional

A Boolean value that indicates whether this feature is optional.

Checking for Validity

- isAllowedValue:

Checks whether the model will accept an input feature value.

Accessing Feature Constraints

imageConstraint

The size and format constraints for an image feature.

MLImageConstraint

The width, height, and pixel format constraints of an image feature.

dictionaryConstraint

The constraint for a dictionary feature.

MLDictionaryConstraint

The constraint on the keys for a dictionary feature.

multiArrayConstraint

The constraints on a multidimensional array feature.

MLMultiArrayConstraint

The shape and data type constraints for a multidimensional array feature.

sequenceConstraint

The constraints for a sequence feature.

MLSequenceConstraint

The constraints for a sequence feature.

Relationships

Inherits From

See Also

Accessing Feature Descriptions

inputDescriptionsByName

Descriptions of this model's various input features, keyed by each feature's name.

outputDescriptionsByName

Descriptions of this model's various output features, keyed by each feature's name.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software