Metrics used to evaluate a classifier’s performance.


Use MLClassifierMetrics to evaluate your model’s ability to distinguish between different categories when it is classifying data.

You can determine the model's accuracy using the classificationError metric. For information about how your model is mislabeling or missing a certain category, use the precisionRecall metric. To determine specific cases where your model is mistaking one label for another, use the confusion property.

If your data is unbalanced, meaning you have a large difference in the number of examples per category, accuracy can be a misleading metric. Instead use precisionRecall or confusion.


Understanding the Model

var classificationError: Double

The fraction of incorrectly labeled examples.

var precisionRecall: MLDataTable

A data table listing the precision and recall percentages for each category.

var confusion: MLDataTable

A table comparing the actual and predicted labels for each classification category.

Handling Errors

var isValid: Bool

A Boolean value indicating whether the metrics were calculated.

var error: Error?

The underlying error present when the metrics are invalid.

Creating Metrics

init(classificationError: Double, confusion: MLDataTable, precisionRecall: MLDataTable)

Creates classifier metrics describing the quality of your model.

Describing the Model

var description: String

A text representation of this instance.

var debugDescription: String

A text representation of this instance that’s suitable for output during debugging.

var playgroundDescription: Any

A description of the instance shown in a playground.

See Also

Model Evaluation

Improving Your Model’s Accuracy

Use metrics to tune the performance of your machine learning model.

struct MLRegressorMetrics

Metrics used to evaluate a regressor’s performance.


Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software