Class

MLModel

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

Overview

In many cases, you can use Core ML without accessing the MLModel class directly. Instead, the automatically generated model class (named after your .mlmodel file) provides a programmer friendly interface that you should use. If you do need an MLModel instance, use the model property on the automatically generated model class.

However, if you create your own MLFeatureProvider, you need to use the MLModel prediction(from:) or prediction(from:options:) directly.

Topics

Creating a Model

init(contentsOf: URL)

Creates a Core ML model, to be used only when not using the Xcode autogenerated interface.

Compiling a Model

class func compileModel(at: URL)

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

Predicting Output Values

func prediction(from: MLFeatureProvider)

Predicts output values from the given input features.

func prediction(from: MLFeatureProvider, options: MLPredictionOptions)

Predicts output values from the given input features

class MLPredictionOptions

The options available when making a prediction.

Inspecting a Model

var modelDescription: MLModelDescription

Metadata about the model, which is also displayed in the Xcode view of the model.

class MLModelDescription

Information about the model, primarily the expected input and output format, with additional 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.