Path: blob/master/cpd3.5/notebooks/python_sdk/deployments/autoai/Use AutoAI to predict credit risk.ipynb
6405 views
Use AutoAI to predict credit risk with ibm-watson-machine-learning
This notebook demonstrates how to deploy in Watson Machine Learning service an AutoAI model created in Generated Scikit-learn Notebook
which is composed during autoai experiments (in order to learn more about AutoAI experiments go to experiments/autoai).
Some familiarity with bash is helpful. This notebook uses Python 3.7.
Learning goals
The learning goals of this notebook are:
Working with the Watson Machine Learning instance
Online deployment of AutoAI model
Scoring data using deployed model
Contents
This notebook contains the following parts:
Connection to WML
Authenticate the Watson Machine Learning service on IBM Cloud Pack for Data. You need to provide platform url
, your username
and password
.
Install and import the ibm-watson-machine-learning
package
Note: ibm-watson-machine-learning
documentation can be found here.
Working with spaces
First of all, you need to create a space that will be used for your work. If you do not have space already created, you can use {PLATFORM_URL}/ml-runtime/spaces?context=icp4data
to create one.
Click New Deployment Space
Create an empty space
Go to space
Settings
tabCopy
space_id
and paste it below
Tip: You can also use SDK to prepare the space for your work. More information can be found here.
Action: Assign space ID below
You can use list
method to print all existing spaces.
To be able to interact with all resources available in Watson Machine Learning, you need to set space which you will be using.
2. Upload model
In this section you will learn how to upload the model.
Download the data as an pandas DataFrame and AutoAI saved as scikit pipeline model using wget
.
Hint: To install required packages exacute command !pip install pandas wget numpy
.
We can exract model from executed AutoAI experiment using ibm-watson-machine-learning
with following command: experiment.optimizer(...).get_pipeline(astype='sklearn')
.
Custom software_specification
Create new software specification based on default Python 3.7 environment extended by autoai-libs package.
config.yaml
file describes details of package extention. Now you need to store new package extention with APIClient.
Create new software specification and add created package extention to it.
Get the details of created software specification
Load the AutoAI model saved as scikit-learn
pipeline.
Depending on estimator type in autoai model pipeline may consist models from following frameworks:
xgboost
lightgbm
scikit-learn
Store the model
Get model details
Note: You can see that model is successfully stored in Watson Machine Learning Service.
Get deployment id.
If you want to clean up all created assets:
experiments
trainings
pipelines
model definitions
models
functions
deployments
see the steps in this sample notebook.
You successfully completed this notebook! You learned how to use Watson Machine Learning for AutoA model deployment and scoring. Check out our Online Documentation for more samples, tutorials, documentation, how-tos, and blog posts.
Author
Jan Sołtysik Intern in Watson Machine Learning.
Copyright © 2020-2025 IBM. This notebook and its source code are released under the terms of the MIT License.