Enumeration

MLDataValue

The value of a cell in a data table.

Declaration

enum MLDataValue

Overview

The MLDataValue enumeration is the fundamental type that you use to store training data in a table. Classifiers use data values to store information like evaluation metrics. Data values wrap all of the possible data types you can use with Create ML.

To access the underlying information in a data value, you can use the properties that correspond to the type's enumeration cases. If you aren't sure which kind of value a data value wrapper contains, use a switch statement to unwrap the value, or check the value of the type property.

Topics

Converting Between Types and Data Values

protocol MLDataValueConvertible

A type that can be converted to and from a value in a data table.

Creating a Data Value

case int(Int)

An integer value.

case double(Double)

A double value.

case string(String)

A string value.

case dictionary(MLDataValue.DictionaryType)

A dictionary of named data values.

case sequence(MLDataValue.SequenceType)

A sequence of data values.

case multiArray(MLDataValue.MultiArrayType)

A multidimensional array of data values.

Inspecting the Type

var type: MLDataValue.ValueType

The kind of the underlying value that the data value wraps.

enum MLDataValue.ValueType

An enumeration describing the supported underlying types that an MLDataValue wraps.

Accessing Numeric Values

var intValue: Int?

The underlying integer value.

var doubleValue: Double?

The underlying double value.

Accessing String Values

var stringValue: String?

The underlying string value.

Accessing Dictionary Values

struct MLDataValue.DictionaryType

A dictionary of named data values.

Accessing Array Values

struct MLDataValue.SequenceType

A sequence of data values.

var multiArrayValue: MLDataValue.MultiArrayType?

The underlying multidimensional array.

struct MLDataValue.MultiArrayType

A multidimensional array of data values.

Comparing Data Values

static func != (MLDataValue, MLDataValue) -> Bool

Returns a Boolean value indicating whether two values are not equal.

static func == (MLDataValue, MLDataValue) -> Bool

Returns a Boolean value indicating whether two data values wrap the same underlying value.

Describing a Data Value

var description: String

A text representation of the data value.

var debugDescription: String

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

Handling Errors

case invalid

An invalid value.

var isValid: Bool

A Boolean value indicating whether the data value is valid.

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.

enum MLRegressor

A model you train to estimate continuous values.

struct MLRecommender

A model you train to make recommendations based on item similarities, and optionally, user ratings.

Beta
struct MLDataTable

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