Ship a new version
Ship a retrained model as a new version, compare what the two learned, and retire the old one.
A version is a copy of a model under the same lineage_id: same schema, outputs, inference, reference data and structure, with its own slug, its own history and its own insights. The version that produced the old predictions and explanations keeps them.
- Create the version with POST /v1/models/{model}/versions, or upload the retrained estimator with
version="2"and a new slug. - Replace what changed: PUT …/structure for new weights, PATCH for a schema change, PUT …/reference-data for a new validation set.
- Run
fullanalyses on both and compare their insights;GET /v1/models/{model}/versionslists the lineage, and the project overview's feature matrix shows which inputs each version leans on. - Point traffic at the new slug. Delete a version with DELETE …/versions/{version} when it is retired.
v2 = client.models.create_version("credit-risk-v3", version="4", description="Adds utilisation trend features.")
client.models.upload_structure(v2.id, clf_v4) # the retrained estimator
client.models.upload_reference_data(v2.id, rows=X_valid_v4.to_dict("records"), labels=y_valid_v4.tolist())
client.models.update(v2.id, slug="credit-risk-v4", features=FEATURES_V4)
for ref in ("credit-risk-v3", "credit-risk-v4"):
client.analyses.wait(client.analyses.create(model=ref, type="full").id)
importance = client.insights.list(model=ref, type="global_importance").data[0]
print(ref, [(r["feature"], r["share"]) for r in importance.payload["features"][:3]])
for version in client.models.versions("credit-risk-v3").data:
print(version.version, version.slug, version.explanations_count)curl https://api.kaimei.ai/v1/models/credit-risk-v3/versions \
-H "Authorization: Bearer $KAIMEI_API_KEY" -H "Content-Type: application/json" \
-d '{"version": "4", "slug": "credit-risk-v4", "description": "Adds utilisation trend features."}'