I\'ve got an array of 40 arrays with 12 double features, so the type is [[double]]. Currently I\'m sending this data to Google Cloud ML API to get a related prediction.
This is how I did it. Probably not the best way to handle optionals but gets the job done for testing
Create an instance of the MLMultiArray
object with shape and data type
let mlArray = try? MLMultiArray(shape: [3], dataType: MLMultiArrayDataType.float32)
mlArray
does not have an append function so you literally have to iterate through it and add values
for i in 0..
Full function
func convertToMLArray(_ input: [Int]) -> MLMultiArray {
let mlArray = try? MLMultiArray(shape: [3], dataType: MLMultiArrayDataType.float32)
for i in 0..