Path: blob/master/cloud/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:
1. Set up the environment
Before you use the sample code in this notebook, you must perform the following setup tasks:
Create a Watson Machine Learning (WML) Service instance (a free plan is offered and information about how to create the instance can be found here).
You can find your COS credentials in COS instance dashboard under the Service credentials tab. Go to the Endpoint tab in the COS instance's dashboard to get the endpoint information.
Authenticate the Watson Machine Learning service on IBM Cloud.
Your Cloud API key can be generated by going to the Users section of the Cloud console. From that page, click your name, scroll down to the API Keys section, and click Create an IBM Cloud API key. Give your key a name and click Create, then copy the created key and paste it below.
NOTE: You can also get service specific apikey by going to the Service IDs section of the Cloud Console. From that page, click Create, then copy the created key and paste it below.
<a href="https://cloud.ibm.com/apidocs/data-ai-common-core#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://cloud.ibm.com/apidocs/data-ai-common-core#spaces-get" target="_blank" rel="noopener no referrer">Get space information
<a href="https://cloud.ibm.com/apidocs/machine-learning#models-create" target="_blank" rel="noopener no referrer">Model storing
Create model revision for further update
<a href="https://cloud.ibm.com/apidocs/machine-learning#models-create-revision" target="_blank" rel="noopener no referrer">Model revision
<a href="https://cloud.ibm.com/apidocs/machine-learning#models-upload-content" target="_blank" rel="noopener no referrer">Upload model content
<a href="https://cloud.ibm.com/apidocs/machine-learning#models-filtered-download" target="_blank" rel="noopener no referrer">Download model content
<a href="https://cloud.ibm.com/apidocs/machine-learning#deployments-create" target="_blank" rel="noopener no referrer">Create deployment
<a href="https://cloud.ibm.com/apidocs/machine-learning#deployments-get" target="_blank" rel="noopener no referrer">Get deployment details
<a href="https://cloud.ibm.com/apidocs/machine-learning#deployments-compute-predictions" target="_blank" rel="noopener no referrer">Score your deployment
<a href="https://cloud.ibm.com/apidocs/machine-learning#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://cloud.ibm.com/apidocs/machine-learning#models-list-revisions" target="_blank" rel="noopener no referrer">List revisions
Create second model revision
<a href="https://cloud.ibm.com/apidocs/machine-learning#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://cloud.ibm.com/apidocs/machine-learning#models-update" target="_blank" rel="noopener no referrer">Patch model
Upload new model content
<a href="https://cloud.ibm.com/apidocs/machine-learning#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://cloud.ibm.com/apidocs/machine-learning#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://cloud.ibm.com/apidocs/machine-learning#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://cloud.ibm.com/apidocs/machine-learning#deployments-update" target="_blank" rel="noopener no referrer">Deployment update
Score updated webservice
<a href="https://cloud.ibm.com/apidocs/machine-learning#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, 2021, 2022 IBM. This notebook and its source code are released under the terms of the MIT License.