Path: blob/master/cloud/notebooks/python_sdk/experiments/autoai/Use AutoAI and timeseries data to predict COVID cases.ipynb
5141 views
Use AutoAI and timeseries data to predict COVID19 cases with ibm-watsonx-ai
This notebook contains the steps and code to demonstrate support of AutoAI experiments for timeseries data sets in watsonx.ai Runtime 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.12.
Learning goals
The learning goals of this notebook are:
Define watsonx.ai Runtime 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:
1. Set up the environment
Before you use the sample code in this notebook, you must perform the following setup tasks:
Create a watsonx.ai Runtime Service instance (a free plan is offered and information about how to create the instance can be found here).
Create a Cloud Object Storage (COS) instance (a lite plan is offered and information about how to order storage can be found here).
Note: When using Watson Studio, you already have a COS instance associated with the project you are running the notebook in.
Install dependencies
Note: ibm-watsonx-ai documentation can be found here.
Successfully installed wget-3.2
Successfully installed narwhals-2.16.0 plotly-6.5.2
Successfully installed tqdm-4.67.3
Successfully installed attrs-25.4.0 fastjsonschema-2.21.2 jsonschema-4.26.0 jsonschema-specifications-2025.9.1 nbformat-5.10.4 referencing-0.37.0 rpds-py-0.30.0 typing-extensions-4.15.0
Successfully installed anyio-4.12.1 cachetools-7.0.1 certifi-2026.1.4 charset_normalizer-3.4.4 h11-0.16.0 httpcore-1.0.9 httpx-0.28.1 ibm-cos-sdk-2.14.3 ibm-cos-sdk-core-2.14.3 ibm-cos-sdk-s3transfer-2.14.3 ibm-watsonx-ai-1.5.2 idna-3.11 jmespath-1.0.1 lomond-0.3.3 numpy-2.4.2 pandas-2.3.3 pytz-2025.2 requests-2.32.5 tabulate-0.9.0 tzdata-2025.3 urllib3-2.6.3
Connection to watsonx.ai Runtime
Authenticate the watsonx.ai Runtime service on IBM Cloud. You need to provide platform api_key and instance location.
You can use IBM Cloud CLI to retrieve platform API Key and instance location.
API Key can be generated in the following way:
In result, get the value of api_key from the output.
Location of your watsonx.ai Runtime instance can be retrieved in the following way:
In result, get the value of location from the output.
Tip: 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. You can also get a service specific url by going to the Endpoint URLs section of the watsonx.ai Runtime docs. You can check your instance location in your watsonx.ai Runtime Service instance details.
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.
Action: Enter your url and api_key in the following cell.
Working with spaces
You need to create a space that will be used for your work. If you do not have a space, you can use Deployment Spaces Dashboard to create one.
Click New Deployment Space
Create an empty space
Select Cloud Object Storage
Select watsonx.ai Runtime instance and press Create
Copy
space_idand 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 watsonx.ai Runtime, you need to set the space which you will be using.
Training data sets
Download training data from git repository and upload it to your space. This example uses the Poland COVID19 daily confirmed cases.
Visualize the data
Training data connection
The code in next cell defines connections to created assets.
Optimizer configuration
Provide the input information for AutoAI optimizer:
name- experiment nameprediction_type- type of the problemprediction_columns- target columns namesscoring- optimization metricbacktest_num– number of backtests
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
Backtest data visualization
6. Deploy and Score
In this section you will learn how to deploy and score pipeline model as online deployment using watsonx.ai Runtime instance.
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-watsonx-ai 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.
Mateusz Szewczyk, Software Engineer at watsonx.ai.
Copyright © 2020-2026 IBM. This notebook and its source code are released under the terms of the MIT License.