Search code examples
azureazure-machine-learning-service

How to generate Inference Schema for Dictionary with nested structure using Azure InferenceSchema package?


In Advanced Scoring Scripting for AzureML webservice, to automatically generate a schema for our web service, we provide a sample of the input and/or output in the constructor for one of the defined type objects. The type and sample are used to automatically create the schema. To use schema generation, we include the open-source inference-schema package version 1.1.0 or above. The types that I can find include Numpy Type, Pandas Type, Abstract Parameter type. How do we define the schema for a Nested Dictionary of (generalized) format:

{    "top_level_key": [
                         {"nested_key_1": "string_1",
                          "nested_key_2": <float_number>, 
                          "nested_key_3": <True/False>}
                      ]
}

Solution

  • we don’t have a good way to extend the handling for generic Python class objects. However, we are planning to add support for that, basically by providing more information on the necessary hooks, and allowing users to extend a base class to implement the hook to match the desired class structure. These types are currently supported:

    pandas numpy pyspark Standard Python object

    https://learn.microsoft.com/en-us/azure/machine-learning/how-to-deploy-advanced-entry-script#automatically-generate-a-swagger-schema