Distributions Monitoring

This demo uses a model trained to predict high or low income based on demographic features from a 1996 US census. In this demo we will observe the predictions and feature distributions of live predictions made using this model with the following steps:

  • Register an income classifier model with the relevant predictions schema

  • Launch a KFServing deployment with the income classifier model

  • Make predictions using a REST requests to the model deployment

  • Observe the feature distributions of the live predictions

  • Filter distributions by time or predictions and feature level filters


This demo needs the request logger to connect to Seldon Deploy in order to fetch model level predictions schema. And this requires specific request logger configuration. Also this feature is supported with many protocols available with deployments like seldon, tensorflow and the kfserving v2 protocol. But not supported for json data, string data, bytes payload or multi-node graph use cases yet.

Register a income classifer model

Register the income classifier SKLearn model with the below URI.



Configure predictions schema

Edit the model metadata to update the predictions schema for the model. The predictions schema is a generic schema structure for machine learning model predictions. It is a definition of feature inputs and output targets from the model prediction. Use the income classifier model predictions schema to edit and save the model level metadata. Learn more about the predictions schema at the ML Predictions Schema open source repository.


Launch a KFServing deployment

Deploy the income classifier model from the catalogue into an appropriate namespace.


Make predictions using the model deployment

Model predictions can be made in the appropriate protocol. In this demo, we will run several single predictions payload examples below:

{ "instances": [[39, 7, 1, 1, 1, 1, 4, 1, 2174, 0, 40, 9]] }
{ "instances": [[50, 7, 1, 1, 1, 1, 4, 1, 2174, 0, 40, 9]] }
{ "instances": [[23, 7, 1, 1, 1, 1, 4, 1, 2174, 0, 40, 9]] }
{ "instances": [[21, 7, 1, 1, 1, 1, 4, 1, 2174, 0, 40, 9]] }
{ "instances": [[25, 7, 1, 1, 1, 1, 4, 1, 2174, 0, 40, 9]] }


Distributions monitoring is especially useful to keep track of predictions when a model makes thousands of predictions in real world scenario. To simulate such a use case, make multiple predictions over time in the Seldon protocol request format using the predictions data csv file and the following shell script which makes around 32560 predictions with an interval of 5 seconds between each request. Note that you need sufficient payload logging infra needed for this.

CLUSTER_IP=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
SERVICE_HOSTNAME=$(kubectl -n seldon get inferenceservice kf-income-classifier -o jsonpath='{.status.url}' | cut -d "/" -f 3)

while IFS= read -r line; do
    curl -k -H "Content-Type: application/json" -H "Host: ${SERVICE_HOSTNAME}" \
        http://$CLUSTER_IP/v1/models/$DEPLOYMENT_NAME:predict \
        -d '{ "instances": [['${line// /,}']] }'
    sleep "${INTERVAL_SECONDS}s"
done <prediction-data.csv

Observe predictions and feature distributions

Select the income classifier deployment and go to the monitor section to view the predictions and feature distributions.


Filter distributions by time or feature level filters

Filter distributions by time or predictions and feature level filters to compare different cohorts and further analysis. For example lets look at the predictions for all individuals in the Age group 25-45 and see how the average prediction frequency changes for this cohort.


Configuring parameters

Distributions parameters configuration allows you to configure your charts for further analysis. For example let’s look at at the charts in the Age group and change the Histogram interval to 11 and Number of time buckets to 30 to see.