MLModel
An encapsulation of all the details of your machine learning model.
Declaration
class MLModelMentioned in
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:
Make a prediction with your app’s custom MLFeatureProvider by calling prediction(from:) or prediction(from:options:).
Make multiple predictions with your app’s custom MLBatchProvider by calling predictions(fromBatch:) or predictions(from:options:).
Inspect your model’s metadata and MLFeatureDescription instances through modelDescription.
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
Loading a model
load(contentsOf:configuration:)load(_:configuration:completionHandler:)load(contentsOf:configuration:completionHandler:)init(contentsOf:)init(contentsOf:configuration:)init(contentsOfURL:)init(contentsOfURL:configuration:)
Compiling a model
Making predictions
prediction(from:)prediction(from:options:)predictions(fromBatch:)predictions(from:options:)prediction(from:using:)prediction(from:using:options:)MLPredictionOptions
Making state
Inspecting a model
availableComputeDevicesconfigurationmodelDescriptionMLModelDescriptionparameterValue(for:)MLParameterKey