Enumeration

MLDataValue

The value of a cell in a data table.

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.

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.

Supported Values

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.

Comparing 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 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.

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.

var hashValue: Int

A hash of the data value.

Handling Errors

case invalid

An invalid value.

var isValid: Bool

A Boolean value indicating whether the data value is valid.

See Also

Structured Data

Creating Data Tables for Training and Evaluation

Import and format data to create and evaluate a machine learning model.

struct MLDataTable

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

Beta

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