Path: blob/master/cpd5.0/notebooks/python_sdk/deployments/pmml/Use PMML and Batch Deploymentt to predict iris species.ipynb
6408 views
Use PMML to predict iris species with ibm-watsonx-ai
This notebook contains steps from storing sample PMML model to starting scoring new data using batch deployment.
Some familiarity with python is helpful. This notebook uses Python 3.11.
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
Batch deployment of PMML model
Scoring of deployed model
Contents
This notebook contains the following parts:
Install and import the ibm-watsonx-ai
and dependecies
Note: ibm-watsonx-ai
documentation can be found here.
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.
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 watsonx.ai
, 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 watsonx.ai
repository.
Note: You can see that model is successfully stored in Watson Machine Learning Service.
You can use command bellow to create batch deployment for stored model.
Batch deployment has been created.
You can retrieve now your deployment ID.
You can also list all deployments in your space.
If you want to get additional information on your deployment, you can do it as below.
You can send new scoring records to batch deployment using by creating job.
Now, your job has been submitted to runtime.
You can retrieve now your job ID.
You can also list all jobs in your space.
If you want to get additional information on your job, you can do it as below.
Monitor job execution Here you can check status of your batch scoring.
Get scored data
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 watsonx.ai
for PMML model deployment and scoring.
Check out our Online Documentation for more samples, tutorials, documentation, how-tos, and blog posts.
Authors
Jan Sołtysik, Software Engineer at IBM.
Copyright © 2020-2025 IBM. This notebook and its source code are released under the terms of the MIT License.