mleap icon indicating copy to clipboard operation
mleap copied to clipboard

Does mleap serving support libsvm format(the sparse way)?

Open kaysonx opened this issue 6 years ago • 2 comments

Hello, I saw the mleapSparseTensorFormat on the json support, but how can I use this? I've tried this way: { "schema": { "fields": [{ "name": "features", "type": { "type": "tensor", "dimensions": [132], "base": "double" } }] }, "rows": [[ 1,3,13,61,111,122,1, 1, 0, 0, 1, 1 ]] } but it doesn't work for me?

kaysonx avatar Oct 30 '19 03:10 kaysonx

@qspeng can you try

         "type": "tensor",
         "base": "double",
         "dimensions": [
           132
         ], 
        "indices": [....] // I think this is the part that you're missing
       }

Let me know if you're still having issues.

ancasarb avatar Jan 14 '20 22:01 ancasarb

Hello @ancasarb! Is there any documentation available for sending sparse vectors? I serialized a model that takes as input a column with Spark Sparse vectors (size ~615k). Im using mleap-spring-boot:0.18.0-SNAPSHOT and this is the inputSchema the model expects according to metadata.

"inputSchema":{"fields":[{"name":"features","dataType":{"base":"DOUBLE","shape":{"base":"TENSOR","isNullable":true,"tensorShape":{"dimensions":[{"size":615504,"name":""}]}}}}]}

The following seems to only work when passing just one index (note the double [[ ]], without them I get "Expected collection as JsArray, got 12")

{"schema": {"fields": [{"name": "features", "type": {"type": "tensor", "base": "double", "dimensions": [615504]}}]}, "rows": [[{"dimensions": [615504], "indices": [[12, 3819, 3935]], "values": [1, 1, 1]}]]}

Yet the above returns "Sparse vectors require that the dimension of the indices match the dimension of the values. You provided 1 indices and 3 values"

mhv777 avatar Jun 17 '21 13:06 mhv777