Skip to main content

Models

Create, manage, and load machine learning models.

All methods are accessed via client.models.

create_model()

POST/v1/models/create

Create a new model.

Parameters

modelRequired
The XClassifier or XRegressor model
model_namestrRequired
Name of the model
model_descriptionstrRequired
Description of the model
xDataFrameRequired
Feature matrix
ySeriesRequired
Target variable
run_idstrdefault: None
Optional run ID to associate with the model

Returns

tuple — Tuple of (model_id, version_id)

Example

1result = client.models.create_model(
2 model=model,
3 model_name="My Model",
4 model_description="Predicts customer churn",
5 x=X_train,
6 y=y_train,
7 run_id="run_abc123"
8)

create_model_v2()

POST/v1/models/v2/create

Persist an XGM v2 model from a pre-serialized JSON blob. The client never imports xplainable_gm and so cannot fit a v2 model locally; the blob is produced by an internal/agent training path (the closed package) and posted as-is to the v2 create endpoint.

Parameters

namestrRequired
Model name
descriptionstrRequired
Model description
model_typestrRequired
'classification' or 'regression'
target_namestrRequired
Name of the target column
blobstrRequired
XGM serialization blob (JSON string)
team_idstrdefault: None
Optional team ID (defaults to the session team)
run_idstrdefault: None
Optional run ID to associate with the model
evaluationdictdefault: None
Optional train-set metric dict. When provided, the platform materialises it into the shared evaluation table so aggregate endpoints surface the v2 model (parity with v1).
feature_importancesdictdefault: None
Optional normalised importance dict, materialised onto the v2 partition row alongside the evaluation.
health_infolistdefault: None
Optional per-feature health list (XScan profile shape), materialised into the shared partition-health table.
profiledictdefault: None
Optional v1-shaped ``{base_value, numeric, categorical}`` per-bin profile, materialised onto the v2 partition row so the model-profile UI renders the same two-panel view as v1.
xDataFramedefault: None
Optional training feature matrix. When provided (and ``health_info`` is not), the client computes ``health_info`` via XScan — the SAME open-``xplainable`` code path v1 ``create_model`` uses (never ``xplainable_gm``).
ySeriesdefault: None
Optional training target. Together with ``y_prob``/``y_pred`` (and when ``evaluation`` is not supplied) the client computes ``evaluation`` as ``{'train': evaluate_classification(...)}`` or ``{'train': evaluate_regression(...)}`` — v1's exact shape.
y_probdefault: None
Predicted probabilities (required to auto-compute a classification evaluation).
y_preddefault: None
Predicted values (required to auto-compute a regression evaluation).
created_bystrdefault: None
User id the model is attributed to, for producers that train on a user's behalf (e.g. the autotrain service account). Only the platform's training service may name a user other than the caller; defaults to the caller. Explicit ``evaluation=``/``health_info=`` always take precedence over anything computed from ``x``/``y``.

Returns

tuple — Tuple of (model_id, version_id)

Example

1result = client.models.create_model_v2(
2 name="My Resource",
3 description="A description",
4 model_type="classifier",
5 target_name="...",
6 blob="...",
7 team_id="team_abc123"
8)

add_version_v2()

POST/v1/models/v2/add-version

Add a new version to an EXISTING XGM v2 model (retrain path). v2 counterpart of add_version: persists a pre-serialized blob as a new version under the same model instead of creating a new one. The parent model must have algorithm_version='v2'.

Parameters

model_idstrRequired
ID of the existing v2 model.
blobstrRequired
XGM serialization blob (JSON string).
evaluationdictdefault: None
Optional train-set metric dict (materialised into the shared evaluation table, parity with create_model_v2).
feature_importancesdictdefault: None
Optional normalised importance dict.
health_infolistdefault: None
Optional per-feature health list.
profiledictdefault: None
Optional v1-shaped per-bin profile for the model UI.
created_bystrdefault: None
User id the version is attributed to (see ``create_model_v2``).

Returns

str — The new version_id.

Example

1result = client.models.add_version_v2(
2 model_id="model_abc123",
3 blob="...",
4 evaluation={},
5 feature_importances={},
6 health_info=[],
7 profile={}
8)

add_version()

POST/v1/models/add-version

Add a new version to an existing model.

Parameters

modelRequired
The XClassifier or XRegressor model
model_idstrRequired
ID of the existing model
xDataFrameRequired
Feature matrix
ySeriesRequired
Target variable

Returns

str — The new version_id

Example

1result = client.models.add_version(
2 model=model,
3 model_id="model_abc123",
4 x=X_train,
5 y=y_train
6)

list_team_models()

GET/v1/models/teams/{team_id}

List all models for the current team (based on API key). This method returns comprehensive information about all models accessible to the authenticated user's team.

Returns

list — List of model information including names, descriptions, and metadata

Example

1result = client.models.list_team_models()

get_model()

GET/v1/models/{model_id}

Get detailed information about a model.

Parameters

model_idstrRequired
ID of the model

Returns

ModelInfo — Model information

Example

1result = client.models.get_model(
2 model_id="model_abc123"
3)

list_model_versions()

GET/v1/models/versions/{model_id}

List all versions of a model. Each version carries parameters — what it was fitted with. For v2 (XGM) versions that is a per-feature map, e.g. \{"Tenure": \{"model_class": "XNumericClassification", "num_splines": 12, "l2": 10.0, ...\}\}. Read it before tuning.

Parameters

model_idstrRequired
ID of the model

Returns

list — List of model versions

Example

1result = client.models.list_model_versions(
2 model_id="model_abc123"
3)

list_model_version_partitions()

GET/v1/models/partitions/{version_id}

List all partitions for a model version.

Parameters

version_idstrRequired
ID of the model version (or "latest")

Returns

dict — Dictionary containing partition information

Example

1result = client.models.list_model_version_partitions(
2 version_id="version_xyz789"
3)

PUT/v1/preprocessors/link-preprocessor

Link a model version to a preprocessor version.

Parameters

model_version_idstrRequired
The model version ID
preprocessor_version_idstrRequired
The preprocessor version ID

Returns

None

Example

1result = client.models.link_preprocessor(
2 model_version_id="version_xyz789",
3 preprocessor_version_id="ppv_xyz789"
4)

refit_model()

POST/v1/models/versions/{version_id}/refit

Rapidly refit an existing v1 model with new parameters without retraining. v1 (tree-partition) models only; v2 (XGM) models refit per feature via refit_features. Everything happens server-side in a single API call -- data never leaves the platform. Two modes: 1. Same params for features: set max_depth, weight, etc. directly. Use 'features' to target specific features, or omit for all. 2. Per-feature params: pass feature_params dict to tune each feature independently in one call. e.g.: feature_params={"Tenure Months": {"max_depth": 3}, "Contract": {"max_depth": 5}}

Parameters

version_idstrRequired
ID of the model version to refit.
dataset_idstrRequired
ID of the dataset on the platform.
target_columnstrRequired
Name of the target column.
featureslistdefault: None
List of feature names to update (mode 1). Defaults to all.
feature_paramsdictdefault: None
Per-feature params dict (mode 2). Keys are feature names, values are dicts of params. Overrides features/params. e.g. {"Tenure": {"max_depth": 3}, "Charges": {"max_depth": 5}}
drop_columnslistdefault: None
Columns to drop (same as in original training).
test_sizefloatdefault: 0.2
Test split fraction (same as original training).
max_depthintdefault: None
New max depth (mode 1, None = keep current).
min_info_gainfloatdefault: None
New min info gain (mode 1, None = keep current).
min_leaf_sizefloatdefault: None
New min leaf size (mode 1, None = keep current).
weightfloatdefault: None
New weight (mode 1, None = keep current).
power_degreefloatdefault: None
New power degree (mode 1, None = keep current).
sigmoid_exponentfloatdefault: None
New sigmoid exponent (mode 1, None = keep current).
tail_sensitivityfloatdefault: None
New tail sensitivity (mode 1, None = keep current).

Returns

dict — Dictionary with new version_id, train/test metrics, feature_importances, and the parameters that were changed.

Example

1result = client.models.refit_model(
2 version_id="version_xyz789",
3 dataset_id="ds_abc123",
4 target_column="target",
5 features=[],
6 feature_params={},
7 drop_columns=["id_col"]
8)

refit_features()

POST/v1/models/versions/{version_id}/refit-features

Refit chosen features of a trained (v2 / XGM) model into a new version. The iterate step between training runs: each named feature's submodel is re-solved against the residual of all the others under your overrides; every other feature is untouched. The new version carries fresh train/test metrics, importances and profile, so you can compare it with the original directly. Read the current values first: list_model_versions returns parameters per version ({feature: {knob: value}}); change one thing, refit, compare. Knobs (unspecified ones keep their fitted values): numeric features: num_splines (basis functions; fewer = smoother), l2 (shrinkage; raise to tame an overfitting feature), d2 (smoothness penalty), spacing, monotonic ("increasing" | "decreasing" | null to remove), monotonic_penalty. categorical features: l2 only. Interaction features ("a_&_b") cannot be refitted. Cost: roughly half a training run (the probability calibration is redone), not instant.

Parameters

version_idstrRequired
The model version to refit (must be v2 / XGM).
dataset_idstrRequired
The dataset it was trained on (raw; the linked preprocessor is applied server-side).
target_columnstrRequired
The target column, as at training.
feature_paramsdictRequired
{feature: {knob: value}}, e.g. {"Tenure": {"l2": 50, "monotonic": "decreasing"}}.
drop_columnslistdefault: None
Columns dropped at training (same list).
test_sizefloatdefault: 0.2
Test split fraction, as at training.
seedintdefault: 42
Split seed, as at training (default 42), so metrics are comparable across versions.

Returns

dict — Dict with the new version_id, refit_of, run_id, train_metrics, test_metrics, feature_importances, changed ({feature: applied overrides}) and parameters (post-refit knobs for every feature).

Example

1result = client.models.refit_features(
2 version_id="version_xyz789",
3 dataset_id="ds_abc123",
4 target_column="target",
5 feature_params={},
6 drop_columns=["id_col"],
7 test_size=0.2
8)

apply_relationships()

POST/v1/models/versions/{version_id}/optimization-config

Re-apply the training dataset's current feature relationships to an existing (v2 / XGM) model version. Models trained after datasets.set_relationships already carry the declaration; use this for versions trained before it, or after the declaration changed. Feasibility rules and derived columns are recompiled and written into the version's optimisation config — costs, bounds, immutables and grid settings are kept. Rules naming a column the model does not have are skipped and reported.

Parameters

version_idstrRequired
Model version to reconfigure.
dataset_idstrdefault: None
Dataset whose declaration to apply; defaults to the dataset the version was trained on.

Returns

dict — Dict with relationships_revision, rules {added, removed, kept}, derived, warnings and deployment_stale — when True, re-deploy the version (deployments_deploy) for the rules to take effect.

Example

1result = client.models.apply_relationships(
2 version_id="version_xyz789",
3 dataset_id="ds_abc123"
4)

train_model()

POST/v1/models/v2/train

Train a new model server-side from a platform dataset. Single synchronous call — the platform loads the dataset, applies the optional fitted preprocessor, splits, fits an explainable model, and persists it. Data never leaves the platform; expect the call to take up to a few minutes for large datasets. This is the core of the iterate loop: train, inspect the train/test gap (get_feature_info / evaluation reads), then refit_model for cheap parameter iteration or call train_model again to restructure features or preprocessing.

Parameters

dataset_idstrRequired
ID of the dataset on the platform.
target_columnstrRequired
Name of the column to predict.
model_namestrRequired
Name for the new model.
model_descriptionstrdefault: ''
Optional description of the model's purpose.
model_typestrdefault: 'classification'
"classification" or "regression".
feature_columnslistdefault: None
Explicit feature whitelist. Defaults to all columns except the target and drop_columns.
drop_columnslistdefault: None
Columns to exclude (ids, leakage, etc.).
preprocessor_version_idstrdefault: None
Optional fitted preprocessor version to apply before training.
monotonic_featuresdictdefault: None
Monotonic constraints, as a map of numeric feature name to direction: "increasing" (higher value never lowers the prediction) or "decreasing". e.g. {"Monthly Charges": "increasing", "Tenure": "decreasing"}. Applied to the whole effect, interactions included. Merged over the dataset's declared monotonic relationships (explicit wins). Constraints on non-numeric features are ignored.
test_sizefloatdefault: 0.2
Test split fraction (0 < test_size < 1).
seedintdefault: 42
Random seed for the train/test split. The dataset's declared feature relationships (datasets

Returns

dict — Dict with model_id, version_id, run_id, train_metrics, test_metrics, feature_importances, n_train, n_test and warnings (relationship entries skipped, monotonic constraints the fitted effect still violates).

Example

1result = client.models.train_model(
2 dataset_id="ds_abc123",
3 target_column="target",
4 model_name="My Model",
5 model_description="Predicts customer churn",
6 model_type="classifier",
7 feature_columns=[]
8)

get_model_profile()

GET/v1/models/profile/{version_id}

Get the model profile showing feature contributions and decision boundaries.

Parameters

version_idstrRequired
ID of the model version.

Returns

dict — Dictionary containing the model profile data.

Example

1result = client.models.get_model_profile(
2 version_id="version_xyz789"
3)

get_model_evaluation()

GET/v1/models/evaluation/{partition_id}

Get detailed evaluation metrics for a model partition.

Parameters

partition_idstrRequired
ID of the model partition.

Returns

dict — Dictionary containing evaluation metrics.

Example

1result = client.models.get_model_evaluation(
2 partition_id="..."
3)

get_feature_info()

GET/v1/models/feature-info/{version_id}

Get feature information including types, health metrics, and distributions.

Parameters

version_idstrRequired
ID of the model version.

Returns

dict — Dictionary containing feature information.

Example

1result = client.models.get_feature_info(
2 version_id="version_xyz789"
3)