Skip to main content

Datasets

Upload, manage, and explore datasets.

All methods are accessed via client.datasets.

list_datasets()

List all available public datasets.

Returns

list — List of dataset names

Example

1result = client.datasets.list_datasets()

load_dataset()

Load a public dataset by name. Downloads the CSV directly from the xplainable public blob storage. Known datasets: telco_churn, titanic, heart_disease, iris

Parameters

namestrRequired
Name of the dataset to load

Returns

DataFrame — DataFrame containing the dataset

Example

1result = client.datasets.load_dataset(
2 name="My Resource"
3)

upload_dataset()

Upload a dataset from inline JSON records. Accepts inline records (list of row dicts) so it works from remote callers such as the hosted MCP server — no file paths.

Parameters

namestrRequired
Name for the dataset
recordslistRequired
Rows as a list of dicts (JSON records)
descriptionstrdefault: None
Optional description
team_idstrdefault: None
Optional team ID (uses session team_id if not provided)

Returns

DatasetUploadResponse — Upload response with dataset information

Example

1result = client.datasets.upload_dataset(
2 name="My Resource",
3 records=[],
4 description="A description",
5 team_id="team_abc123"
6)

upload_dataset_file()

Upload a dataset from a local file.

Parameters

file_pathstrRequired
Path to the dataset file
namestrRequired
Name for the dataset
descriptionstrdefault: None
Optional description
team_idstrdefault: None
Optional team ID (uses session team_id if not provided)

Returns

DatasetUploadResponse — Upload response with dataset information

Example

1result = client.datasets.upload_dataset_file(
2 file_path="./data.csv",
3 name="My Resource",
4 description="A description",
5 team_id="team_abc123"
6)

delete_dataset()

DELETE/v1/datasets/{dataset_id}

Delete a dataset.

Parameters

dataset_idstrRequired
ID of the dataset to delete

Returns

dict — Success message

Example

1result = client.datasets.delete_dataset(
2 dataset_id="ds_abc123"
3)

get_dataset_info()

GET/v1/datasets/{dataset_id}

Get information about a specific dataset.

Parameters

dataset_idstrRequired
ID of the dataset

Returns

DatasetInfo — Dataset information

Example

1result = client.datasets.get_dataset_info(
2 dataset_id="ds_abc123"
3)

preview_dataset()

GET/v1/datasets/{dataset_id}/preview

Preview a window or random sample of a dataset.

Parameters

dataset_idstrRequired
ID of the dataset
rowsintdefault: 10
Number of rows to return (1-1000)
offsetintdefault: 0
Rows to skip before the window (ignored when sampling)
samplebooldefault: False
Return a reproducible random sample instead of a head window

Returns

DataFrame — DataFrame with preview data

Example

1result = client.datasets.preview_dataset(
2 dataset_id="ds_abc123",
3 rows=10,
4 offset=1,
5 sample=True
6)

preview_dataset_json()

Preview a dataset as JSON records. The default is a head window. Datasets are often ordered (e.g. by the target), so a head window can be badly biased — pass sample=True to see a representative slice, or page with offset.

Parameters

dataset_idstrRequired
ID of the dataset
rowsintdefault: 10
Number of rows to return (1-1000)
offsetintdefault: 0
Rows to skip before the window (ignored when sampling)
samplebooldefault: False
Return a reproducible random sample instead of a head window

Returns

list — List of row dicts (JSON records)

Example

1result = client.datasets.preview_dataset_json(
2 dataset_id="ds_abc123",
3 rows=10,
4 offset=1,
5 sample=True
6)

list_team_datasets()

GET/v1/datasets/teams/{team_id}

List all datasets for a team.

Parameters

team_idstrdefault: None
Optional team ID (uses session team_id if not provided)

Returns

list — List of dataset information

Example

1result = client.datasets.list_team_datasets(
2 team_id="team_abc123"
3)

get_relationships()

GET/v1/datasets/{dataset_id}/relationships

Read the dataset's declared feature relationships. Relationships are the things the model cannot see feature by feature: derived columns (EstimatedLifetimeCharges = tenure * MonthlyCharges), implications between categorical features (InternetService=No implies every add-on is No) and confirmed monotonic directions. They are declared once per dataset and copied into every model trained on it, where the optimiser enforces them.

Parameters

dataset_idstrRequired

Returns

dict — Dict with revision, updated_by, updated, derived, implies, infeasible, monotonic, notes. revision 0 means nothing declared.

Example

1result = client.datasets.get_relationships(
2 dataset_id="ds_abc123"
3)

infer_relationships()

POST/v1/datasets/{dataset_id}/relationships/infer

Propose feature relationships from the data, with evidence. Scans up to 50k rows and returns candidates for the agent to review before committing with set_relationships — nothing is stored: - implies: category pairs that never co-occur (parent level with at least 30 rows), each with support and the never-seen values; - derived: numeric columns that equal an arithmetic combination of two others (a * b, a + b, a - b, a / b) to 1e-6; - monotonic_hints: numeric features whose Spearman correlation with the target exceeds 0.3 in magnitude (hints only — confirm from domain knowledge before declaring); - existing: the current declaration.

Parameters

dataset_idstrRequired
Dataset to scan.
target_columnstrdefault: None
Target column, for monotonic hints (optional).

Returns

dict

Example

1result = client.datasets.infer_relationships(
2 dataset_id="ds_abc123",
3 target_column="target"
4)

set_relationships()

PUT/v1/datasets/{dataset_id}/relationships

Declare (replace) the dataset's feature relationships. Validated against the data before it is stored: columns and categories must exist, every derived expression must evaluate (pandas-eval syntax, backticks for names with spaces), and an implication must actually forbid something. The declaration is copied into every model trained afterwards; existing versions pick it up with models.apply_relationships.

Parameters

dataset_idstrRequired
Dataset to declare on.
deriveddictdefault: None
``{column: expression}``, e.g. ``{"EstimatedLifetimeCharges": "tenure * MonthlyCharges"}``. The optimiser never moves a derived column and recomputes it from its parents for every candidate.
implieslistdefault: None
``[{"when": {feature: [values]}, "then": {feature: [allowed values]}}]``. Compiled to symmetric forbidden combinations, so one rule covers both directions.
infeasiblelistdefault: None
raw forbidden combinations ``[{feature: [values],
monotonicdictdefault: None
``{feature: "increasing" | "decreasing"}`` confirmed constraints applied at training (explicit train_model(monotonic_features=...) wins per feature).
notesdictdefault: None
free-text rationale per entry, e.g. ``{"implies[0]": "no add-ons without an internet plan"}``.

Returns

dict — Dict with the stored relationships (new revision), the compiled rules and any warnings (e.g. a derived expression that does not reproduce the stored column).

Example

1result = client.datasets.set_relationships(
2 dataset_id="ds_abc123",
3 derived={},
4 implies=[],
5 infeasible=[],
6 monotonic={},
7 notes={}
8)