Golden Bank is a leading mortgage provider through their network of neighborhood branches. This tutorial cover these goals:
- The bank uses AI to process loan applications and needs to avoid unanticipated risk and ensure that its applicants are being treated fairly.
- Based on a new regulation, the bank cannot lend to underqualified loan applicants. The bank has existing data for loan applications in a Db2 Warehouse. The bank needs to use the data to train AI models without moving it.
- The bank wants to run a campaign to offer lower mortgage rates. The bank needs a consolidated view of applicants to identify the highest value customers to target and help to determine the best rates to offer them.
- Prerequisite: Prepare Services
- Exercise 1: Create Project
- Exercise 2: Set up Tracking
- Exercise 3: Build and Save a Model
- Exercise 4: View Model’s AI Factsheet
- Exercise 5: Associate the Model with a Model Entry
- Exercise 6: Promote Model to Deployment Space
- Exercise 7: Deploy the Model
- Exercise 8: Run the model
Before we begin, we need to make sure we have the required services for the exercise. If you followed the sign-up process all required services should have been provisioned. Follow the steps below to verify or create missing services.
- Log into your IBM Cloud account.
- From the navigation menu in the top left corner, scroll down and choose Cloud Pak for Data > Services.
- Click Launch Cloud Pak for Data.
- From the Cloud Pak for Data navigation menu in the top left corner, choose Services > Service instances.
- Use the Product drop-down list to determine whether there is an existing Watson Studio service instance.
- If you need to create a Watson Studio service instance, click Add service.
- Select Watson Studio.
- Select Dallas as the region.
- Select the Lite plan.
- Select the Default resource group.
- Click Create.
- Repeat these steps to verify or provision the following additional services.
- Verify your screen looks like the following image.
Create the sample project for the exercise:
- Login to IBM Cloud Pak for Data
- Select "Dallas" under "Work with resources in this IBM Cloud region"
- From the navigation menu in the top left corner select Gallery.
- Type "MLOps" in the search box and click on the MLOps and Trustworthy AI guided tutorial sample project.
- Click Create project.
- Take the default name and select your Cloud Object Storage instance from the list.
- Click Create and then View new project
- Close the popup window and select the Assets tab to verify your project looks like the following image:
- Set up tracking for your model in Watson Knowledge Catalog:
- From the IBM Cloud Pak for Data navigation menu, choose Catalogs > View all catalogs.
- Click Create Catalog.
- Enter the catalog name as “Mortgage Approval Catalog” with no leading or trailing spaces.
- Select your IBM Cloud Object Storage from the list for the catalog assets.
- Select Enforce data policies, confirm the selection, and accept the defaults for the other fields.
- Click Create.
- Create model entry in the model inventory:
- From the IBM Cloud Pak for Data navigation menu, choose Catalogs > Model Inventory.
- Click New model entry.
- Enter the model entry name as “Mortgage Approval Model Entry” with no leading or trailing spaces.
- Click Save.
- Verify your model entry looks like the following image.
We will run the first notebook in the sample project in order to ...:
- Set up AI Factsheets used to track the lifecycle of the mode.
- Load the training data.
- Specify the target, categorical, and numerical columns along with the thresholds used to build the model.
- Build data pipelines.
- Build machine learning models.
- View the model results.
- Save the model.
- From the IBM Cloud Pak for Data navigation menu, choose Projects > View all projects.
- Open the MLOps and Trustworthy AI project.
- On the Assets tab, click Source Code > Notebooks.
- Open the 1-model-training-with-factsheets notebook.
- Since the notebook is in read-only mode, click the Edit (pencil) icon to place the notebook in edit mode.
- Under the Provide your IBM Cloud API key section, you need to pass your credentials to the Machine Learning API service.
- If you don't already have a saved API key, follow the instructions in notebook to create an API key.
- Update the cell
ibmcloud_api_key = ''
with your API key. - To run all the cells in the notebook, click Cell > Run All. Alternatively, you can run the notebook cell by cell if you want to explore each cell and its output.
- Take a few minutes to review the steps to build, train, verify, and save this random forest model.
- After the last notebook cell is finished and the model is stored, click File > Stop Kernel and confirm to shut down the kernel.
You just built and saved a model “Mortgage Approval Prediction Model” to your project.
View the model’s AI Factsheet:
- From the Cloud Pak for Data navigation menu, choose Projects > View all projects.
- Open the MLOps and Trustworthy AI project.
- On the Assets tab, click Models > Models.
- Open Mortgage Approval Prediction Model that you previously created.
- Review the AI Factsheet for your model.
- Scroll to the Training metrics and Training tags sections to review the captured training metadata.
- Verify your screen looks like the following image.
We need to associate the model with a model entry.
- Scroll up on the model page, and click Track this model.
- In the pop-up dialog box, choose Select an existing model entry.
- From the list of model entries, select Mortgage Approval Model Entry.
- Click Track to close the dialog box
- Back on the model page, click Open in model inventory.
- On the Model entry page, click the Asset tab.
- Under Model tracking, you can see that AI Factsheets track models through their lifecycle. This model is still in the Develop stage as it has not been deployed yet.
- Verify your screen looks like the following image.
Before you can deploy the model, you need to promote the model to a new deployment space.
- From the IBM Cloud Pak for Data navigation menu, choose Catalogs > Model inventory.
- For the Mortgage Approval Model Entry, click View details.
- Click Asset tab.
- From the model entry, under the Develop phase, click Mortgage Approval Prediction Model.
- Click Open in project to open the model in the MLOps and Trustworthy AI project.
- On the model page, click Promote to deployment space.
- For the Target space, select Create a new deployment space.
- For the deployment space name, enter “Golden Bank Preproduction Space” with no leading or trailing spaces.
- Select your storage service from the list.
- Select your provisioned machine learning service from the list.
- Click Create and after the deployment space is ready click Close.
- For the Target space, ensure that Golden Bank Preproduction Space is selected.
- Check the Go to model in the space after promoting it option.
- Click Promote.
Create an online deployment for the model.
- On the deployment space screen, click New deployment.
- For the Deployment type, select Online.
- For the Name, enter "Mortgage Approval Model Deployment" with no leading or trailing spaces.
- For the Serving Name, enter “mortgage_approval_service_<your_unique_id>”, append some characters to make it unique if name is taken.
- Click Create.
- Navigate to Catalogs > Model inventory.
- For the Mortgage Approval Model Entry, click View details.
- Click the Asset tab. Under Model tracking, you can see that the model is now in the Deploy stage.
- Verify your model entry looks like the following image.
Make predictions using the deployed model.
- Add the test dataset to the deployment space
- Download the test dataset GoldenBank_TestData.csv from this repo.
- Click "Raw" in the top right corner above the CSV content view
- From your browser "File" menu, click "Save page as" to store a local copy of the CSV file
- From the Cloud Pak for Data navigation menu, click Deployments
- Select the Spaces tab and click on "Golden Bank Preproduction Space" from the list of Deployments
- Click on "Drop files here or browse for files to upload" to upload the test dataset.
- Verify that the test dataset CSV file appears under Data assets on the Assets tab.
- Download the test dataset GoldenBank_TestData.csv from this repo.
- Open model deployment in the deployment space.
- Click Deployments tab.
- Click Mortgage Approval Model Deployment.
- Make a prediction request to the model - using a dataset CSV file
- Make a prediction request to the model – using a local JSON file
- Download the test json file GoldenBank_TestData.json from this repo.
- Click "Raw" in the top right corner above the JSON content view
- From your browser "File" menu, click "Save page as" to store a local copy of the JSON file
- Under "Enter input data", click Paste JSON.
- Click Browse local files and select the "GoldenBank_TestData.json" downloaded in the previous step.
- Click Predict to make a prediction request for the entry in json.
- You should see the Binary classification result for 1 Record, i.e. a prediction of 0 and 94% confidence.
- Close the result dialog
- Repeat the steps to "Browse local files", scroll down the json editor and change the following values:
- 3rd value from
10
to30
(YRS_WITH_CURRENT_EMPLOYER
) - 5th value from
2000
to200
(CREDITCARD_DEBT
)
- 3rd value from
- Verify your screen looks like in this screenshot
- Click Predict to make a prediction request for the entry in json.
- Now you should see a prediction of 1 with a high confidence around 80%.
- Download the test json file GoldenBank_TestData.json from this repo.