Prediction Drift Formats

Classification Models

Modzy provides prediction drift calculations for all models that perform a classification task. To ensure your classification model can be configured to measure prediction drift (see Prediction drift for more details), all you have to do is configure your outputs in a specific format.

Output Format

Modzy gives you the flexibility to return your model predictions to the end user in whichever format you prefer. In the case of adding prediction drift, your results object can still include any prediction information you wish to return, but at a minimum, you must include your predictions in a JSON object that accompanies your results object in the following format:

"result": {
  "classPredictions": [
    {
      "class": "",
      "score": <float>
    }
  ]
}

Where the multiple keys in this output dictionary must match the defined naming convention: result :arrow-right: classPredictions. Additionally, the classPredictions component of this results object must be a list of dictionaries representing the top N predictions your classification model makes, where you can decide N, or the number of class predictions your model returns for each input (e.g., if your model is a binary classifier, you may return a list with either both class predictions or just the top prediction. If your model can detect 1000 classes, you may wish to only return the top 5 predictions). Each dictionary in this list must include two key-value pairs:

  1. "class": "", where the value must be a string representing the predicted class
  2. "score": <float>, where the value must be a float value representation of the confidence score associated with the prediction (e.g., 0.95 :arrow-right: 95% confidence score).

Here is an example of the full model output containing properly-formatted drift results from our Image Classification model:

{
  "data": {
    "result": {
      "classPredictions": [
        {
          "class": "pug, pug-dog",
          "score": 1
        },
        {
          "class": "Norwegian elkhound, elkhound",
          "score": 0
        },
        {
          "class": "Brabancon griffon",
          "score": 0
        },
        {
          "class": "chow, chow chow",
          "score": 0
        },
        {
          "class": "bull mastiff",
          "score": 0
        }
      ]
    },
    "drift": null,
    "explanation": null,
  }
}

Did this page help you?