Path: blob/master/cpd4.7/notebooks/python_sdk/deployments/pmml/Use PMML to predict iris species.ipynb
6408 views
Use PMML to predict iris species with ibm-watson-machine-learning
This notebook contains steps from storing sample PMML model to starting scoring new data.
Some familiarity with python is helpful. This notebook uses Python 3.10.
You will use a Iris data set, which details measurements of iris perianth. Use the details of this data set to predict iris species.
Learning goals
The learning goals of this notebook are:
Working with the WML instance
Online deployment of PMML model
Scoring of 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 api_key
.
Alternatively you can use username
and password
to authenticate WML services.
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.
In this section you will learn how to upload the model to the Cloud.
Action: Download sample PMML model from git project using wget.
Store downloaded file in Watson Machine Learning repository.
Note: You can see that model is successfully stored in Watson Machine Learning Service.
You can use commands bellow to create online deployment for stored model (web service).
You can send new scoring records to web-service deployment using score
method.
As we can see this is Iris Setosa flower.
If you want to clean up all created assets:
experiments
trainings
pipelines
model definitions
models
functions
deployments
please follow up this sample notebook.
You successfully completed this notebook! You learned how to use Watson Machine Learning for PMML model deployment and scoring.
Check out our Online Documentation for more samples, tutorials, documentation, how-tos, and blog posts.
Authors
Lukasz Cmielowski, PhD, is a Software Architect and Data Scientist at IBM.
Copyright © 2020-2025 IBM. This notebook and its source code are released under the terms of the MIT License.