> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/sdgm/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/sdgm/_mcp/server.

# Google Colab Notebook Code Example

> Train and score an AdventureWorks customer order model in Google Colab

Predict whether a customer who ordered in the previous year will order again in the next 90 days. The downloadable notebook prepares four AdventureWorks files, builds a local graph, trains or reloads a binary-classification model, inspects training diagnostics, and scores customers in Google Colab.

Download Colab notebook

## Sample Data

Unlike the Snowflake and Databricks notebook examples, this notebook does **not** use data preloaded in an account. Supply four original AdventureWorks OLTP exports: `Customer.csv`, `Product.csv`, `SalesOrderHeader.csv`, and `SalesOrderDetail.csv`. Download them from [Microsoft's AdventureWorks OLTP sample files](https://github.com/microsoft/sql-server-samples/tree/master/samples/databases/adventure-works/oltp-install-script), or use the downloader in [Linux Deployment Code Examples](/kumo-engine/1.0.0/examples/linux-local-examples). If you use the downloader, choose its **source-download** directory, not its separately prepared input directory.

These original files are headerless, tab-separated exports despite their `.csv` extension. Upload them to the Colab runtime or mount the Google Drive directory containing them, then set `SOURCE_DATA_DIR` to that directory. The notebook verifies access and file shape, copies the sources to its workspace, and creates separate labeled CSVs for a local `FileConnector`. It does not modify your source files.

## Prepare the Notebook

Select a Linux x86-64 Colab runtime with Python 3.12 (2026.07) and a GPU. Run the installation cell once, restart the runtime when instructed, and resume at Configuration.

Set `SOURCE_DATA_DIR`, `BASE`, and the other configuration values before running the remaining cells. `BASE` must be on the local runtime disk under `/content`, outside mounted Drive. It separates raw copies, prepared files, and Kumo scratch. `ARTIFACT_ROOT` defaults to a separate directory under `BASE`; you can set it to mounted Drive for retained copies. The notebook rejects workspace paths on another filesystem before configuring scratch. The notebook checks GPU visibility and free local disk before graph ingestion and training. See [GPU Sizing](/kumo-engine/1.0.0/get-started-with-kumo-engine/gpu-sizing) for resource considerations.

Colab's local filesystem is temporary. The copied model bundle, optional diagnostic archive, and saved prediction files remain local to the runtime unless you move or download them to durable storage. If `ARTIFACT_ROOT` is on mounted Drive, confirm that the retained files have finished syncing before ending the session. Keep `BASE` and `SCRATCH_DIR` on the local runtime disk; use Drive only for source files or retained artifact copies.

## Run the Example

The notebook assigns keys, timestamps, and feature types to the four tables; validates their relationships; and materializes a local graph snapshot. Its predictive query is:

```text
PREDICT COUNT(SalesOrderHeader.*, 0, 90, days) > 0
FOR EACH Customer.CustomerID
WHERE COUNT(SalesOrderHeader.*, -365, 0, days) > 0
```

With `MODE = "train"`, it generates historical examples, suggests a model plan, fits a model, and copies the complete reloadable bundle from scratch to `ARTIFACT_ROOT`. The five-epoch cap keeps the walkthrough bounded; inspect the model's metrics before deciding whether to tune it further.

The optional diagnostics cells locate AutoML scratch results and display per-trial validation results, trial plans, and available epoch metrics. They can plot learning curves and inspect explanation artifacts when present. Set `ARCHIVE_DIAGNOSTICS = True` if you want a separate ZIP under `ARTIFACT_ROOT`, then move that archive to durable storage before the runtime ends.

For prediction, the notebook uses a configurable date after the latest order in the supplied files. These are future scores, not an accuracy evaluation against observed outcomes. It writes local Parquet results, previews at most ten rows, and, when `SAVE_PREDICTIONS = True`, copies the files and a run manifest to `ARTIFACT_ROOT`.

To score with an earlier model, place its **complete** saved bundle on the Colab filesystem, set `MODE = "reload"` and `MODEL_BUNDLE_PATH`, and rerun the data preparation, graph, snapshot, and prediction cells. The model bundle does not replace the source files or graph snapshot.