<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLFeatureValue",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core ML"
    ],
    "preciseIdentifier" : "c:objc(cs)MLFeatureValue"
  },
  "title" : "MLFeatureValue"
}
-->

# MLFeatureValue

A generic wrapper around an underlying value and the value’s type.

```
class MLFeatureValue
```

## Overview

A Core ML *feature value* wraps an underlying value and bundles it with that value’s type, which is one of the types that [`MLFeatureType`](/documentation/CoreML/MLFeatureType) defines. Apps typically access feature values indirectly by using the methods in the wrapper class Xcode automatically generates for Core ML model files.

If your app accesses an [`MLModel`](/documentation/CoreML/MLModel) directly, it must create and consume [`MLFeatureProvider`](/documentation/CoreML/MLFeatureProvider) instances. For each prediction, Core ML accepts a feature provider for its inputs, and generates a separate feature provider for its outputs. The input feature provider contains one `MLFeatureValue` instance per input, and the output feature provider contains one per output. See [`MLFeatureDescription`](/documentation/CoreML/MLFeatureDescription) for more information about the model input and output features.

## Topics

### Creating a feature value

[`init(_:)`](/documentation/CoreML/MLFeatureValue/init(_:))

Creates a feature value from a sendable feature value.

### Creating numeric feature values

[`init(int64:)`](/documentation/CoreML/MLFeatureValue/init(int64:))

Creates a feature value that contains an integer.

[`init(double:)`](/documentation/CoreML/MLFeatureValue/init(double:))

Creates a feature value that contains a double.

### Creating string feature values

[`init(string:)`](/documentation/CoreML/MLFeatureValue/init(string:))

Creates a feature value that contains a string.

### Creating multidimensional feature values

[`init(multiArray:)`](/documentation/CoreML/MLFeatureValue/init(multiArray:))

Creates a feature value that contains a multidimensional array.

[`init(shapedArray:)`](/documentation/CoreML/MLFeatureValue/init(shapedArray:))

Creates a feature value that contains a shaped array.

### Creating collection feature values

[`init(dictionary:)`](/documentation/CoreML/MLFeatureValue/init(dictionary:))

Creates a feature value that contains a dictionary of numbers.

[`init(sequence:)`](/documentation/CoreML/MLFeatureValue/init(sequence:))

Creates a feature value that contains a sequence.

### Creating image feature values

[`init(pixelBuffer:)`](/documentation/CoreML/MLFeatureValue/init(pixelBuffer:))

Creates a feature value that contains an image from a pixel buffer.

[`init(CGImage:pixelsWide:pixelsHigh:pixelFormatType:options:)`](/documentation/CoreML/MLFeatureValue/init(CGImage:pixelsWide:pixelsHigh:pixelFormatType:options:)-2zg43)

Creates a feature value that contains an image defined by a core graphics image and its size and pixel format.

[`init(CGImage:orientation:pixelsWide:pixelsHigh:pixelFormatType:options:)`](/documentation/CoreML/MLFeatureValue/init(CGImage:orientation:pixelsWide:pixelsHigh:pixelFormatType:options:)-4nme0)

Creates a feature value that contains an image defined by a core graphics image and its orientation, size, and pixel format.

[`init(CGImage:constraint:options:)`](/documentation/CoreML/MLFeatureValue/init(CGImage:constraint:options:)-1j00l)

Creates a feature value that contains an image defined by a core graphics image and a constraint.

[`init(CGImage:orientation:constraint:options:)`](/documentation/CoreML/MLFeatureValue/init(CGImage:orientation:constraint:options:)-87vk0)

Creates a feature value that contains an image defined by a core graphics image, an orientation, and a constraint.

[`init(imageAtURL:pixelsWide:pixelsHigh:pixelFormatType:options:)`](/documentation/CoreML/MLFeatureValue/init(imageAtURL:pixelsWide:pixelsHigh:pixelFormatType:options:))

Creates a feature value that contains an image defined by an image URL and the image’s size and pixel format.

[`init(imageAtURL:orientation:pixelsWide:pixelsHigh:pixelFormatType:options:)`](/documentation/CoreML/MLFeatureValue/init(imageAtURL:orientation:pixelsWide:pixelsHigh:pixelFormatType:options:))

Creates a feature value that contains an image defined by an image URL and the image’s orientation, size, and pixel format.

[`init(imageAtURL:constraint:options:)`](/documentation/CoreML/MLFeatureValue/init(imageAtURL:constraint:options:))

Creates a feature value that contains an image defined by an image URL and a constraint.

[`init(imageAtURL:orientation:constraint:options:)`](/documentation/CoreML/MLFeatureValue/init(imageAtURL:orientation:constraint:options:))

Creates a feature value that contains an image defined by an image URL, an orientation, and a constraint.

[`MLImageConstraint`](/documentation/CoreML/MLImageConstraint)

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

[`MLFeatureValue.ImageOption`](/documentation/CoreML/MLFeatureValue/ImageOption)

The initializer options you use to crop and scale an image when creating an image feature value.

### Creating undefined feature values

[`init(undefined:)`](/documentation/CoreML/MLFeatureValue/init(undefined:))

Creates a feature value with a type that represents an undefined or missing value.

### Accessing the feature’s type

[`type`](/documentation/CoreML/MLFeatureValue/type)

The type of the feature value.

### Accessing the feature’s value

[`isUndefined`](/documentation/CoreML/MLFeatureValue/isUndefined)

A Boolean value that indicates whether the feature value is undefined or missing.

[`int64Value`](/documentation/CoreML/MLFeatureValue/int64Value)

The underlying integer of the feature value.

[`doubleValue`](/documentation/CoreML/MLFeatureValue/doubleValue)

The underlying double of the feature value.

[`stringValue`](/documentation/CoreML/MLFeatureValue/stringValue)

The underlying string of the feature value.

[`imageBufferValue`](/documentation/CoreML/MLFeatureValue/imageBufferValue)

The underlying image of the feature value as a pixel buffer.

[`shapedArrayValue(of:)`](/documentation/CoreML/MLFeatureValue/shapedArrayValue(of:))

Returns the underlying shaped array of the feature value.

[`multiArrayValue`](/documentation/CoreML/MLFeatureValue/multiArrayValue)

The underlying multiarray of the feature value.

[`sequenceValue`](/documentation/CoreML/MLFeatureValue/sequenceValue)

The underlying sequence of the feature value.

[`dictionaryValue`](/documentation/CoreML/MLFeatureValue/dictionaryValue)

The underlying dictionary of the feature value.

### Comparing feature values

[`isEqual(to:)`](/documentation/CoreML/MLFeatureValue/isEqual(to:))

Returns a Boolean value that indicates whether a feature value is equal to another.

### Supporting types

[`MLFeatureType`](/documentation/CoreML/MLFeatureType)

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

[`MLShapedArray`](/documentation/CoreML/MLShapedArray)

A machine learning collection type that stores scalar values in a multidimensional array.

[`MLShapedArrayProtocol`](/documentation/CoreML/MLShapedArrayProtocol)

An interface that defines a shaped array type.

[`MLMultiArray`](/documentation/CoreML/MLMultiArray)

A machine learning collection type that stores numeric values in an array with multiple dimensions.

[`MLSequence`](/documentation/CoreML/MLSequence)

A machine learning collection type that stores a series of strings or integers.



---

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)