Class

MLFeatureValue

A feature's value and its type bundled as a read-only instance.

Declaration

class MLFeatureValue : NSObject

Overview

A Core ML feature value, represented by MLFeatureValue, wraps both a data value and its type, represented by MLFeatureType. For every MLModel prediction, every input feature receives exactly one MLFeatureValue and every output feature produces exactly one MLFeatureValue. (See MLFeatureDescription for details about input and output features.)

However, the model and your app don't pass MLFeatureValue instances directly. Instead, your app uses an MLFeatureProvider to pass MLFeatureValue instances to the model's input features and another MLFeatureProvider to get MLFeatureValue instances from the model's output features.

If you use the dynamically generated interface for your Core ML model, you will use the model input and output interfaces specific to your model, instead of using MLFeatureValue, to manipulate values directly.

Topics

Creating Values with a Specific Type

init(int64: Int64)

Wraps an integer as a value for this feature.

init(string: String)

Wraps a string as a value for a feature.

init(dictionary: [AnyHashable : NSNumber])

Wraps a dictionary as a value for a feature.

init(pixelBuffer: CVPixelBuffer)

Wraps a pixel buffer as a value for a feature.

init(double: Double)

Wraps a double as a value for a feature.

init(multiArray: MLMultiArray)

Wraps a multidimensional array as a value for a feature.

init(sequence: MLSequence)

Wraps a sequence as a value for a feature.

init(undefined: MLFeatureType)

Wraps an undefined value with a given type.

Accessing the Type

var type: MLFeatureType

The type of this feature value.

enum MLFeatureType

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

Accessing the Value

var isUndefined: Bool

A Boolean value indicating whether the feature value is undefined.

var int64Value: Int64

The integer wrapped in this feature value.

var doubleValue: Double

The double wrapped in this feature value.

var stringValue: String

The string wrapped in this feature value.

var dictionaryValue: [AnyHashable : NSNumber]

The dictionary wrapped in this feature value.

var imageBufferValue: CVPixelBuffer?

The image, or pixelBuffer, wrapped in this feature value.

var multiArrayValue: MLMultiArray?

The multidimensional array wrapped in this feature value.

class MLMultiArray

A multidimensional array used as a feature input or feature output for a model.

var sequenceValue: MLSequence?

The sequence wrapped in this feature value.

class MLSequence

A sequence of data used as a feature input or feature output for a model.

Comparing Feature Values

func isEqual(to: MLFeatureValue) -> Bool

Compares the feature value and its type.

Relationships

Inherits From

See Also

Model Features

protocol MLFeatureProvider

An interface that represents a collection of values for either a model's input or its output.

class MLDictionaryFeatureProvider

A convenience wrapper for the given dictionary of data.

protocol MLBatchProvider

An interface that represents a collection of feature providers.

class MLArrayBatchProvider

A convenience wrapper for batches of feature providers.