Enumeration

MLRegressor

A model you train to estimate continuous values.

Declaration

enum MLRegressor

Overview

Use an MLRegressor to estimate continuous values like price, time, or temperature.

A regressor differs from a classifier because it can predict output values not seen during the training process. By contrast, a classifier can only classify input into the categories you provide in the training data.

For example, when estimating housing prices on Mars, a regressor can interpolate between the examples to estimate prices not seen during training. The figure below shows a linear regressor for Mars real-estate prices similar to the Integrating a Core ML Model into Your App sample.

A graph showing housing prices for mars with a linear regressor used to create a continuous estimation between points.

In this case, there are no data points with three solar panels, but the regressor can make an informed prediction about the housing price.

When you create an MLRegressor, Create ML inspects your data and automatically chooses a specific regressor (see Supporting Regressor Types).

Topics

Creating and Training a Regressor

init(trainingData: MLDataTable, targetColumn: String, featureColumns: [String]?)

Creates a regressor from the feature columns in the training data to predict the values in the target column.

var targetColumn: String

The name of the column you selected at initialization to define which feature the regressor predicts.

var featureColumns: [String]

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

Assessing Model Accuracy

var trainingMetrics: MLRegressorMetrics

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

var validationMetrics: MLRegressorMetrics

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

Evaluating a Regressor

func evaluation(on: MLDataTable) -> MLRegressorMetrics

Returns metrics describing the regressor’s performance on the provided labeled data.

Testing a Regressor

func predictions(from: MLDataTable) -> MLUntypedColumn

Predicts the target value from the provided data.

Saving a Regressor

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.

Describing a Regressor

var model: MLModel

The underlying Core ML model stored in memory.

var description: String

A text representation of the regressor.

var debugDescription: String

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

var playgroundDescription: Any

A description of the regressor shown in a playground.

Regressor Cases

The regressor case picked automatically when initializing an MLRegressor.

case linear(MLLinearRegressor)

A regressor that estimates the target as a linear function of the features.

case decisionTree(MLDecisionTreeRegressor)

A regressor that estimates the target by learning rules to split the data.

case boostedTree(MLBoostedTreeRegressor)

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

case randomForest(MLRandomForestRegressor)

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

Supporting Regressor Types

struct MLLinearRegressor

A regressor that estimates the target as a linear function of the features.

struct MLDecisionTreeRegressor

A regressor that estimates the target by learning rules to split the data.

struct MLRandomForestRegressor

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

struct MLBoostedTreeRegressor

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

See Also

Tabular Data

Creating a Model from Tabular Data

Train a machine learning model by using Core ML to import and manage tabular data.

enum MLClassifier

A model you train to classify data into discrete categories.

struct MLRecommender

A model you train to make recommendations based on item similarity, grouping, and, optionally, item ratings.

struct MLDataTable

A table of data for training or evaluating a machine learning model.

enum MLDataValue

The value of a cell in a data table.