Path: blob/master/cpd4.5/notebooks/python_sdk/experiments/autoai/Use AutoAI and timeseries data to predict COVID cases.ipynb
6405 views
Use AutoAI and timeseries data to predict COVID19 cases with ibm-watson-machine-learning
This notebook contains the steps and code to demonstrate support of AutoAI experiments for timeseries data sets in Watson Machine Learning service. It introduces commands for data retrieval, training experiments, persisting pipelines, testing pipelines, deploying pipelines, and scoring.
Some familiarity with Python is helpful. This notebook uses Python 3.9.
Learning goals
The learning goals of this notebook are:
Define Watson Machine Learning experiment for timeseries data sets.
Work with experiments to train AutoAI models.
Compare trained models quality and select the best one for further deployment.
Online deployment and score the trained 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
and dependecies
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 the list
method to print all existing spaces.
To be able to interact with all resources available in Watson Machine Learning, you need to set the space which you will be using.
Training data sets
Define connection information to training data CSV file. This example uses the Poland COVID19 daily confirmed cases.
Visualize the data
Optimizer configuration
Provide the input information for AutoAI optimizer:
name
- experiment nameprediction_type
- type of the problemprediction_columns
- target columns namesscoring
- optimization metric
Configuration parameters can be retrieved via pipeline_optimizer.get_params()
.
You can use the get_run_status()
method to monitor AutoAI jobs in background mode.
Check pipeline details by calling get_pipeline_details(pipeline_name='Pipeline_8')
. By default details of best pipeline are returned.
Holdout data visualization
Online deployment creation
To show all available information about the deployment use the .get_params()
method:
Scoring
You can use the score
method to get predictions for defined forecasting window. You can either send payload records or use empty list.
Or you could send payload with new obeservations:
Visualization of predictions
If you want to clean up all created assets:
experiments
trainings
pipelines
model definitions
models
functions
deployments
please follow up this sample notebook.
8. Summary and next steps
You successfully completed this notebook!.
You learned how to use ibm-watson-machine-learning
to run AutoAI experiments.
Check out our Online Documentation for more samples, tutorials, documentation, how-tos, and blog posts.
Authors
Lukasz Cmielowski, PhD, is an Automation Architect and Data Scientist at IBM with a track record of developing enterprise-level applications that substantially increases clients' ability to turn data into actionable knowledge.
Copyright © 2020-2025 IBM. This notebook and its source code are released under the terms of the MIT License.