import json
import requests
payload = {
"model": "kumo-relational",
"task": {
"kind": "binary_classification",
"target": {
"column_name": "label",
"dtype": "bool",
"classes": ["false", "true"],
"positive_class": "true",
},
"entity_table_names": ["accounts"],
"anchor_time_column": "anchor_time",
},
"schema": {
"instance_table": {
"columns": {
"instance_id": {
"dtype": "int64",
"stype": "ID",
"nullable": False,
},
"anchor_time": {
"dtype": "timestamp[us]",
"stype": "timestamp",
"nullable": False,
},
"account_id": {
"dtype": "int64",
"stype": "ID",
"nullable": False,
},
"label": {
"dtype": "bool",
"stype": "categorical",
},
},
"primary_key": "instance_id",
},
"related_tables": {
"accounts": {
"columns": {
"instance_id": {
"dtype": "int64",
"stype": "ID",
"nullable": False,
},
"account_id": {
"dtype": "int64",
"stype": "ID",
"nullable": False,
},
"amount": {
"dtype": "float64",
"stype": "numerical",
},
"segment": {
"dtype": "string",
"stype": "categorical",
},
},
"primary_key": ["instance_id", "account_id"],
}
},
"relationships": [
{
"source_columns": ["instance_id", "account_id"],
"target_table": "accounts",
"target_columns": ["instance_id", "account_id"],
}
],
},
"context": {
"instance_table": {
"format": "arrays",
"columns": ["instance_id", "anchor_time", "account_id", "label"],
"rows": [
[0, "2025-01-01T00:00:00Z", 100, False],
[1, "2025-01-01T00:00:00Z", 101, True],
[2, "2025-01-02T00:00:00Z", 102, False],
[3, "2025-01-02T00:00:00Z", 103, True],
],
},
"related_tables": {
"accounts": {
"format": "arrays",
"columns": ["instance_id", "account_id", "amount", "segment"],
"rows": [
[0, 100, 10.5, "small"],
[1, 101, 250.0, "enterprise"],
[2, 102, 12.0, "small"],
[3, 103, 300.0, "enterprise"],
],
}
},
},
"predict": {
"instance_table": {
"format": "arrays",
"columns": ["instance_id", "anchor_time", "account_id"],
"rows": [[4, "2025-02-01T00:00:00Z", 104]],
},
"related_tables": {
"accounts": {
"format": "arrays",
"columns": ["instance_id", "account_id", "amount", "segment"],
"rows": [[4, 104, 275.0, "enterprise"]],
}
},
},
"output": {"fields": ["prediction", "probabilities"]},
}
response = requests.post(
"https://ai.api.nvidia.com/v1/structured-data/nvidia/kumo-relational/predictions",
headers={
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer $NVIDIA_API_KEY",
},
json=payload,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))