Path: blob/master/cpd3.5/notebooks/rest_api/curl/experiments/autoai/Use AutoAI and batch deployment to predict credit risk.ipynb
6405 views
Use AutoAI and batch deployment to predict credit risk with Watson Machine Learning REST API
This notebook contains steps and code to demonstrate support of AutoAI experiments in Watson Machine Learning Service. It introduces commands for getting data, training experiments, persisting pipelines, publishing models, deploying models and scoring.
Some familiarity with cURL is helpful. This notebook uses cURL examples.
Learning goals
The learning goals of this notebook are:
Working with Watson Machine Learning experiments to train AutoAI models.
Downloading computed models to local storage.
Batch deployment and scoring of trained 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
.
<a href="https://cpd-spaces-api.eu-gb.cf.appdomain.cloud/#/Spaces/spaces_create" target="_blank" rel="noopener no referrer">Space creation
Space creation is asynchronous. This means that you need to check space creation status after creation call. Make sure that your newly created space is active
.
<a href="https://cpd-spaces-api.eu-gb.cf.appdomain.cloud/#/Spaces/spaces_get" target="_blank" rel="noopener no referrer">Get space information
2. Experiment / optimizer configuration
Provide input information for AutoAI experiment / optimizer:
name
- experiment namelearning_type
- type of the problemlabel
- target column namescorer_for_ranking
- optimization metricholdout_param
- percentage of training data to use as a holdout [0 - 1]daub_include_only_estimators
- list of estimators to use
You can modify parameters
section of the following cURL call to change AutoAI experiment settings.
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Pipelines/pipelines_create" target="_blank" rel="noopener no referrer">Define AutoAI experiment.
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Pipelines/pipelines_get" target="_blank" rel="noopener no referrer">Get experiment / optimizer information
Training data connection
Define connection information to COS bucket and training data CSV file. This example uses the German Credit Risk dataset.
The dataset can be downloaded from here. You can also download it to local filesystem by running the cell below.
Action: Upload training data to COS bucket and enter location information in the next cURL examples.
<a href="https://cloud.ibm.com/apidocs/watson-data-api#createdataassetv2" target="_blank" rel="noopener no referrer">Upload file as Data Asset
The response should looks like this:
{"status":"Asset created: The asset was successfully uploaded."}
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Trainings/trainings_create" target="_blank" rel="noopener no referrer">Schedule a training job for AutoAI experiment
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Trainings/trainings_get" target="_blank" rel="noopener no referrer">Get information about training job
Get training status
Please make sure that training is completed before you go to the next sections. Monitor state
of your training by running above cell couple of times.
Output should be similar to the output from training creation but you should see more trainings entries. Listing trainings:
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Trainings/trainings_list" target="_blank" rel="noopener no referrer">Get list of historical training jobs information
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Trainings/trainings_delete" target="_blank" rel="noopener no referrer">Canceling training
Before deployment creation, you need store your model in WML repository. Please see below cURL call example how to do it. Remember that you need to specify where your chosen model is stored in COS.
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_create" target="_blank" rel="noopener no referrer">Model storing
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_filtered_download" target="_blank" rel="noopener no referrer">Download model content
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Deployments/deployments_create" target="_blank" rel="noopener no referrer">Create deployment
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Deployments/deployments_get" target="_blank" rel="noopener no referrer">Get deployment details
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Deployment Jobs/deployment_jobs_create" target="_blank" rel="noopener no referrer">Create deployment job
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Deployment Jobs/deployment_jobs_list" target="_blank" rel="noopener no referrer">List jobs
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Deployment Jobs/deployment_jobs_get" target="_blank" rel="noopener no referrer">Get job details
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Deployment Jobs/deployment_jobs_delete" target="_blank" rel="noopener no referrer">Cancel job
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Deployments/deployments_list" target="_blank" rel="noopener no referrer">List deployments details
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Trainings/trainings_delete" target="_blank" rel="noopener no referrer">Deleting training
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Deployment Jobs/deployment_jobs_delete" target="_blank" rel="noopener no referrer">Delete job
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_delete" target="_blank" rel="noopener no referrer">Delete model from repository
Authors
Amadeusz Masny, Python Software Developer in Watson Machine Learning at IBM Jan Sołtysik, Intern in Watson Machine Learning at IBM
Copyright © 2020-2025 IBM. This notebook and its source code are released under the terms of the MIT License.