SeldonIO / MLServer

An inference server for your machine learning models, including support for multiple frameworks, multi-model serving and more
https://mlserver.readthedocs.io/en/latest/
Apache License 2.0
715 stars 181 forks source link

Fix JSON input shapes #1679

Closed ReveStobinson closed 6 months ago

ReveStobinson commented 6 months ago

Closes #1678

Fixes JSON Payload input shapes in Pandas DataFrame content type section of User Guide.

For example DataFrame:

A B C
a1 b1 c1
a2 b2 c2
a3 b3 c3
a4 b4 c4

All inputs in JSON payload had "shape": [3] (the number of columns in the DataFrame) instead of "shape": [4] (the number of rows in the DataFrame).

This PR assumes that #1625 is in fact a bug, and that the shape values should not have an extra dimension added to them. If that assumption is incorrect, I would recommend also adding a disclaimer to this section like the one seen in the Numpy Array section before it:

Note

By default, MLServer will always assume that an array with a single-dimensional shape, e.g. [N], is equivalent to [N, 1]. That is, each entry will be treated like a single one-dimensional data point (i.e. instead of a [1, D] array, where the full array is a single D-dimensional data point). To avoid any ambiguity, where possible, the Numpy codec will always explicitly encode [N] arrays as [N, 1].