Class

MLModel

An encapsulation of all the details of your machine learning model.

Overview

MLModel encapsulates a model's prediction methods, configuration, and model description.

In most cases, you can use Core ML without accessing the MLModel class directly. Instead, use the programmer-friendly wrapper class that Xcode automatically generates when you add a model (see Add a Model to Your Xcode Project). Use the model property from the wrapper class if your app needs the MLModel interface in addition to the wrapper class.

Use the MLModel interface to:

If your app downloads and compiles a model on the user's device, the MLModel interface is the only way for your app to use that model. See Downloading and Compiling a Model on the User's Device.

Topics

Creating a Model

init(contentsOf: URL)

Creates a Core ML model object from a compiled model file.

init(contentsOf: URL, configuration: MLModelConfiguration)

Creates a Core ML model object from a compiled model file and a custom configuration.

Beta
class MLModelConfiguration

The settings for a model object.

Beta

Compiling a Model

class func compileModel(at: URL) -> URL

Compiles a model on the device to update the model in your app.

Predicting Output Values

func prediction(from: MLFeatureProvider) -> MLFeatureProvider

Predicts output feature values from the given input feature values.

func prediction(from: MLFeatureProvider, options: MLPredictionOptions) -> MLFeatureProvider

Predicts output feature values from the given input feature values.

func predictions(from: MLBatchProvider, options: MLPredictionOptions) -> MLBatchProvider

Predicts output feature values from the given a batch of input feature values.

Beta
protocol MLFeatureProvider

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

protocol MLBatchProvider

An interface that represents a collection of feature providers.

Beta
class MLPredictionOptions

The options available when making a prediction.

Inspecting a Model

var configuration: MLModelConfiguration

The configuration of the model set during initialization.

Beta
var modelDescription: MLModelDescription

Information about this model, intended for use during development, which is also displayed in the Xcode view of the model.

class MLModelDescription

Information about a model, primarily the expected input and output format for each feature, and optional metadata.

Relationships

Inherits From

Conforms To

See Also

Machine Learning Model

Downloading and Compiling a Model on the User's Device

Distribute Core ML models to the user's device after the app is installed.

Making Predictions with a Sequence of Inputs

Integrate a recurrent neural network model to process sequences of inputs.

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