A column of untyped values in a data table.
- macOS 10.14+
- Xcode 10.0+
- Create ML
Typically you use
MLData, the typed equivalent to
MLUntyped, for its type-specific functionality.
Untyped columns are especially useful when:
You’re initializing a data table with columns by using
You’re using columns of a non-Boolean type to filter a data table with
You don’t need to work directly with the underlying type.
Each element of an untyped column is an
MLData, and has an underlying type that conforms to
MLData. The underlying type is hidden from the Swift compiler and is what makes an
MLUntyped untyped. Using an untyped column allows you to quickly write type-agnostic code with Create ML.
However, by avoiding type safety at compile time, you expose your code to errors at runtime. When an error occurs during an operation, Create ML marks the product of that operation invalid by setting
false and by setting
error with a value. For example, using a slash (
/) operator to divide a column of integers with a string produces an invalid column.
Once a column becomes invalid, you can’t use it for any subsequent operation because it will only produce further invalid columns or invalid tables.
Each comparison operator of
MLUntyped returns a column of Booleans. However,
MLUntyped uses integers as its underlying type for columns of Booleans, because
MLData does not have a case for
For example, create an untyped column of Booleans using the less-than comparison operator(
Then print the column to see that its underlying
Int, and each Boolean value of
false is represented in the column by an integer value of