watsonx Data Scientist - Associate study materials
watsonx Data Scientist - Associate study resources

watsonx Data Scientist - Associate: Python and Notebook Workflows with the watsonx SDKs

watsonx Data Scientist - Associate · Work through your exam, one topic at a time.

All guide sections

Python and Notebook Workflows with the watsonx SDKs

This domain tests whether you can drive watsonx.ai from a notebook: authenticate, call a model, run AutoAI, and manage assets.

Setup

ibm-watsonx-ai (successor to ibm-watson-machine-learning) is the main Python SDK. Build Credentials(url=..., apikey=...), create an APIClient, then either set client.set.default_space(space_id) for deployment-space work or pass project_id per call for project work. Keep keys in environment variables, never in notebook cells.

Inference calls

ModelInference(model_id=..., credentials=..., project_id=..., params={...}) exposes generate_text, generate_text_stream, chat(messages=[...]) and tokenize. Embeddings use a dedicated embeddings class and embedding model. Responses report token usage for cost tracking.

Experiments and assets

AutoAI is driven from the experiment module (for example from ibm_watsonx_ai.experiment import AutoAI), fitted against a data asset or connection. Models are stored through the client's model API and served through its deployment API.

Worked example

A script must score inside a project. Reasoning: create Credentials from URL and API key, construct the client, pass project_id to ModelInference, set temperature 0 for repeatability, call generate_text, and log usage tokens. Passing a space ID here fails because the asset lives in the project.

Traps

Hardcoded API keys; swapping project_id and space_id; mixing generate_text with the chat message format; assuming a stopped kernel keeps variables; using outdated model IDs from older documentation.