Structure

MLRandomForestClassifier

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

Declaration

struct MLRandomForestClassifier

Topics

Creating and Training a Model

init(trainingData: MLDataTable, targetColumn: String, featureColumns: [String]?, parameters: MLRandomForestClassifier.ModelParameters)

Creates a Random Forest Classifier from the feature columns in the training data to predict the categories in the target column.

struct MLRandomForestClassifier.ModelParameters

Parameters that affect the process of training a model.

Evaluating a Model

var trainingMetrics: MLClassifierMetrics

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

var validationMetrics: MLClassifierMetrics

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

func evaluation(on: MLDataTable) -> MLClassifierMetrics

Evaluates the classifier on the provided labeled data.

Testing a Model with Unlabeled Data

var featureColumns: [String]

The column names used by the classifer when accepting input data for classification.

var targetColumn: String

The name of the column you want the classifier to make predictions for.

func predictions(from: MLDataTable) -> MLUntypedColumn

Classifies the provided data into the target categories.

Saving a Model

func write(to: URL, metadata: MLModelMetadata?)

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

func write(toFile: String, metadata: MLModelMetadata?)

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

Inspecting a Model

var model: MLModel

The underlying Core ML model stored in memory.

let modelParameters: MLRandomForestClassifier.ModelParameters

The underlying parameters used when training the model.

Describing a Model

var description: String

A text representation of the random forest classifier.

var debugDescription: String

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

var playgroundDescription: Any

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

See Also

Supporting Classifier Types

struct MLDecisionTreeClassifier

A classifier that predicts the target by creating rules to split the data.

struct MLBoostedTreeClassifier

A classifier based on a collection of decision trees combined with gradient boosting.

struct MLLogisticRegressionClassifier

A classifier that predicts a discrete target value as a function of data features.

struct MLSupportVectorClassifier

A classifier that predicts a binary target value by maximizing the separation between categories.