Class

MLModel

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

Declaration

@interface MLModel : NSObject

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 Integrating a Core ML Model into Your App). If your app needs the MLModel interface, use the wrapper class’s model property.

With the MLModel interface, you can:

If your app downloads and compiles a model on the user’s device, you must use the MLModel class directly to make predictions. See Downloading and Compiling a Model on the User’s Device.

Topics

Creating a Model

+ modelWithContentsOfURL:error:

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

+ modelWithContentsOfURL:configuration:error:

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

MLModelConfiguration

The settings for creating or updating a machine learning model.

Compiling a Model

+ compileModelAtURL:error:

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

Making Predictions

- predictionFromFeatures:error:

Generates a prediction from the feature values within the input feature provider.

- predictionFromFeatures:options:error:

Generates a prediction from the feature values within the input feature provider using the prediction options.

- predictionsFromBatch:error:

Generates predictions for each input feature provider within the batch provider.

- predictionsFromBatch:options:error:

Generates a prediction for each input feature provider within the batch provider using the prediction options.

MLPredictionOptions

The options available when making a prediction.

Inspecting a Model

configuration

The configuration of the model set during initialization.

modelDescription

Model information you use at runtime during development, which Xcode also displays in its Core ML model editor view.

MLModelDescription

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

- parameterValueForKey:error:

Returns a model parameter value for a key.

MLParameterKey

The keys for the parameter dictionary in a model configuration or a model update context.

MLKey

An abstract base class for machine learning key types.

Relationships

Inherits From

See Also

Machine Learning Model

Downloading and Compiling a Model on the User’s Device

Install Core ML models on the user’s device dynamically at runtime.

Making Predictions with a Sequence of Inputs

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