- AI with Armand
- Posts
- Build your first Trustworthy AI system
Build your first Trustworthy AI system
Step-by-step tutorial
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/1cccd278-cc42-4b3d-9402-2d11693daf8b/Copy_of_the_flowchart__8_.png?t=1699658243)
Welcome to the 697 new members this week! nocode.ai now has 18,251 subscribers.
This tutorial walks through a no-code AI experience to monitor models in production. We will use a tool called IBM OpenScale with Auto setup, which makes a model, deploys it, and adds historical data to simulate a production model. OpenScale monitors are set up. Then we will explore the metrics and data.
In this tutorial, you learn how to:
Provision a Watson OpenScale service
Use the Insights Dashboard
Using the Analytics tools
Let’s Dive In! 🤿
Environment preparation
Software that we will use: IBM OpenScale, tracks and measures outcomes from your AI models, and helps ensure that they remain fair, explainable, and compliant no matter where your models were built or are running.
How to get access to OpenScale: you can access it here: https://cloud.ibm.com/catalog/services/watson-openscale there is a Free Lite plan to test the service
Product Documentation: link
Let’s Start! 🏁
This section explains how to provision Watson OpenScale on the IBM Cloud Pak for Data platform. If you're using IBM Cloud, skip to the On IBM Cloud section.
In the Cloud Pak for Data instance, go to the (☰) menu, and under Services, click Instances.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/13bf4757-d9ae-427c-8a84-4814a1cc0ef1/image.png)
Find the OpenScale-default instance from the Instances table, and click the three vertical dots to open the action menu. Then, click Open.
Because this is the first time you are launching OpenScale, you are presented with a welcome message where you can launch the auto setup process. Click Auto setup.
In the Connect to Watson Machine Learning panel, leave the defaults because you are using the Watson Machine Learning instance deployed in the same cluster. Click Next.
In the Connect to your database panel, enter the connection details for your local Db2 database (this is the database you provisioned in a previous section of the admin guide), and click Next.
The auto setup of a model will take some time to run.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/4f1b0eac-cf73-4b4d-817a-c53b6c7c95c3/image.png)
After it completes, you see a message if it succeeded.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/bb5b8294-4de4-451c-869b-f737c4afec26/image.png)
Click through the Insights dashboard for the deployed models to make sure that the pages load.
If you need to give other users access to the OpenScale instance, go to the (☰) menu, and under Services, click Instances.
Find the OpenScale-default instance from the Instances table, and click the three vertical dots to open the action menu. Then, click Manage access.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/5b87f784-b33d-4101-b682-477aea837ad9/image.png)
Use the Insights Dashboard
To launch the OpenScale service:
Go to the (☰) navigation menu, and click Services -> Instances.
Click the three vertical dots next to the OpenScale instance that your Administrator has provisioned, and click Open.
Now, let's interact with the tools.
OpenScale loads the Insights Dashboard, which contains tiles for any models being monitored. The GermanCreditRiskModelICP tile is the one you'll use for this tutorial. This tile was configured using the Auto setup script.
Click the Insights icon on the left, make sure that you are on the Model monitors tab, and then open the GermanCreditRiskModelICP model tile. Click the 3-dot menu, then click View details.
Notice the red alert indicators on the various monitors (Fairness, Quality, and Drift). You should see a red indicator under Fairness. Click the Fairness score.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/b2646466-e9fa-4d05-9adc-625d91d0e708/image.png)
Click on the triangle with the ! under Fairness -> Sex. This indicates that there has been an alert for this attribute in the Fairness monitor. Alerts are configurable, based on thresholds for fairness outcomes, which can be set and altered as needed.
By moving your mouse pointer over the trend chart, you can see the values change. Find and click on a time slice where the graph is below the red threshold line. This indicates that the level of fairness is below the predetermined minimum and that some of the transactions at that time are biased.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/9e50d0de-d1fd-4b6a-ad21-6304fd0572f9/image.png)
After you click on one of the time periods, you see details of the Fairness monitor, including a bar chart that shows how many females received the "No Risk" outcome versus males. You can click view calculation to see how the fairness score is calculated. Click View payload transactions.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/0c52f89e-2616-40dc-8d87-f2a844b84ee4/image.png)
You see a list of transactions. Look for one of the Monitored Group - Female with a Group Bias check mark and a Prediction of "Risk." Click Explain prediction. If the time period on the graph for Fairness Monitoring doesn't contain this element, go back and choose another time period until you can find one. This makes the explanation more interesting.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/d6c4efa2-01d4-4b37-9229-b3588ff26ada/image.png)
Note: Each of the individual transactions can be examined to see them in detail. Doing so will cache that transaction as you see later. Be aware that the Explainability feature requires thousands of REST calls to the endpoint using variations of the data that are slightly perturbed. This can require several seconds to complete.
On the Explain tab for this individual transaction, you can see the relative weights of the most important features for this prediction. Examine the data, then click the Inspect tab.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/a6ee8ffc-c46c-4884-9c19-9692ccedcc43/image.png)
In the Inspect view of this transaction, you can see the original features that led to this prediction as well as a series of drop-down menus and input boxes that offer the ability to change each feature. You can find which features will change the outcome (in this case, from "Risk" to "No Risk") by clicking Run Analysis. Note that this requires thousands of REST calls to the endpoint with slight perturbations in the data, so it can take a few minutes to run. Click Run Analysis.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/d76b5aac-cabf-44d1-a2f5-13ff404cc9ce/image.png)
In this particular transaction, you see that the presence of a guarantor on the loan is the only thing required to flip the outcome from "Risk" to "No Risk." Other transactions might show a different analysis, so be aware that your results might vary from this. In this example, you can click the drop-down menu for Others on Loan and change to guarantor.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/54409f23-13dd-4839-8991-f410e283f160/image.png)
Choosing this new value for guarantor exposes a button for Score new values. Click this button.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/2bcb7659-236c-4966-8db9-07d4a676db34/image.png)
In this example, you see that the outcome has now been flipped from "Risk" to "No Risk."
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/2bc26915-2b8f-4933-8956-aa040c506f52/image.png)
Go back to the Insights Dashboard page by clicking on the Insights menu icon. Make sure that you are on the Model monitors tab. Now, open the monitor configuration for the GermanCreditRiskModelICP model by clicking the 3-dot menu on the tile, and then click Configure monitors.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/2da0b4ec-72c3-4490-89f2-33a9eee006bf/image.png)
Click the Endpoints menu, then the Endpoints tab. Use the Endpoints drop-down menu to select Debiased transactions. This is the REST endpoint that offers a debiased version of the credit risk machine learning model based on the features that were configured (that is, Sex and Age). It presents an inference that attempts to remove the bias that has been detected.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/a775f261-49a1-427b-ac48-fad6b103947a/image.png)
You can see code snippets using cURL, the Java language, and Python, which can be used in your scripts or applications.
Similarly, you can choose the Feedback logging endpoint to get code for Feedback Logging. This provides an endpoint for sending fresh test data for ongoing quality evaluation. You can upload feedback data here or work with your developer to integrate the code snippet provided to publish feedback data to your Watson OpenScale database.
Using the Analytics tools
To use the Analytics tools:
Click the Insights icon on the left, make sure that you are on the Model monitors tab, and then open the GermanCreditRiskModelICP model tile. Click the 3-dot menu, then click View details.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/7d59ea58-59c7-430f-9a77-1ef7a9082b75/image.png)
Notice the red alert indicators on the various monitors (Fairness, Quality, and Drift). You should see a red indicator under Fairness. Click the Fairness score.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ba2383c9-bcbd-4661-8eff-afcaf914c439/image.png)
Click Analytics -> Predictions by Confidence. It might take a minute to create the chart. Here, you can see a bar chart that indicates confidence levels and predictions of "Risk" and "No Risk."
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/9408aa79-0a15-4a42-9753-432cb1ed14ce/image.png)
From this dashboard, click Analytics -> Chart Builder. Here, you can create charts using various Measurements, Features, and Dimensions of your machine learning model. You can see a chart that breaks down Predictions by Confidence.
Note: You might need to click the date range for Past Week or Yesterday to load the data.
You can experiment with changing the values and examine the charts that are created.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/9f622632-33f6-45c4-862c-76ec4fb6de61/image.png)
Congratulations! 🤯 You now know how to connect a model to a monitoring tool and track the main performance metrics to deploy trustworthy AI into production!
Join the AI Bootcamp! 🤖
Join 🧠 The AI Bootcamp. It is FREE! Go from Zero to Hero and Learn the Fundamentals of AI. This Course is perfect for beginner to intermediate-level professionals who want to break into AI. Transform your skillset and accelerate your career. Learn more about it here:
Cheers!
Armand 😎
Reply