Extract result from Algorithmia response

63 Views Asked by At

I have deployed a machine learning model on algorithmia. The model returns a array. Here is my code:

    let input = "[82811,4,67,1,1,4]"
    let client = Algorithmia.client(simpleKey: "xxxxx")
    let algo = client.algo(algoUri: "xxxxx/xxxxx/0.1.4")
    algo.pipe(rawJson: input) { resp, error in
        if (error == nil){
            print(resp)

        }
        else {print(error!)}
    }

I suppose to get an array like [12.3456] by print(resp). However, the output from the console is algorithmia.AlgoResponse which is not my expected output. I have tried resp.getData(), resp.getText() but it didn't work.

The model work properly on my jupyter notebook and it can successfully output the result which is an array using python:

import Algorithmia

input = [82811,4,67,0,0,8]
client = Algorithmia.client('mykey')
algo = client.algo('xxxxx/xxxxx/0.1.4')
algo.set_options(timeout=300)
print(algo.pipe(input).result)

So my question is, how to extract the array from AlgoResponse using swift? Thank you very much.

0

There are 0 best solutions below