Path: blob/master/cpd4.8/notebooks/python_sdk/deployments/custom_library/Use custom software spec to create statsmodels function.ipynb
6405 views
Use custom software_spec to create statsmodels function describing data with ibm-watson-machine-learning
This notebook demonstrates how to deploy in Watson Machine Learning service a python function with statsmodel
which requires to create custom software specification using conda yaml file with all required libraries.
Some familiarity with bash is helpful. This notebook uses Python 3.10 with statsmodel.
Learning goals
The learning goals of this notebook are:
Working with the Watson Machine Learning instance
Creating custom software specification
Online deployment of python function
Scoring data using deployed function
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.
Create deploayable callable which uses stsmodels library
Test callable locally
Hint: To install numpy execute !pip install numpy
.
Custom software_specification
Create new software specification based on default Python 3.10 environment extended by autoai-libs package.
config.yaml
file describes details of package extention. Now you need to store new package extention with APIClient.
Create new software specification and add created package extention to it.
Get the details of created software specification
Store the function
Get function details
Note: You can see that function is successfully stored in Watson Machine Learning Service.
Create online deployment of a python function
Get deployment id.
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 function deployment and scoring with custom software_spec. Check out our Online Documentation for more samples, tutorials, documentation, how-tos, and blog posts.
Author
Jan Sołtysik Intern in Watson Machine Learning.
Copyright © 2020-2025 IBM. This notebook and its source code are released under the terms of the MIT License.