Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Monitor performance, fairness, and quality of a WML model with AI OpenScale APIs

License

NotificationsYou must be signed in to change notification settings

IBM/monitor-wml-model-with-watson-openscale

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

In this Code Pattern, we will use German Credit data to train, create, and deploy a machine learning model usingWatson Machine Learning. We will create a data mart for this model withWatson OpenScale and configure OpenScale to monitor that deployment, and inject seven days' worth of historical records and measurements for viewing in the OpenScale Insights dashboard.

When the reader has completed this Code Pattern, they will understand how to:

  • Create and deploy a machine learning model using the Watson Machine Learning service
  • Setup Watson OpenScale Data Mart
  • Bind Watson Machine Learning to the Watson OpenScale Data Mart
  • Add subscriptions to the Data Mart
  • Enable payload logging and performance monitor for subscribed assets
  • Enable Quality (Accuracy) monitor
  • Enable Fairness monitor
  • Enable Drift montitor
  • Score the German credit model using the Watson Machine Learning
  • Insert historic payloads, fairness metrics, and quality metrics into the Data Mart
  • Use Data Mart to access tables data via subscription

architecture

Flow

  1. The developer creates a Jupyter Notebook on Watson Studio.
  2. The Jupyter Notebook is connected to a PostgreSQL database, which is used to store Watson OpenScale data.
  3. The notebook is connected to Watson Machine Learning and a model is trained and deployed.
  4. Watson OpenScale is used by the notebook to log payload and monitor performance, quality, and fairness.

Prerequisites

Steps

  1. Clone the repository
  2. Use free internal DB or Create a Databases for PostgreSQL DB
  3. Create a Watson OpenScale service
  4. Create a Watson Machine Learning instance
  5. Create a notebook in IBM Watson Studio on Cloud Pak for Data
  6. Run the notebook in IBM Watson Studio
  7. Setup OpenScale to utilize the dashboard

1. Clone the repository

git clone https://github.com/IBM/monitor-wml-model-with-watson-openscalecd monitor-wml-model-with-watson-openscale

2. Use free internal DB or Create a Databases for PostgreSQL DB

If you wish, you can use the free internal Database with Watson OpenScale. To do this, make sure that the cell forKEEP_MY_INTERNAL_POSTGRES = True remains unchanged.

If you have or wish to use a paidDatabases for Postgres instance, follow these instructions:

Note: Services created must be in the same region, and space, as your Watson Studio service.

  • Using theIBM Cloud Dashboard catalog, search for PostgreSQL and choose theDatabases for Postgresservice.
  • Wait for the database to be provisioned.
  • Click on theService Credentials tab on the left and then clickNew credential + to create the service credentials. Copy them or leave the tab open to use later in the notebook.
  • Make sure that the cell in the notebook that has:
KEEP_MY_INTERNAL_POSTGRES=True

is changed to:

KEEP_MY_INTERNAL_POSTGRES=False

3. Create a Watson OpenScale service

Create Watson OpenScale, either on the IBM Cloud or using your On-Premise Cloud Pak for Data.

On IBM Cloud
  • If you do not have an IBM Cloud account,register for an account

  • Create a Watson OpenScale instance from theIBM Cloud catalog

  • Select theLite (Free) plan, enter aService name, and clickCreate.

  • ClickLaunch Application to start Watson OpenScale.

  • ClickAuto setup to automatically set up your Watson OpenScale instance with sample data.

    Cloud auto setup

  • ClickStart tour to tour the Watson OpenScale dashboard.

On IBM Cloud Pak for Data platform

Note: This assumes that your Cloud Pak for Data Cluster Admin has already installed and provisioned OpenScale on the cluster.

  • In the Cloud Pak for Data instance, go the (☰) menu and underServices section, click on theInstances menu option.

    Service

  • Find theOpenScale-default instance from the instances table and click the three vertical dots to open the action menu, then click on theOpen option.

    Openscale Tile

  • If you need to give other users access to the OpenScale instance, go the (☰) menu and underServices section, click on theInstances menu option.

    Service

  • Find theOpenScale-default instance from the instances table and click the three vertical dots to open the action menu, then click on theManage access option.

    Openscale Tile

  • To add users to the service instance, click theAdd users button.

    Openscale Tile

  • For all of the user accounts, select theEditor role for each user and then click theAdd button.

    Openscale Tile

4. Create a Watson Machine Learning instance

  • Under theSettings tab, scroll down toAssociated services, click+ Add service and chooseWatson:

    Add service

  • Search forMachine Learning, Verify this service is being created in the same space as the app in Step 1, and clickCreate.

    Create Machine Learning

  • Alternately, you can choose an existing Machine Learning instance and click onSelect.

  • The Watson Machine Learning service is now listed as one of yourAssociated Services.

  • In a different browser tab go tohttps://cloud.ibm.com/ and log in to the Dashboard.

  • Click on your Watson Machine Learning instance underServices, click onService credentials and then onView credentials to see the credentials.

  • Save the credentials in a file. You will use them inside the notebook.

5. Create a notebook in IBM Watson Studio on Cloud Pak for Data

Note: The current default (as of 8/11/2021) is Python 3.8. This will cause an error when installing thepyspark.sql SparkSession library, so make sure that you are using Python 3.7

  • Click theCreate notebook button. [6]

OpenScale Notebook Create

6. Run the notebook in IBM Watson Studio

Follow the instructions forProvision services and configure credentials:

Your Cloud API key can be generated by going to theUsers section of the Cloud console.

  • From that page, click your name, scroll down to theAPI Keys section, and clickCreate an IBM Cloud API key.

  • Give your key a name and clickCreate, then copy the created key and paste it below.

Alternately, from theIBM Cloud CLI :

ibmcloud login --ssoibmcloud iam api-key-create'my_key'
  • Enter theCLOUD_API_KEY in the cell1.1 Cloud API key.

Create COS bucket and get credentials

  • In yourIBM Cloud Object Storage instance, create a bucket with a globally unique name. The UI will let you know if there is a naming conflict. This will be used in cell1.3.1 asBUCKET_NAME.

  • In yourIBM Cloud Object Storage instance, get the Service Credentials for use asCOS_API_KEY_ID,COS_RESOURCE_CRN, andCOS_ENDPOINT:

    COS credentials

  • Add the COS credentials in cell1.2 Cloud object storage details.

  • Insert your BUCKET_NAME in the cell1.2.1 Bucket name.

  • Either use the internal Database, which requiresNo Changes or Add yourDB_CREDENTIALS after reading the instructions preceeding that cell and change the cellKEEP_MY_INTERNAL_POSTGRES = True to becomeKEEP_MY_INTERNAL_POSTGRES = False.

  • Move your cursor to each code cell and run the code in it. Read the comments for each cell to understand what the code is doing.Important when the code in a cell is still running, the label to the left changes toIn [*]:.Donot continue to the next cell until the code is finished running.

7. Setup OpenScale to utilize the dashboard

Now that you have created a machine learning model, you can utilize theOpenScale dashboard to gather insights.

Sample Output

You can find a sample notebook with output forWatsonOpenScaleMachineLearning-with-outputs.ipynb.

Openscale Dashboard

  • Go to the instance ofWatson OpenScale for an IBM Cloud deployment, or to your deployed instance on Cloud Pak for Data on-premise version. Choose theInsights tab to get an overview of your monitored deployments, Accuracy alerts, and Fairness alerts.

WOS insights

  • Click on the tile for theSpark German Risk Deployment and you can see tiles for theFairness,Accuracy, andPerformance monitors.

OpenScale monitors

  • Click on one of the tiles, such asDrift to view details. Click on a point on the graph for more information on that particular time slice.

Drift monitor

  • You will see which types of drift were detected. Click on the number to bring up a list of transactions that led to drift.

Drift transactions

  • Click on theExplain icon on the left-hand menu and you'll see a list of transactions that have been run using an algorithm to provide explainability. Choose one and clickExplain.

Choose transaction to explain

  • You will see a graph showing all the most influential features with the relative weights of contribution to thePredicted outcome.

View feature weights

  • Click theInspect tab and you can experiment with changing the values of various features to see how that would affect the outcome. Click theRun analysis button to see what changes would be required to change the outcome.

Inspect features and change

License

Apache 2.0

Releases

No releases published

Packages

No packages published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp