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

# MLRandomForestClassifier

A classifier based on a collection of decision trees trained on subsets of the data.

```
struct MLRandomForestClassifier
```

## Topics

### Creating a random forest classifier asynchronously

[`static train(trainingData:targetColumn:featureColumns:parameters:sessionParameters:)`](/documentation/CreateML/MLRandomForestClassifier/train(trainingData:targetColumn:featureColumns:parameters:sessionParameters:))

Trains a random forest classifier.

[`static makeTrainingSession(trainingData:targetColumn:featureColumns:parameters:sessionParameters:)`](/documentation/CreateML/MLRandomForestClassifier/makeTrainingSession(trainingData:targetColumn:featureColumns:parameters:sessionParameters:))

Creates or restores a training session.

[`static func resume(MLTrainingSession<MLRandomForestClassifier>) throws -> MLJob<MLRandomForestClassifier>`](/documentation/CreateML/MLRandomForestClassifier/resume(_:))

Resumes a training session from the last checkpoint if available.

[`static func restoreTrainingSession(sessionParameters: MLTrainingSessionParameters) throws -> MLTrainingSession<MLRandomForestClassifier>`](/documentation/CreateML/MLRandomForestClassifier/restoreTrainingSession(sessionParameters:))

Restores an existing training session.

### Creating a random forest classifier from a checkpoint

[`init(checkpoint: MLCheckpoint) throws`](/documentation/CreateML/MLRandomForestClassifier/init(checkpoint:))

Creates a random forest classifier classifier  from a checkpoint.

### Creating a random forest classifier synchronously

[`init(trainingData:targetColumn:featureColumns:parameters:)`](/documentation/CreateML/MLRandomForestClassifier/init(trainingData:targetColumn:featureColumns:parameters:))

Creates a random forest classifier.

[`var targetColumn: String`](/documentation/CreateML/MLRandomForestClassifier/targetColumn)

The name of the column you selected at initialization to define which categories the classifier predicts.

[`var featureColumns: [String]`](/documentation/CreateML/MLRandomForestClassifier/featureColumns)

The names of the columns you selected at initialization to train the classifier.

### Evaluating a random forest classifier

[`func evaluation(on:)`](/documentation/CreateML/MLRandomForestClassifier/evaluation(on:))

Evaluates the classifier on the provided labeled data.

[`var trainingMetrics: MLClassifierMetrics`](/documentation/CreateML/MLRandomForestClassifier/trainingMetrics)

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

[`var validationMetrics: MLClassifierMetrics`](/documentation/CreateML/MLRandomForestClassifier/validationMetrics)

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

### Testing a random forest classifier

[`func predictions(from:)`](/documentation/CreateML/MLRandomForestClassifier/predictions(from:))

Predicts a column of labels for the given testing data.

### Saving a random forest classifier

[`func write(to: URL, metadata: MLModelMetadata?) throws`](/documentation/CreateML/MLRandomForestClassifier/write(to:metadata:))

Exports a Core ML model file for use in your app.

[`func write(toFile: String, metadata: MLModelMetadata?) throws`](/documentation/CreateML/MLRandomForestClassifier/write(toFile:metadata:))

Exports a Core ML model file for use in your app.

### Inspecting a random forest classifier

[`var model: MLModel`](/documentation/CreateML/MLRandomForestClassifier/model)

The Core ML model.

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

Parameters that affect the process of training a model.

[`let modelParameters: MLRandomForestClassifier.ModelParameters`](/documentation/CreateML/MLRandomForestClassifier/modelParameters-swift.property)

The underlying parameters used when training the model.

### Describing a random forest classifier

[`var description: String`](/documentation/CreateML/MLRandomForestClassifier/description)

A text representation of the random forest classifier.

[`var debugDescription: String`](/documentation/CreateML/MLRandomForestClassifier/debugDescription)

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

[`var playgroundDescription: Any`](/documentation/CreateML/MLRandomForestClassifier/playgroundDescription)

A description of the random forest classifier shown in a playground.

### Default Implementations

[CustomDebugStringConvertible Implementations](/documentation/CreateML/MLRandomForestClassifier/CustomDebugStringConvertible-Implementations)

[CustomPlaygroundDisplayConvertible Implementations](/documentation/CreateML/MLRandomForestClassifier/CustomPlaygroundDisplayConvertible-Implementations)

[CustomStringConvertible Implementations](/documentation/CreateML/MLRandomForestClassifier/CustomStringConvertible-Implementations)

## Relationships

### Conforms To

[`CustomPlaygroundDisplayConvertible`](/documentation/Swift/CustomPlaygroundDisplayConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`Escapable`](/documentation/Swift/Escapable)

[`Copyable`](/documentation/Swift/Copyable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)