Path: blob/master/cpd4.0/notebooks/rest_api/curl/deployments/scikit/Use scikit-learn to predict diabetes progression.ipynb
6408 views
Use scikit-learn to predict diabetes progression with Watson Machine Learning REST API
This notebook contains steps and code to demonstrate support of external machine learning models in Watson Machine Learning Service. This notebook introduces cURL
calls for publishing, deploying (Web Service) and scoring ML scikit model.
Some familiarity with cURL is helpful. This notebook uses cURL examples.
This example was made based on diabetes
dataset and trained scikit ML model that could be found inside the same repository under as follows:
/data/diabetes/
/models/scikit/diabetes/
Learning goals
The learning goals of this notebook are:
Working with Watson Machine Learning repository, deployment and scoring.
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 api_key
.
<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
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_create" target="_blank" rel="noopener no referrer">Model storing
Create model revision for further update
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_create_revision" target="_blank" rel="noopener no referrer">Model revision
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_upload_content" target="_blank" rel="noopener no referrer">Upload model content
<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#/Deployments/deployments_compute_predictions" target="_blank" rel="noopener no referrer">Score your deployment
<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
In this section, you'll learn how to store new version of your model in Watson Machine Learning repository.
Model update
Below you can find how ML model can be updated with new version on WML repository.
List model revisions.
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_list_revisions" target="_blank" rel="noopener no referrer">List revisions
Create second model revision
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_create_revision" target="_blank" rel="noopener no referrer">Create model revision
Update model metadata
For example update model name or description
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_update" target="_blank" rel="noopener no referrer">Patch model
Upload new model content
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_upload_content" target="_blank" rel="noopener no referrer">Upload model content
List model revisions to see a new one just created
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_list_revisions" target="_blank" rel="noopener no referrer">List revisions
Now we have updated model content and model name in repository.
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Models/models_get" target="_blank" rel="noopener no referrer">Get model details
Below you can see how deployment can be updated with new version of the model without any change for scoring url.
<a href="https://watson-ml-v4-api.mybluemix.net/wml-restapi-cloud.html#/Deployments/deployments_update" target="_blank" rel="noopener no referrer">Deployment update
Score updated webservice
<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.