<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 10.14.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateML",
  "identifier" : "/documentation/CreateML/MLImageClassifier",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML"
    ],
    "preciseIdentifier" : "s:8CreateML17MLImageClassifierV"
  },
  "title" : "MLImageClassifier"
}
-->

# MLImageClassifier

A model you train to classify images.

```
struct MLImageClassifier
```

## Overview

Use an image classifier to train a machine learning model that you can include in your app to categorize images.

When you create the model, you give it a training dataset made up of labeled images, along with parameters that
control the training process. For example, you can provide the model with images of elephants and giraffes, in
two folders labeled `Elephant` and `Giraffe`, to train it to recognize these animals.

After training completes, you evaluate the trained model by showing it a testing dataset containing labeled images
that the model hasn’t seen before. The metrics that come from this evaluation tell you whether the model performs
well enough. For example, you can see how often the elephant and giraffe classifier mistakes a giraffe for an
elephant. When the model makes too many mistakes, you can add more or better training data, or change the
parameters, and try again.

When your model does perform well enough, you save it as a Core ML model file with the `mlmodel` extension. You can
then import this model file into an app—like the
<doc://com.apple.documentation/documentation/CoreML/classifying-images-with-vision-and-core-ml> sample code
project—that uses a Core ML model file to classify images.

## Topics

### Training an image classifier asynchronously

[`makeTrainingSession(trainingData:parameters:sessionParameters:)`](/documentation/CreateML/MLImageClassifier/makeTrainingSession(trainingData:parameters:sessionParameters:))

Creates or restores a training session.

[`train(trainingData:parameters:sessionParameters:)`](/documentation/CreateML/MLImageClassifier/train(trainingData:parameters:sessionParameters:))

Begins an asynchronous image classifier training session with a training dataset represented by a data source.

[`resume(_:)`](/documentation/CreateML/MLImageClassifier/resume(_:))

Begins or continues an asynchronous image classifier training session.

[`restoreTrainingSession(sessionParameters:)`](/documentation/CreateML/MLImageClassifier/restoreTrainingSession(sessionParameters:))

Creates an asynchronous training session for an image classifier by restoring an existing training session’s
state from its parameters.

### Creating an image classifier from a checkpoint

[`init(checkpoint:)`](/documentation/CreateML/MLImageClassifier/init(checkpoint:))

Creates an image classifier from a training session checkpoint.

### Training an image classifier synchronously

[`init(trainingData:parameters:)`](/documentation/CreateML/MLImageClassifier/init(trainingData:parameters:))

Creates an image classifier with a training dataset represented by a data source.

### Evaluating an image classifier

[`evaluation(on:)`](/documentation/CreateML/MLImageClassifier/evaluation(on:))

Generates metrics describing the image classifier’s performance on labeled images represented by a data source.

[`trainingMetrics`](/documentation/CreateML/MLImageClassifier/trainingMetrics)

Measurements of the classifier’s performance on the training data set.

[`validationMetrics`](/documentation/CreateML/MLImageClassifier/validationMetrics)

Measurements of the image classifier’s performance on the validation dataset.

### Testing an image classifier

[`prediction(from:)`](/documentation/CreateML/MLImageClassifier/prediction(from:))

Generates a prediction for an image.

[`predictions(from:)`](/documentation/CreateML/MLImageClassifier/predictions(from:))

Generates predictions for an array of images.

### Saving an image classifier

[`write(to:metadata:)`](/documentation/CreateML/MLImageClassifier/write(to:metadata:))

Exports the image classifier as a Core ML model file to a location in the file system.

[`write(toFile:metadata:)`](/documentation/CreateML/MLImageClassifier/write(toFile:metadata:))

Exports the image classifier as a Core ML model file to the file path.

### Inspecting an image classifier model

[`model`](/documentation/CreateML/MLImageClassifier/model)

The underlying Core ML model of the image classifier stored in memory.

[`modelParameters`](/documentation/CreateML/MLImageClassifier/modelParameters-swift.property)

The model configuration parameters the image classifier used during its training session.

### Describing an image classifier

[`description`](/documentation/CreateML/MLImageClassifier/description)

A text representation of the image classifier.

[`debugDescription`](/documentation/CreateML/MLImageClassifier/debugDescription)

A text representation of the image classifier that’s suitable for output
during debugging.

[`playgroundDescription`](/documentation/CreateML/MLImageClassifier/playgroundDescription)

A description of the image classifier shown in a playground.

### Supporting types

[`MLImageClassifier.DataSource`](/documentation/CreateML/MLImageClassifier/DataSource)

A data source for an image classifier.

[`MLImageClassifier.ModelParameters`](/documentation/CreateML/MLImageClassifier/ModelParameters-swift.struct)

Parameters that affect the process of training an image classifier model.

[`MLImageClassifier.FeatureExtractorType`](/documentation/CreateML/MLImageClassifier/FeatureExtractorType)

The underlying base model that extracts image features for image classifier training session.

[`MLImageClassifier.CustomFeatureExtractor`](/documentation/CreateML/MLImageClassifier/CustomFeatureExtractor)

A custom feature extractor a training session uses to train an image classifier.

[`MLImageClassifier.ImageAugmentationOptions`](/documentation/CreateML/MLImageClassifier/ImageAugmentationOptions)

The variations that the training process can use to generate more training data from the training data you
provide.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)