All pages
Powered by GitBook
1 of 11

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Feature Distributions

Distributions monitoring provides an ability to view the statistics and distributions of features and predictions made by your model between any given time. This feature also enables you to draw comparisons between the model predictions for different feature combinations, cohorts and/or time slices. It is a vital aspect of model monitoring cycle to understand if the deployed model has the desired prediction characteristics during different times and for different cohorts.

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:

  • Register an income classifier model with the relevant predictions schema

  • Launch a Seldon Deployment with the income classifier model

  • Run a Batch Job to send predictions to the model deployment

  • Observe the feature distributions of the live predictions

  • Filter distributions by time or predictions and feature level filters

Under the production installation, the following must be installed:

  • (required) - used for storage of live predictions and reference data

  • (required) - used for storage of model metadata (which includes the prediction schema)

  • (required for demo) - allows for batch jobs to be run

In addition to the prerequisites, this demo needs the request logger to connect to Seldon Enterprise Platform in order to fetch model level predictions schema. This requires . Also, this feature is supported with Open Inference Protocol (OIP) only. Support for json data, string data, bytes payload or multi-node graph use cases is not available yet.

Register a pre-trained income classifier SKLearn model.

  1. In the Model Catalog page, click Register a new model:

  2. In the Register New Model wizard, enter the following information, then click Register Model:

Edit the model metadata to update the prediction schema for the model. The prediction 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. Learn more about the predictions schema at the open source repository. Use the income classifier model predictions schema income-classifier-prediction-schema.json to edit and save the model level metadata.

  1. Click the model income-classifier that you registered.

  2. Click Edit Metadata to update the Prediction schema field associated with the model using the contents of prediction schema income-classifier-prediction-schema.json.

Deploy the income classifier model from the catalog into an appropriate namespace

  1. In the Model catalog, select Deploy of the Action dropdown.

  2. Enter the deployment details in the deployment creation wizard and click Next:

    • Name

  1. Click Next for the remaining steps, then click Launch.

In order to observe the predictions and feature distributions, first we need to send some predictions to the model. To simulate such a use case, we are going to run a that will require an input file of predictions formatted according to the . To do so, we need to follow the steps below:

  1. Download the predictions data file predictions.txt.

This is a dataset which contains 60 predictions. The first few lines of the input file 'predictions.txt' should show the following format:

  1. Upload the data to a bucket store of your choice. This demo uses and stores the data at bucket path minio://predictions-data/predictions.txt. Refer to the for an example of how this can be done using the minio browser.

  2. Open the Deployment Dashboard of your deployment by clicking on it in the Overview page.

This will create a new Batch Job that will use the predictions data, located at minio://predictions-data/predictions.txt, to send requests to the model. The output data will be stored at minio://predictions-data/output-data-{{workflow.name}}.txt. The workflow will send requests to the model every 5 seconds using the REST transport protocol, and those will be formatted according to the . We also specify the secret name minio-bucket-envvars which contains the credentials required for access to the MinIO bucket store and the predictions data.

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

Filter distributions by time or predictions and feature level filters to compare different cohorts and further analysis. For example let's look at the predictions for all individuals in the Age group 25-50 and also filter by their Marital Status as Married and Never-Married only and see how the average prediction frequency changes for this cohort.

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 15 and Number of time buckets to 30 to see.

A useful feature for monitoring feature distributions is the ability to compare features against features from a reference dataset. Feature level comparisons allow users to easily gauge which features are actually drifting visually.

Here, we define reference data as a set of data where the distribution of the data is a useful representation of the expected live predictions. Typically, this would be a sampled subset of the training data used to create the inference model.

In this section of the demo, we will extend the distributions monitoring demo and:

  • Show how reference data needs to be prepared before it can be inserted into Seldon Enterprise Platform

  • Create a bucket and upload some reference data onto minio

  • Trigger a retrieval job via the Seldon Enterprise Platform UI

Currently, there is a strict requirement for the types of data that can be inserted into Seldon Enterprise Platform that is dependent on the .

  1. The number of columns in the reference data must match the number of expected columns from the prediction schema. This means that some feature types, (i.e. ONE_HOT and PROBA) may need to be split into dummy/indicator values. For example, a PROBA feature (e.g. the Iris Species form the ) might have 3 categories in the schema:

    However, the raw reference dataset represents this feature as a single column where the values are its categories. This is typically the case for output features where the reference data has the expected real output, while the model returns a probability distribution of the different possible outputs:

Download the income classifier reference dataset income-reference-data.csv. Store it in a bucket of your choice.

In this demo, we will use and create a bucket called reference-data which we can upload the income-reference-data.csv file to.

In your deployment, navigate to the Monitor page and open the Distributions tab. An Add reference data button should be available.

This button opens a wizard where the bucket path and secret can be specified. For this demo, use the following values:

  • Bucket Path: minio://reference-data/

  • Bucket Secret: minio-bucket-envvars

After confirming, the job will start running, and the Add reference data button will change to a Retrieving data... status.

Give the job a few minutes to finish. Once finished, the Retrieving data... button will change to Reference data available. Now, the Toggle reference data toggle will become available to click for every feature, and you can view comparisons of the live prediction distributions against the reference data.

Use the filters to filter both live predictions and reference data.

MinIO (optional) - allows for easy storage of and access to downloaded datasets

Model Name: income-classifier

  • URI: gs://seldon-models/scv2/samples/mlserver_1.6.0/income-sklearn/classifier/

  • Artifact Type: SciKit Learn

  • Version: v1

  • Model configuration wizard

    Click Save Metadata.

    :
    income-classifier
  • Namespace: seldon

  • Type: Seldon Deployment

  • Income classifier deployment details
  • The predictor details should already be filled in from the model catalog except the Model Name field. Use income for the Model Name field.

    • Model Name: income

    The Model Name is linked to the name described in the model-settings.json file, located in the Google Cloud Storage location. Changing the name in the JSON file would also require changing the Model Name, and vice versa.

  • Click the Batch Jobs in the left pane.
  • Create a Batch Job with the following details:

  • Toggle the comparison of live predictions and reference data feature distributions
    Iris Species

    Versicolor

    Setosa

    Virginica

    Virginica

    Setosa

    The processed data should have the following format

    Setosa
    Versicolor
    Virginica

    0

    1

    0

    1

    0

  • The order of columns must match the prediction schema

  • Both "input" and "output" features must be in the reference dataset, where "input" features come before "output" features.

  • {"inputs": [{"name": "income", "datatype": "INT64", "shape": [1, 12], "data": [30, 4, 4, 0, 2, 0, 4, 1, 5013, 0, 40, 9]}]}
    {"inputs": [{"name": "income", "datatype": "INT64", "shape": [1, 12], "data": [30, 4, 1, 0, 6, 0, 4, 1, 2407, 0, 40, 9]}]}
    {"inputs": [{"name": "income", "datatype": "INT64", "shape": [1, 12], "data": [32, 0, 3, 2, 0, 1, 4, 1, 0, 0, 40, 0]}]}
    Input Data Location: minio://predictions-data/predictions.txt
    Output Data Location: minio://predictions-data/output-data-{{workflow.name}}.txt
    Number of Workers: 1
    Number of Retries: 3
    Batch Size: 1
    Minimum Batch Wait Interval (sec): 5
    Method: Predict
    Transport Protocol: REST
    Input Data Type: Open Inference Protocol (OIP)
    Object Store Secret Name: minio-bucket-envvars
    {
       "name": "Iris Species",
       "type": "PROBA",
       "dataType": "FLOAT",
       "schema": [
         {
           "name": "Setosa"
         },
         {
           "name": "Versicolor"
         },
         {
           "name": "Virginica"
         }
       ]
    }

    Prerequisites

    Register an income classifier model

    Configure predictions schema for classifier

    Launch a Seldon Deployment

    Run a Batch Job to send predictions to the model deployment

    Note: If the file containing the predictions data is uploaded to a private bucket storage, ensure that you have configured your storage access credentials secret.

    Observe predictions and feature distributions

    Filter distributions by time or feature level filters

    Configuring parameters

    Reference Data Distributions Comparison

    Note: This feature is experimental and has very limited functionality and only tabular reference data is supported.

    Preprocess Reference Data

    Note

    • Only tabular data that has been processed and saved in CSV format can be retrieved and inserted into Seldon Enterprise Platform as reference data.

    • There are no PROBA or ONE_HOT features in the income dataset used in this demo so no preprocessing is required. Instead, we'll use the Iris dataset.

    Reference Data Storage Bucket

    Trigger Add Reference Data Job

    Note: Here minio-bucket-envvars is a pre-created secret in the namespace containing env vars.

    Toggle Reference Data Feature Distributions Comparison

    Elasticsearch
    Metadata storage
    Argo Workflows
    specific request logger configuration
    ML Predictions Schema
    Batch Job
    Open Inference Protocol
    MinIO
    batch request demo
    Open Inference Protocol
    prediction schema
    Iris Dataset
    minio
    "Register a new model" button on the Model Catalog page
    4KB
    income-classifier-prediction-schema.json
    Open
    Select "income-classifier" model on the Model Catalog page
    Model's metadata wizard
    "Deploy" action in the dropdown on the Model Catalog page
    Income classifier deployment predictor
    7KB
    predictions.txt
    Open
    Predictions and features distributions
    Filters for predictions and features distributions
    Distributions parameters configuration modal
    33KB
    income-reference-data.csv
    Open
    Add reference data
    Reference data

    Seldon Core 1

    To run these demos install Seldon Enterprise Platform with the necessary permissions to create or update deployments.

    Most demos utilize pre-built models, except for the Kubeflow demo, which includes .

    Models can either be:

    • Pushed to MinIO or other object stores for use with pre-packaged model servers.

    • Packaged as Docker containers using language wrappers.

    0

    0

    0

    1

    0

    0

    1

    1

    0

    0

    For detailed guidance on the building and hosting stages, refer to the .

    Regardless of how you install your SeldonDeployments, the Seldon Enterprise Platform should have visibility into the relevant namespaces. These demos utilize the Enterprise Platform UI for simplicity and convenience.

    steps to build a model and push it to MinIO
    Seldon Core documentation

    Drift Detection

    When ML models are deployed in production, sometimes even minor changes in a data distribution can adversely affect the performance of ML models. When the input data distribution shifts then prediction quality can drop. It is important to track this drift. This demo is based on the mixed-type tabular data drift detection method in the alibi detect project for tabular datasets.

    Here we will :

    • Launch an income classifier model based on demographic features from a 1996 US census. The data instances contain a person’s characteristics like age, marital status or education while the label represents whether the person makes more or less than $50k per year.

    • Setup a mixed-type tabular data drift detector for this particular model.

    • Make a batch of predictions over time.

    • Track the drift metrics in the Monitoring dashboard.

    Register a pre-trained income classifier SKLearn model.

    1. In the Model Catalog page, click Register a new model:

    2. In the Register New Model wizard, enter the following information, then click Register Model:

    Edit the model metadata to update the prediction schema for the model. The prediction 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. Learn more about the predictions schema at the open source repository. Use the income classifier model predictions schema income-classifier-prediction-schema.json to edit and save the model level metadata.

    1. Click the model income-classifier that you registered.

    2. Click Edit Metadata to update the Prediction schema field associated with the model using the contents of prediction schema income-classifier-prediction-schema.json.

    Deploy the income classifier model from the catalog into an appropriate namespace

    1. In the Model catalog, select Deploy of the Action dropdown.

    2. Enter the deployment details in the deployment creation wizard and click Next:

      • Name

    1. Click Next for the remaining steps, then click Launch.

    From the deployment overview page, select your deployment to enter the deployment dashboard. Inside the deployment dashboard, add a drift detector with by clicking the Add button within the Drift Detection widget.

    Enter the following parameters in the modal popup which appears, to configure the detector:

    • Model Name: income-drift.

    • Storage URI: (For public Google Buckets, secret field is optional)

    • Reply URL: Leave as the default value, shown below, unless you are using a custom installation, please change this parameter according to your installation

    Then, click CREATE DETECTOR to complete the setup.

    As per the income classifier model, use the same model predictions schema income-classifier-prediction-schema.json to edit and save the model level metadata for drift detector.

    1. Click on the vertical ellipses “⋮” icon for the drift detector you have just registered.

    2. Click the Configure Metadata option to update the prediction schema associated with the model

    3. Paste the downloaded income-classifier-prediction-schema.json, name the model

    1. From the deployment dashboard, click on Batch Jobs. Run a batch prediction job using the Open Inference Protocol (OIP) payload format text predictions data file data.txt.

    This file has 4000 individual data points and based on our drift detector configuration, drift will be detected for a batch every 200 points. The distribution of the data in the first half section is the same as the distribution of the reference data the drift detector was configured with and the second half section of the data should be different to observe drift.

    1. Upload the data to a bucket store of your choice. This demo will use and store the data at bucket path minio://income-batch-data/data.txt . Do not forget to - we have it as minio-bucket-envvars here. Refer to the for an example of how this can be done via the minio browser.

    2. Running a batch job with the configuration below. This runs an offline job that makes a prediction request for a batch of 200 rows in the file at minio://income-batch-data/data.txt every 5 seconds:

    Under the Monitor section of your deployment navigation, on the Drift Detection Tab, you can see a timeline of drift detection metrics.

    The drift dashboard showcases 2 types of metrics graphs:

    1. P-value score over time

      • 1a. Zoomed in view, focusing on features that have drifted, i.e. features that have a p-value score of less than the threshold.

      • 2b. Zoomed out view, showing all features.

    Note that for both drift metrics graphs, the starting batches do not drift and are marked by an empty O symbol, while the later batches do drift and are marked by a filled O symbol.

    If you have you should see a notification about the drift

    with further details present on the alerting log

    To further analyse prediction data drift, you can also switch to the feature distribution tab to compare predictions to reference data distribution. See demo for setup details.

    Upload the income classifier reference dataset drift-reference-v2.csv as the reference data to monitor data drift in terms of feature distributions.

    Once reference data is available, you can compare the distributions of the prediction data to the reference data.

    You can see when reference data is available by checking the button on the top left of the Distributions dashboard. If it is not clickable and displays Reference data available, then reference data is available.

    For each feature, you can click on Toggle reference data to view reference data side by side.

    We will see that the drifted data has lower education individuals that were not in the reference data.

    If you experience issues with this demo, see the and also the or sections.

    Model Name: income-classifier

  • URI: gs://seldon-models/scv2/samples/mlserver_1.6.0/income-sklearn/classifier/

  • Artifact Type: SciKit Learn

  • Version: v1

  • Model configuration wizard

    Click Save Metadata.

    :
    income-classifier
  • Namespace: seldon

  • Type: Seldon Deployment

  • Income classifier deployment details
  • The predictor details should already be filled in from the model catalog except the Model Name field. Use income for the Model Name field.

    • Model Name: income

    The Model Name is linked to the name described in the model-settings.json file, located in the Google Cloud Storage location. Changing the name in the JSON file would also require changing the Model Name, and vice versa.

  • Minimum Batch Size: 200

  • Drift Type: Feature

  • income-drift
    and click
    Save Metadata
    .
    configure prediction schema

    Distance score over time.

    gs://seldon-models/scv2/samples/mlserver_1.6.0/income-sklearn/drift-detector
    http://seldon-request-logger.seldon-logs
    Input Data Location: minio://income-batch-data/data.txt
    Output Data Location: minio://income-batch-data/output-{{workflow.name}}.txt
    Number of Workers: 1
    Number of Retries: 3
    Batch Size: 200
    Minimum Batch Wait Interval (sec): 5
    Method: Predict
    Transport Protocol: REST
    Input Data Type: Open Inference Protocol (OIP)
    Storage Secret Name: minio-bucket-envvars

    This demo requires Knative installation on the cluster as the drift detector will be installed as a kservice. See Knative installation instructions for necessary setup required.

    Register an income classifier model

    Configure predictions schema for classifier

    Launch a Seldon Deployment

    Add a Drift Detector

    Expand to see drift detector creation

    Configure predictions schema for detector

    Run Batch Predictions

    Monitor Drift Detection Metrics

    Monitor Drift Detection Alerts

    Data drift and reference distributions comparison

    Troubleshooting

    ML Predictions Schema
    MinIO
    configure your storage access credentials secret
    batch request demo
    alerting configured
    feature distribution monitoring
    troubleshooting docs
    Knative
    Elasticsearch
    "Register a new model" button on the Model Catalog page
    4KB
    income-classifier-prediction-schema.json
    Open
    Select "income-classifier" model on the Model Catalog page
    Model's metadata wizard
    "Deploy" action in the dropdown on the Model Catalog page
    Income classifier deployment predictor
    select detector
    471KB
    data.txt
    Open
    p-values drift metrics zoomed in
    p-values drift metrics zoomed out
    distance score metrics
    alert notification
    alert notification
    28KB
    drift-reference-v2.csv
    Open
    Reference data available
    Monitor distributions

    Image Explanations

    Understanding how complex models make predictions is essential for promoting transparency, trust, and identifying potential biases. Model explainers offer insights into feature influence on outcomes, supporting debugging and model refinement.

    We are going to demonstrate model explanations using Alibi Explain's Anchor Images method, taking note of the segments in an input image that influenced the prediction the most, as well as, observing the Anchor's Precision and Coverage metrics.

    In this demo we will:

    • Launch an image classification deployment

    • Send prediction requests to the deployment

    • Create an explainer for the deployment

    • Generate explanations for previously sent prediction requests

    The model used in this demo was trained to classify images based on the .

    1. Click on Create new deployment button.

    2. Enter the deployment details as follows:

      • Name: cifar10-classifier

    1. Configure the default predictor as follows:

      • Runtime: Triton (ONNX, PyTorch, Tensorflow, TensorRT)

      • Model Project: default

    1. Click the Next button until the end and, finally, click Launch.

    2. If your deployment is launched successfully, it will have Available status.

    We will make a prediction request using the image of a frog from the cifar10 dataset. The image is a JSON file in the REST format of the .

    1. Click on the cifar10-classifier deployment created in the previous section to enter the deployment dashboard.

    2. Inside the deployment dashboard, click on the Predict button.

    3. On the Predict page, click on Browse

    1. From the cifar10-classifier deployment dashboard, click Add inside the Model Explanation card.

    2. For step 1 of the Explainer Configuration Wizard, select the Image model data type and click Next.

    1. For step 2, make sure Anchor is selected, then click Next.

    2. For step 3, enter the following values in the Explainer URI tab:

      • Explainer URI:

    1. Click the Next button until the end, and finally, click Launch.

    After a short while, the explainer should become available.

    Now that the explainer is available, we can make use of it to generate an explanation for the prediction request we made earlier.

    1. Click on the cifar10-classifier deployment created in the previous sections to enter the deployment dashboard.

    2. Navigate to the Requests page using the left navigation drawer, and you will see the request you made earlier.

    3. Click on the View explanation button to generate an explanation for the request.

    1. After a few seconds, the explanation should be generated and displayed on the page.

    Congratulations, you've created an explanation for the request! 🥳

    Why not try our other ? Ready to dive in? Read our to learn more about how to use Enterprise Platform.

    Text Generation with Custom HuggingFace Model

    In this demo we will:

    • Launch a pretrained custom text generation HuggingFace model in a Seldon Deployment

    • Send a text input request to get a generated text prediction

    The custom HuggingFace text generation model is based on the TinyStories-1M model in the HuggingFace hub.

    Create a Seldon Deployment

    1. In the Overview page, click Create new deployment.

    2. Enter the deployment details as follows, then click Next:

      Parameter
      Value
    3. Configure the default predictor as follows, then click Next:

      Parameter
      Value
    1. Skip to the end and click Launch.

    When your deployment is launched successfully the status will read as Available.

    1. Click the hf-custom-tiny-stories deployment that you created.

    2. In the Deployment Dashboard page, click Predict in the left pane.

    3. In the Predict page, click Enter JSON

    Congratulations, you've successfully sent a prediction request using a custom HuggingFace model! 🥳

    Why not try our other ? Or perhaps try running a larger-scale model? You can find one in s://seldon-models/scv2/samples/mlserver_1.6.0/huggingface-text-gen-custom-gpt2. However, you may need to request more memory!

    Batch Prediction Jobs

    MinIO should already be installed with Seldon Enterprise Platform. The MinIO browser should be exposed on /minio/ (note the trailing forward slash).

    For trials, the credentials will by default be the same as the Enterprise Platform login, with MinIO using the email as its Access Key and the password as its Secret Key.

    On a production cluster, the namespace needs to have been set up with a service account. This can be found under the .

    This demo helps you learn about:

    Outlier Detection

    In a production environment, it is critical to monitor the data your machine learning model runs inference on, as changes in data can adversely affect the performance of ML models.

    In this demo learn how to identify outliers in your inference data using Alibi Detect's method for tabular datasets.

    In this demo, we will:

    • Launch an image classification deploying with a model, trained on the .

    Namespace: seldon
  • Type: Seldon Deployment

  • Model URI: gs://seldon-models/triton/tf_cifar10
  • Storage Secret: (leave blank/none)

  • Model Name: cifar10

  • to select and upload the previously downloaded prediction file.
  • Click the Predict button, the prediction request should be successful and the response should be shown.

  • gs://seldon-models/tfserving/cifar10/cifar10_anchor_image_py3.7_alibi-0.7.0
  • Model Project: default

  • Storage Secret: (leave blank/none)

  • Create a Seldon Deployment

    The Model Name is linked to the name described in the model-settings.json file, located in the Google Cloud Storage location. Changing the name in the JSON file would also require changing the Model Name, and vice versa.

    Get Predictions

    Add an Anchor Image Explainer

    Get an explanation for the request

    Next Steps

    CIFAR10 dataset
    Open Inference Protocol (OIP)
    demos
    operations guide
    Deployment details
    Default predictor
    85KB
    cifar10-frog-oip.json
    Open
    Successful prediction using a JSON file
    Explainer Model Data Type
    Explainer URI
    Previously made prediction request with its predicted response
    The frog image segments that influenced the prediction the most
    The Precision and Coverage Anchor metrics
    Perturbed samples of the prediction request which comply with the prediction
    configure drift detector
    create drift detector

    seldon

    Type

    Seldon Deployment

    Deployment Details

    default

    Model URI

    gs://seldon-models/scv2/samples/mlserver_1.6.0/huggingface-text-gen-custom-tiny-stories

    Storage Secret

    (leave blank/none)

    Model Name

    transformer

    and paste the following text:
  • Click the Predict button.

  • Name

    hf-custom-tiny-stories

    Runtime

    HuggingFace

    The Model Name is linked to the name described in the model-settings.json file, located in the Google Cloud Storage location. Changing the name in the JSON file would also require changing the Model Name, and vice versa.

    1. The seldon and seldon-gitops namespaces are installed by default, which may not always be available. Select a namespace which best describes your environment.

    2. A secret may be required for private buckets.

    3. Additional steps may be required for your specific model.

    Get Prediction

    Next Steps

    demos
    Default Predictor
    A screenshot showing the Predict page with the textarea prepopulated and the result of the prediction

    Namespace

    Model Project

    {
      "inputs": [{
        "name": "args",
        "shape": [1],
        "datatype": "BYTES",
        "data": ["The brown fox jumped"]
      }]
    }
    Deploying a deployment with a pre trained SKlearn iris model
  • Running a batch job to get predictions

  • Checking the output

    1. Click on Create new deployment button.

    2. Enter the deployment details as follows:

      • Name: batch-demo

      • Namespace: seldon

      • Type: Seldon Deployment

    3. Configure the default predictor as follows:

      • Runtime: Scikit Learn

      • Model URI: gs://seldon-models/scv2/samples/mlserver_1.6.0/iris-sklearn

    1. Skip Next for the remaining steps, then click Launch.

    2. If your deployment is launched successfully, it will have Available status, on the overview page.

    1. Download the input data file iris-input.txt.

    The first few lines of the input file `iris-input.txt` should show the following format:

    1. Go to the MinIO browser and use the button in the bottom-right to create a bucket. Call it data.

    2. Again from the bottom-right choose to upload the iris-input.txt file to the data bucket.

    1. Click the new deployment batch-demo in the Overview page.

    2. Click the Batch Jobs in the left pane.

    3. Click Create Your First Job, enter the following details, and click Submit:

      • Input Data Location: minio://data/iris-input.txt

      • Output Data Location: minio://data/iris-output-{{workflow.name}}.txt

      • Number of Workers: 5

      • Number of Retries: 3

      • Batch Size: 10

      • Minimum Batch Wait Interval (sec) : 0

      • Method: Predict

      • Transport Protocol: REST

      • Input Data Type: Open Inference Protocol (OIP)

      • Object Store Secret Name: minio-bucket-envvars

    4. Give the job a couple of minutes to complete, then refresh the page to see the status.

    5. Inspect the output file in MinIO:

    miniooutput

    If you open that file you should see contents such as:

    If not, see the argo section for troubleshooting.

    Pre-requisites

    Other cloud storage services, such as S3 and GCS, can be specified alternatively with the corresponding secret files configured.

    argo install documentation
    {"inputs":[{"name":"predict","data":[0.38606369295833043,0.006894049558299753,0.6104082981607108,0.3958954239450676],"datatype":"FP64","shape":[1,4]}]}
    {"inputs":[{"name":"predict","data":[0.7223678219956075,0.608521741883582,0.8596266157372878,0.20041864827775757],"datatype":"FP64","shape":[1,4]}]}
    {"inputs":[{"name":"predict","data":[0.8659159480026418,0.2383384971368594,0.7743518759043038,0.8748919374334038],"datatype":"FP64","shape":[1,4]}]}
    {"model_name":"","outputs":[{"data":[0],"name":"predict","shape":[1],"datatype":"INT64"}],"parameters":{"batch_index":0}}
    {"model_name":"","outputs":[{"data":[0],"name":"predict","shape":[1],"datatype":"INT64"}],"parameters":{"batch_index":2}}
    {"model_name":"","outputs":[{"data":[1],"name":"predict","shape":[1],"datatype":"INT64"}],"parameters":{"batch_index":4}}
    {"model_name":"","outputs":[{"data":[0],"name":"predict","shape":[1],"datatype":"INT64"}],"parameters":{"batch_index":1}}

    Create a Deployment

    The Model Name is linked to the name described in the model-settings.json file, located in the Google Cloud Storage location. Changing the name in the JSON file would also require changing the Model Name, and vice versa.

    Setup Input Data

    Run a Batch Job

    In the Resources (Optional) section, you can specify how much memory and CPU are allocated to the containers in this specific batch job workflow. If no values are set on this form, the default values specified in Helm values will be used. Refer to the for details.

    Expand to see batch job status

    15KB
    iris-input.txt
    Open
    Set up an VAE outlier detector for this particular model
  • Send a request to get an image classification

  • Send a perturbed request to identify an outlier instance

    1. In the Overview page, click Create new deployment.

    2. Enter the deployment details as follows:

      • Name: cifar10-classifier

      • Namespace: seldon

      • Type: Seldon Deployment

    Deployment details
    1. Configure the default predictor as follows:

      • Runtime: Triton (ONNX, PyTorch, Tensorflow, TensorRT)

      • Model Project: default

      • Model URI: gs://seldon-models/triton/tf_cifar10

      • Storage Secret: (leave blank/none)

      • Model Name: cifar10

    Default predictor
    1. Click the Next button until the end and, finally, click Launch.

    2. If your deployment is launched successfully, it will have Available status.

    1. From the cifar10-classifier deployment dashboard, click Add inside the Outlier Detection card.

    2. Configure the detector with the following values:

      • Detector Name: outlier-detect

      • Storage URI: gs://seldon-models/scv2/examples/cifar10/outlier-detector

      • Project: default

      • Storage Secret: (leave blank)

      • Reply URL: http://seldon-request-logger.seldon-logs

    Outlier Detector
    1. Click Create Detector to complete the setup.

    2. After a short while, the detector should become available.

    Now that the outlier detector available, we can showcase how to make use of it to identify outliers in the inference data. We are going to send 2 requests to the model, one with a normal image and another with a perturbed image to identify the outlier.

    A frog image from the CIFAR-10 dataset in the Open Inference Protocol (OIP) format:

    A perturbed image of the same frog in the Open Inference Protocol (OIP) format:

    1. In the deployment dashboard of click Predict in the left pane..

    2. Click Browse to upload the cifar10-frog-oip.json file.

    3. Click Predict. The prediction request is processed and the response is displayed.

    4. Click Remove to remove the uploaded file

    5. Click Browse again to make a prediction with the perturbed image of the frog using the cifar10-frog-perturbed-oip.json file. The prediction request is processed and the response is displayed.

    Navigate to the Requests page using the left navigation drawer to view the requests made to the model and their prediction responses. Outlier scores will be available on the right side of each instance.

    Previously made prediction requests with their prediction responses and outlier scores

    You can also highlight outlier prediction responses using the Highlight Outliers toggle on the top-right of the screen.

    Highlighted outlier prediction requests with their prediction responses and outlier scores

    Furthermore, you can filter the requests to show only the outliers by clicking on the Filter icon in the top right(next to the Page number) and selecting the Outliers option, toggling to show only outliers or not.

    A highlighted outlier prediction after applying a filter to show only outliers

    It is important to be able to monitor the outlier detection requests in real-time to ensure that the model is performing as expected and to take corrective actions when necessary.

    1. Click Monitor in the left pane.

    2. Select the Outlier Detection tab to view a timeline graph of outlier/inlier requests.

    A timeline graph showing the first request classified as an inlier and the second as an outlier

    Congratulations, you've successfully demonstrated how to identify outliers in your inference data using Alibi Detect's VAE outlier detection method! 🥳

    Why not try our other demos? Ready to dive in? Read our operations guide to learn more about how to use Enterprise Platform.

    If you experience issues with this demo, see the troubleshooting docs and also the Knative or Elasticsearch sections.

    VAE outlier detection
    CIFAR-10 dataset

    This demo requires Knative installation on the cluster as the drift detector will be installed as a kservice. See for necessary setup required.

    Create a Seldon Deployment

    The Model Name is linked to the name described in the model-settings.json file, located in the Google Cloud Storage location. Changing the name in the JSON file would also require changing the Model Name, and vice versa.

    Add an Outlier Detector

    Make Predictions

    View and highlight outlier detection results

    Real-Time Outlier Monitoring

    Next Steps

    Troubleshooting

    85KB
    cifar10-frog-oip.json
    Open
    81KB
    cifar10-frog-perturbed-oip.json
    Open

    Text Explanations

    This demo helps you learn about:

    • Launching a movie sentiment pipeline which takes text input

    • Sending a request to get a sentiment prediction

    • Creating an explainer for the model

    • Sending the same request and then get an explanation

    The explainer uses the to provide insight into why a particular classification was made by the model. We'll see patterns in input text that are most relevant to the prediction outcome.

    1. In the Overview page, click Create new deployment.

    2. Type the following deployment details and click Next:

      Parameter
      Value
    1. Click Next for the remaining steps in the Deployment Creation Wizard and then click Launch.

    1. Click the movie deployment that you created.

    2. In the Deployment Dashboard, click Predict in the left pane.

    3. In the Predict page, click Enter JSON and paste the following text:

    1. In the Deployment Dashboard page for the deployment movie, click Add inside the MODEL EXPLANATION card.

    2. In the Explainer Configuration Wizard, choose Text and click Next.

    3. In the Explainer Types step, choose the Anchor

    After sometime, the explainer should become available.

    1. In the Deployment Dashboard for the deployment named movie, click Predict in the left pane.

    2. In the Predict page, click Enter JSON and once again paste the following text and click Predict:

    3. Click Explain to generate explanations for the request.

    Try the other or read our to learn more about how to use Seldon Enterprise Platform.

    Canary Promotion

    In this demo, we will:

    • Deploy a pretrained SKLearn classification model based on the Iris dataset

    • Load test the model with prediction data

    • Observe the prediction requests and their responses

    [1]
    [2]
    Model Project: default
  • Storage Secret: (leave blank/none)

  • Model Name: iris

  • Note: In this job minio-bucket-envvars is a pre-created secret in the same namespace as the model, containing environment variables.

    Kubernetes documentation on requests and limits
    deployment wizard details step
    batchjobstatus
    Knative installation instructions

    Name

    movie

    Namespace

    seldon

    Type

    Seldon Deployment

  • Configure the default predictor as follows:

    Parameter
    Value

    Runtime

    Scikit Learn

    Model Project

  • Click Predict.
    option and click
    Next
    .
  • In the Explainer URI step, set the following details:

    - Explainer URI: gs://seldon-models/scv2/examples/moviesentiment/explainer
    - Explainer Project: default
  • Click Next for the remaining steps without changing any fields, and click Launch.

  • {
      "parameters": {
        "content_type": "str"
      },
      "inputs": [{
        "name": "text review",
        "shape": [1],
        "datatype": "BYTES",
        "data": ["this film has bad actors"]
      }]
    }
    {
      "parameters": {
        "content_type": "str"
      },
      "inputs": [{
        "name": "text review",
        "shape": [1],
        "datatype": "BYTES",
        "data": ["this film has bad actors"]
      }]
    }

    Create a Seldon Deployment

    The Model Name is linked to the name described in the model-settings.json file, located in the Google Cloud Storage location. Changing the name in the JSON file would also require changing the Model Name, and vice versa.

    • The seldon and seldon-gitops namespaces are installed by default, which may not always be available. Select a namespace which best describes your environment.

    • A secret may be required for private buckets.

    • Additional steps may be required for your specific model.

    Get Predictions

    Add an Anchor Text Explainer

    • It is only possible to create one explainer for each deployment.

    • You can also enter a comment here for a gitops enabled namespace.

    Get Explanation for one Request

    Note: If the explainer is making use of parameters.content_type field, View explanation button from the Requests dashboard then it leads to the server error. The /explain API works as expected if parameters.content_type is included in the request input.

    Next Steps

    anchor technique
    demos
    operations guide
    Default predictor details
    the Predict page with the textarea prepopulated
    Explainer URI details
    Resending the prediction
    Explaining the request

    Observe the utilization metrics for the model

  • Deploy a canary XGBoost model

  • Load test canary model with prediction data

  • Observe and compare the prediction requests and metrics for both models

  • Promote the canary model

  • You can use SKLearn classification model based on the well-known Iris dataset. This dataset includes 150 samples of iris flowers, each with 4 features: sepal length, sepal width, petal length, and petal width, measured in centimeters. The samples are labeled by iris species—setosa, versicolor, and virginica—with an even distribution across these classes.

    1. In the Overview page, click Create new deployment.

    2. In the Deployment Creation Wizard, enter the following deployment details and click Next:

      • Name: iris-classifier

      • Namespace: seldon

      • Type: Seldon Deployment

    Deployment details
    1. Configure the default predictor as follows and click Next:

      • Runtime: Scikit Learn

      • Model URI: gs://seldon-models/scv2/samples/mlserver_1.6.0/iris-sklearn

      • Model Project: default

      • Storage Secret: (leave blank/none)

      • Model Name: iris

    Default predictor spec
    1. Click Next for the remaining steps, then click Launch.

    2. When your deployment is launched successfully, the status reads Available.

    1. Once the deployment is in an Available status, navigate to its Dashboard page by clicking on it.

    2. In the Dashboard page, scroll down to find the Requests Monitor section and click Start a load test with the following details:

      • Connections(total): 1

      • Load Parameter: Duration(seconds)

      • Value: 120

      • JSON payload:

    Load Test Wizard

    This will create a Kubernetes Job that will be sending prediction requests for the specified seconds to the SKLearn model in the deployment.

    After the load test has started, you can monitor the upcoming requests and their responses by navigating to the Requests page of the deployment.

    Requests page showing prediction requests and their responses

    You can also monitor live requests metrics resulting from the load test if you navigate back to the Dashboard page of the deployment, and scroll down to the Live Requests section. In this screenshot you can see the number of requests per second and the average latency of the model.

    Live Requests section showing the number of requests per second and the average latency of the model

    Furthermore, you can monitor the utilization metrics for the model in the Dashboard page of the deployment. Scroll down to the Resource Monitor section to see the CPU and memory utilization of the model.

    Resource Monitor section showing the CPU and memory utilization of the model

    The next step is to create an XGBoost canary model that shares a percentage of the traffic with the main model.

    1. Navigate to the Dashboard of the deployment and click Add Canary.

    2. In the Update Deployment Wizard, configure the default predictor as follows:

      • Runtime: XGBoost

      • Model URI: gs://seldon-models/xgboost/iris

      • Model Project: default

      • Storage Secret: (leave blank/none)

      • Canary Traffic Percentage: 10

      • Model Name: iris

    Canary Deployment Wizard
    1. Click on Next for the remaining steps, then click Launch.

    2. While the canary model is being launched, the deployment status changes to an Updating state.

    3. When the canary model is launched successfully, the deployment status becomes Available.

    Create a new canary deployment with the XGBoost model and roughly 10% of the traffic is sent to it.

    This time, we will create a new load test with the canary model running and observe the requests and metrics for both models. You can use either the same JSON payload from the previous load test or construct a new one with different values or number of predictions.

    After the second load test has started, you can monitor the upcoming requests and their responses by navigating to the Requests page of the deployment. Since we have two models running, you can choose to filter the requests by the model name to see the requests and responses for each model. In order to see the requests and responses for the canary model, you can filter the requests by clicking on the reverse pyramid icon, then click on the Node Selector dropdown, and, finally, select the canary predictor.

    Requests page showing prediction requests and their responses for the canary model

    You can also monitor live requests metrics for the both models if you navigate back to the Dashboard page of the deployment, and scroll down to the Live Requests section. In this screenshot you can see the number of requests per second and the average latency for both models. As expected, the main model is receiving more requests than the canary model, so the number of requests per second for the main model is higher.

    Live Requests section showing the number of requests per second and the average latency for both models

    Furthermore, you can monitor the utilization metrics for both models in the Dashboard page of the deployment. Scroll down to the Resource Monitor section to see the CPU and memory utilization for both models.

    Resource Monitor section showing the CPU and memory utilization of the model

    Great! Now we have observed the requests and metrics for both models. If we are happy with how the canary model is performing, we can promote it to become the main model.

    1. Navigate to the Dashboard of the deployment and click on the Promote Canary button.

    2. In the Promote Canary dialog, click Confirm to promote the canary model to the main model.

    3. If the canary model is promoted successfully, the deployment status will become Available.

    The canary model has been successfully promoted to be the main model of the deployment
    {
      "inputs": [
        {
          "name": "predict",
          "data": [
            0.38606369295833043,
            0.006894049558299753,
            0.6104082981607108,
            0.3958954239450676
          ],
          "datatype": "FP64",
          "shape": [
            1,
            4
          ]
        }
      ]
    }

    Iris Model

    Launch a Seldon Deployment

    The Model Name is linked to the name described in the model-settings.json file, located in the Google Cloud Storage location. Changing the name in the JSON file would also require changing the Model Name, and vice versa.

    Start Load Test

    Observe the prediction requests and their responses

    Observe the utilization metrics for the model

    Deploy a Canary model

    The Model Name is linked to the name described in the model-settings.json file, located in the Google Cloud Storage location. Changing the name in the JSON file would also require changing the Model Name, and vice versa.

    Note: The deployment status represents the overal status of the deployment, including the main and canary models.

    Load test the canary model

    Remember that roughly 10% of the traffic is sent to the canary model. If, however, the canary model is not available, all the traffic is sent to the main model.

    Observe the prediction requests and their responses for both models

    Observe the utilization metrics for both models

    Promote the Canary model

    Model Accuracy

    Iris is the genus of flower which contains 3 species: setosa, versicolor, and virginica. This demo is based on iris classification model based on flower properties like sepal length, sepal width, petal length, and petal width. The species are also the classes that will be used for the classification. Here we will:

    • Set up a metrics server for the pre-existing iris classifier deployment

    • Send a request to get an iris classification

    Tabular Explanations

    In this demo we will:

    • Create a deployment which can be used to classify tabular data

    • Create an explainer that will offer insight into why a particular prediction was made for a given input

    • Send a prediction request to the deployment

    default

    Model URI

    gs://seldon-models/scv2/examples/moviesentiment/classifier

    Storage Secret

    (leave blank/none)

    Model Name

    movies

    Send feedback requests to gather accuracy metrics
    1. Use the pre-existing iris classifier deployment with the Seldon inference protocol

    2. From the Dashboard page, click on Add in the Metrics Server panel:

      • Detector Name: multiclass

      • Storage URI: adserver.cm_models.multiclass_numeric.MultiClassNumeric

      • Storage Secret: Leave empty as we are using a public bucket

      • Reply URL: Leave as default value, http://seldon-request-logger.seldon-logs

    Run a single prediction using the ndarray payload format. Make a couple of these requests at random using the predict tool in the UI.

    1. Go to the Predict page.

    2. Paste in the following JSON data for the prediction, and click the Predict button:

      {
        "data": {
          "names": [
            "Sepal length",
            "Sepal width",
            "Petal length",
            "Petal Width"
          ],
          "ndarray": [
            [
              6.8,
              2.8,
              4.8,
              1.4
            ]
          ]
        }
      }
    3. Inspect the response, to see that the class with the highest confidence is the second of the iris dataset, versicolor.

      {
        "data": {
          "names": [
            "t:0",
            "t:1",
            "t:2"
          ],
          "ndarray": [
            [
               0.008074020139119268,
               0.7781601484223357,
               0.21376583143854502
            ]
          ]
        },
        "meta": {
          "requestPath": {
          "iris-accuracy-container": "seldonio/sklearnserver:1.18.2"
          }
        }
      }

    As we saw the prediction response was versicolor (the second class of iris). In numeric form the response is,

    A feedback request consists of the returned value in a response (response.data on line 5) and a truth value (truth.data on line 12), for that data. For example, a true-positive feedback request looks like this:

    We'll send several feedback requests to the metrics server, that we set-up earlier, for various scenarios.

    1. Set-up the environment variable(s) for the request:

      export CLUSTER_IP=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')

      (Recommended) You may also need to set-up for the Authorization header:

      1. Return to the predict page, and paste in the prediction, as you did above

      2. Click the Copy as curl button, and copy the value that looks like Bearer <authorization header>

      1. Set the environment variable:

    2. Scenario 1: True-positive:

      Request without Authorization header:

      Request with Authorization header:

      Response:

    3. Scenario 2: False-positive:

      The difference from the previous scenario is the in the truth value:

      Request without Authorization header:

      Request with Authorization header:

      Response:

    Having done a prediction, metrics will begin to become available.

    1. Go to the monitor screen's Prediction Accuracy tab to view all the metrics.

    2. Set the time range to view the metrics, using the "From Time" and "To Time" selectors.

    3. You can see metrics like accuracy, precision, recall and specificity here. Notice the drop in accuracy metrics after the false feedback was received.

    Now we will submit a feedback as a batch using the Batch Processor component.

    We will use two files, each containing 10k feedback instances:

    • 90% success rate feedback file

    • 40% success rate feedback file

    1. We need to upload the files to MinIO's data bucket. For details on interacting with MinIO UI please see Batch Demo.

    2. Once the files are in the MinIO bucket, go to the Batch Jobs screen using either the navigation bar on the left side or with the button on the model dashboard. For each of feedback-input-90.txt and feedback-input-40.txt files, submit a batch job. Wait for the first to complete before proceeding to the next. Submit batch request using the following form values:

      • Input Data Location: minio://data/feedback-input-40.txt

      • Output Data Location: minio://data/output-data-40-{{workflow.name}}.txt

      • Number of Workers: 15

      • Number of Retries: 3

      • Batch Size: 1

      • Minimum Batch Wait Interval (sec): 0

      • Method: Feedback

      • Transport Protocol: REST

      • Input Data Type: Raw Data

      • Object Store Secret Name: minio-bucket-envvars

      • Resources: Leave defaults

    3. Now go to the monitor view and observe how metrics value evolve over time.

    If you experience issues with this demo, see the troubleshooting docs and also the Knative or Elasticsearch sections.

    {
      "data": {
        "ndarray": [
          1
        ]
      }
    }
    {
      "response": {
        "data": {
          "ndarray": [
            1
          ]
        }
      },
      "truth": {
        "data": {
          "ndarray": [
            1
          ]
        }
      }
    }

    This demo requires Knative installation on the cluster as the metrics server will be installed as a kservice. Also, the metrics server only works with classification models in this version.

    These model metrics are only supported for pre-existing Seldon Core 1 deployments with the Seldon inference protocol. Seldon now recommends adopting the industry-standard Open Inference Protocol (OIP) in preference to the Seldon protocol. Seldon has a separate module to support the calculation of model performance metrics with the Open Inference Protocol. Please contact your customer success representative to learn more.

    Setup Metrics Server

    Make Predictions

    Send Feedback

    Monitor accuracy metrics on the Monitor Screen

    Submit batch feedback using Batch Processor component

    Troubleshooting

    762KB
    feedback-input-90.txt
    Open
    762KB
    feedback-input-40.txt
    Open

    View the explanation

    Register a pre-trained income classifier SKLearn model.

    1. In the Model Catalog page, click Register a new model:

      "Register a new model" button on the Model Catalog page
    2. In the Register New Model wizard, enter the following information, then click Register Model:

      • Model Name: income-classifier

      • URI: gs://seldon-models/scv2/samples/mlserver_1.6.0/income-sklearn/classifier/

      • Artifact Type: SciKit Learn

      • Version: v1

    Edit the model metadata to update the prediction schema for the model. The prediction 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. Learn more about the predictions schema at the ML Predictions Schema open source repository. Use the income classifier model predictions schema income-classifier-prediction-schema.json to edit and save the model level metadata.

    1. Click the model income-classifier that you registered.

      Select "income-classifier" model on the Model Catalog page
    2. Click Edit Metadata to update the Prediction schema field associated with the model using the contents of prediction schema income-classifier-prediction-schema.json.

      Model's metadata wizard
    3. Click Save Metadata.

    Deploy the income classifier model from the catalog into an appropriate namespace

    1. In the Model catalog, select Deploy of the Action dropdown.

      "Deploy" action in the dropdown on the Model Catalog page
    2. Enter the deployment details in the deployment creation wizard and click Next:

      • Name: income-classifier

      • Namespace: seldon

      • Type: Seldon Deployment

    3. The predictor details should already be filled in from the model catalog except the Model Name field. Use income for the Model Name field.

      • Model Name: income

    Income classifier deployment predictor
    1. Click Next for the remaining steps, then click Launch.

    1. Click the income-classifier deployment that you created.

    2. In the deployment dashboard, click Predict in the left pane.

    3. In the Predictpage, click Enter JSON and paste the following request payload:

    1. Click Predict.

    The Seldon Enterprise Platform supports several explanation methods for prediction requests. In this demo, you can learn about using these two methods:

    • Anchor Explainer

    • Kernel SHAP Explainer

    The Anchor Explainer can be used to generate explanations for tabular data, text, and image classification models. Whereas, the Kernel SHAP Explainer can be used to generate explanations for only tabular data classification models. You can use the tabular data classification capabilities of these methods because the income-classifier deployment is considered a tabular data classification model.

    1. In the income-classifier deployment dashboard, click Add in the MODEL EXPLANATION card.

    2. In the Model Data Type tab, select the Tabular model data type option and click Next.

    3. In the Explainer Types tab, select the Anchor explainer type option and click Next.

    4. In the Explainer URI tab, enter the following details:

      • Explainer URI: gs://seldon-models/scv2/samples/mlserver_1.6.0/income-sklearn/anchor-explainer

      • Explainer Project: default

    Using the Anchor Explainer URI
    1. Click Next for the remaining steps, then click Launch.

    2. If your explainer is launched successfully, both the deployment and the explainer will show an Available status.

    1. From the income-classifier deployment dashboard, click Add inside the Model Explanation card.

    2. In the Model Data Type tab, select the Tabular model data type option and click Next.

    3. In the Explainer Types tab, select the KernelShap explainer type option and click Next.

    4. In the Explainer URI tab, enter the following details:

      • Explainer URI: gs://seldon-models/scv2/samples/mlserver_1.6.0/income-sklearn/kernel-shap-explainer-sd

      • Explainer Project: default

    Using the Kernel SHAP Explainer URI
    1. Click Next for the remaining steps, then click Launch.

    2. If your explainer is launched successfully, both the deployment and the explainer will show an Available status.

    Once the explainer of choice is successfully launched, you can now generate explanations for the prediction request made earlier.

    1. Navigate to the Requests page using the left navigation drawer.

    2. Click on the View explanation button to generate explanations for the request.

    The Anchor explanation reveals which features most contributed to the classification of 'Low Income'. Here, for around 87% of the training data, a 'Relationship' of 'Unmarried' correlates to Low Income. Having a 'Sex' of 'Female' also correlates but is a less strong indicator. At the bottom-most screenshot, we are shown other examples of Low Income data points. This helps to reveal the patterns that the model is relying on to make predictions.

    The explanation page showing the original prediction request and the predicted class - Low Income
    The explanation summary consisting of the key contributing features towards the predicted class, and their request input values
    The Anchor metrics of the explanation: Precision and Coverage
    Perturbed variation samples of the prediction request which comply with the prediction

    The Kernel SHAP explanation, on the other hand, reveals the top 6 contributing features towards the predicted class of 'Low Income'. The features and their corresponding SHAP values shown in the purple bars indicate the most influential features towards the predicted class, whereas the blue bars indicate the features contributing the most towards the opposite class of 'High Income'. Here, the most influential 'positive' features are 'Marital Status' of 'Separated', followed by 'Sex' of 'Female, 'Race' of 'Black, and others. The most influential 'negative' features are 'Occupation' of 'White-Collar', 'Hours per week' of '60', 'Age' of '53', and others.

    The explanation page showing the original prediction request and the predicted response
    The explanation summary consisting of the key contributing features towards the predicted class, and the correspoding SHAP values

    Congratulations, you've created an explanation for the request! 🥳

    Why not try our other demos? Ready to dive in? Read our operations guide to learn more about how to use Enterprise Platform.

    {
      "inputs": [
        {
          "name": "income",
          "datatype": "INT64",
          "shape": [1, 12],
          "data": [53, 4, 0, 2, 8, 4, 2, 0, 0, 0, 60, 9]
        }
      ]
    }

    Note: This demo uses a model trained to predict high or low income based on .

    Register an income classifier model

    Configure predictions schema for classifier

    Launch a Seldon Deployment

    Make a prediction

    Add an Explainer

    Add an Anchor Explainer

    Add a Kernel SHAP Explainer

    Note: If in the previous step you added the Anchor explainer, and you would like to use the Kernel SHAP explainer instead, you can do so by removing the Anchor explainer first. You will need to click on the ellipsis inside the Model Explanation card, select the Delete button, and confirm the deletion of the Anchor explainer.

    Explain a prediction

    An explanation made using the Anchor Explainer

    An explanation made using the Kernel SHAP Explainer

    Next Steps

    4KB
    income-classifier-prediction-schema.json
    Open
  • Storage Secret: (leave blank/none)

  • Storage Secret: (leave blank/none)

  • The Model Name is linked to the name described in the model-settings.json file, located in the Google Cloud Storage location. Changing the name in the JSON file would also require changing the Model Name, and vice versa.

    demographic features from a 1996 US census
    Model configuration wizard
    Income classifier deployment details
    export AUTH_TOKEN="<paste the authorization value>"
    curl -k \
        -H "Content-Type: application/json" \
        https://$CLUSTER_IP/seldon/seldon/iris-accuracy/api/v0.1/feedback \
        -d '{"response":{"data":{"ndarray":[1]}},"truth":{"data":{"ndarray":[1]}}}'
    curl -k \
        -H "Content-Type: application/json" \
        -H "Authorization: $AUTH_TOKEN" \
        https://$CLUSTER_IP/seldon/seldon/iris-accuracy/api/v0.1/feedback \
        -d '{"response":{"data":{"ndarray":[1]}},"truth":{"data":{"ndarray":[1]}}}'
    {
      "data": {
         "tensor": {
         "shape": [
             0
           ]
          }
        },
        "meta": {
         "requestPath": {
           "iris-accuracy-container": 1.18.2
        }
      }
    }
    -   -d '{"response":{"data":{"ndarray":[1]}},"truth":{"data":{"ndarray":[1]}}}'
    +   -d '{"response":{"data":{"ndarray":[1]}},"truth":{"data":{"ndarray":[0]}}}'
    curl -k \
        -H "Content-Type: application/json" \
        https://$CLUSTER_IP/seldon/seldon/iris-accuracy/api/v0.1/feedback \
        -d '{"response":{"data":{"ndarray":[1]}},"truth":{"data":{"ndarray":[0]}}}'
    curl -k \
        -H "Content-Type: application/json" \
        -H "Authorization: $AUTH_TOKEN" \
        https://$CLUSTER_IP/seldon/seldon/iris-accuracy/api/v0.1/feedback \
        -d '{"response":{"data":{"ndarray":[1]}},"truth":{"data":{"ndarray":[0]}}}'
    {
      "data": {
         "tensor": {
         "shape": [
             0
           ]
          }
        },
        "meta": {
         "requestPath": {
           "iris-accuracy-container": 1.18.2
        }
      }
    }
    metrics server
    Copying aithorization header
    metrics server