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


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.


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) -> URL

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

Predicting Output Values

func prediction(from: MLFeatureProvider) -> MLFeatureProvider

Predicts output values from the given input features.

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

Predicts output values from the given batch of 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.


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