Skip to navigation

Quickstart: Kumo Tabular

View as Markdown

This quickstart builds a Request directly from two small pandas DataFrames and runs a Kumo Tabular prediction through an NVIDIA NIM.

The small tables are for API verification only. They do not contain enough labelled examples to assess prediction quality.

Standard SDK workflow

After you install the SDK and make a kumo-tabular NIM available, use the following workflow:

  1. Prepare the labelled rows (context) and the rows to score (predict).
  2. Build a Request, naming the target column and the task.
  3. Call client.predict(request, model=KumoTabular()).

The result is a PredictionResult; to_pandas() gives you a DataFrame.

1. Install the SDK

pip install structured-data-models-client

2. Prepare labelled and scored rows

import pandas as pd
labelled = pd.DataFrame({
"age": [31.0, 44.5, 28.0, 51.0, 39.0],
"spend": [120.0, 430.0, 90.0, 510.0, 260.0],
"churn": [0, 1, 0, 1, 0],
})
to_score = pd.DataFrame({
"age": [33.0, 47.0],
"spend": [150.0, 480.0],
})

to_score need not overlap with labelled at all: this model exists to score rows it has never seen.

3. Build the request

from sdm_client import Request
request = Request(
context=labelled,
predict=to_score,
target="churn",
task="classification",
)

context must contain target; predict must not — those are the rows whose answer is being asked for. Every feature the model is shown in context has to be supplied for the rows being scored, except the primary key.

4. Run a prediction

from sdm_client import SDMClient, KumoTabular
with SDMClient(url="http://localhost:8000") as client:
result = client.predict(request, model=KumoTabular())
print(result.to_pandas())

The returned DataFrame includes row_index and, for classification, prediction and one probability_<class> column per class. The prediction values depend on the deployed model and the supplied context.

Pass api_key to SDMClient if your deployment has an authenticating gateway.

Next steps