init(dictionaries:)
Creates a new column of machine learning dictionaries by converting the elements of another column.
Declaration
init(dictionaries: MLUntypedColumn)Parameters
- dictionaries:
A column with elements that are convertible to Create ML dictionaries.
Return Value
A new untyped column of doubles; otherwise an invalid column if any element of the given column cannot be converted to MLDataValue.DictionaryType.
Discussion
Use this initializer to create a column of dictionaries from another column. As an example, to create a column with this initializer, first start with a column that is convertible to dictionaries.
let intDictionaryString = "{1:\"one\", 2:\"two\", 3:\"three\"}"
let intDictionaryString2 = "{4:\"four\", 5:\"five\", 6:\"six\"}"
let stringsColumn = MLUntypedColumn([intDictionaryString, intDictionaryString2])
print(stringsColumn)
/* Prints...
ValueType: String
Values: [{1:"one", 2:"two", 3:"three"}, {4:"four", 5:"five", 6:"six"}]
*/Then use init(dictionaries:) to convert the column to a column of dictionaries.
let dictionaryColumn = MLUntypedColumn(dictionaries: stringsColumn)
print(dictionaryColumn)
/* Prints...
ValueType: Dictionary
Values: [[1: one, 3: three, 2: two], [4: four, 5: five, 6: six]]
*/