Quickstart for Structured Data Models
In this quickstart, you load a public dataset, predict its labels with Kumo Tabular, and check the accuracy.
Prerequisites
Before you start, make sure that your environment meets the following requirements:
- Install Python 3.11 or later.
- Reserve about 1 GB of disk space for PyTorch and model weights.
- Make sure that you have network access for the first run.
You do not need a GPU or a Hugging Face account.
Quickstart Steps
To make your first prediction, complete the following steps.
1. Install SDM
Install SDM and the example dataset dependency:
scikit-learn provides the example dataset.
For GPU setup and other options, refer to Installation Guide for Structured Data Models.
2. Run a Classification
Run the following example to predict the labels of the query rows and check the accuracy:
The numbered comments in the example mark four steps:
TableTensor.from_pandasconverts the data frame.infer_stypesassigns a semantic type to each column. The override markstargetas categorical, which makes this a classification task.KumoTabulardownloads pretrained weights.size="small"keeps the download and CPU time small. The default is"large".- The forward pass reads 300 labeled context rows and predicts the 269 query rows.
num_estimators=8averages eight randomized views of the table. The seededgeneratormakes the result reproducible. to_class_indicesaligns probability columns with the true labels by class name.
3. Check the Output
The example prints the following output:
The result is a TableTensor with one probability column per class, named by class value.
Select classes by name, for example probs["1"], not by position: without a seeded generator, column order and probabilities can change between runs.
The first run prints a Hugging Face warning about unauthenticated requests. It is safe to ignore because the Kumo weights are public.
Try a Regression Task
When the target is numerical, Kumo Tabular performs regression and returns 999 quantiles named q001 to q999.
The following example runs a regression task:
The example prints the following output:
Reuse Context for Many Queries
If you score many batches against the same labeled rows, call fit once and predict per batch.
SDM caches the context side of the model, so each batch only computes the query side.
This example continues from the classification script:
The 269 query rows run in batches of 64, so the last batch of probabilities has shape torch.Size([13, 2]).
Run on a GPU
The quickstart script selects a CUDA device when PyTorch detects one, and creates its random generator on the same device.
First, set up a CUDA-enabled PyTorch build as described in Set Up a GPU.
On a GPU, you can drop size="small" to use the default large model.
The random generator draws a different sequence on a GPU, so probabilities can differ slightly from the CPU output shown above.
Download the Example Notebook
Classify breast masses from four clinical features using the UCI Mammographic Mass dataset on Kumo Tabular (small).
The notebook installs its dependencies, downloads the dataset and pretrained weights, and runs without a GPU.
To run the example in Snowflake, download the Snowflake notebook. First, configure Snowflake external access so the notebook can download model weights:
Run Kumo Relational on AdventureWorks tables in a Snowflake notebook:
Next Steps
After your first prediction runs, continue with the following pages:
- For GPU setup, Snowflake external access, and other installation options, refer to Installation Guide for Structured Data Models.
- For import, download, device, and input errors, refer to Troubleshooting Structured Data Models.