aip_sdk.save_clusters
aip_sdk.save_clusters(dataset: str, name: str, pipeline_id: str, *, df: pd.DataFrame | None = None, coordinates: pd.DataFrame | None = None, compute_result: EmbeddingComputeResult | None = None, source_run_id: str | None = None, version_id: str | None = None, client: APIClient | None = None) -> SavedAssignedDimension
Save one pipeline's cluster labels as a dataset-scoped assigned dimension.
Extracts row_id → cluster_id from embedding coordinates and calls
POST /datasets/{id}/dimensions:assign with authored_by="clustering".
The saved dimension resolves as assigned:<name> on every later run of
the same dataset, so slice delta grouping can use
group_by=assigned:<name>.
Unclustered rows are omitted from the assignment: HDBSCAN reports them as
the label "noise", and a pipeline with clustering disabled as null.
Both are dropped rather than saved, so they appear under missing: in
join coverage rather than as a noise category.
Parameters
datasetstr: Dataset id, or"name@vN"to pin the validation version.namestr: Assigned dimension name — lowercase, underscores, no dots.pipeline_idstr: Which pipeline's cluster labels to save.dfpd.DataFrame | None: Run output carrying a nestedembedcolumn. Mutually exclusive withcoordinates=andcompute_result=.coordinatespd.DataFrame | None: Tidy coordinate frame withCOORDINATE_COLUMNS.compute_resultEmbeddingComputeResult | None: Result ofcompute(); itscoordinatesare used.source_run_idstr | None: Run the labels were extracted from — stored as metadata.version_idstr | None: Dataset version whose row ids are validated. Defaults to the latest version. Mutually exclusive with aname@vNpin on dataset — passing both raises rather than silently choosing one.clientAPIClient | None: Optional pre-configured API client.
Returns
SavedAssignedDimension: The saved dimension, including coverage counts from the platform.
Raises
EmbeddingsError: If no coordinate source is given, more than one is given, df carries noembedcolumn, the coordinates frame is missing a required column, dataset is malformed, dataset andversion_id=pin different versions, the pinned version does not exist, the pipeline has no cluster labels, a row carries conflicting labels, or every row is unclustered noise.AipError: If no client is given and none is configured.UnprocessableEntityError: If the name or assignments fail platform validation.NotFoundError: If the dataset does not exist.ConflictError: If concurrent saves of the same dimension cannot be serialised.
Examples:
df = run.output()
saved = aip.embeddings.save_clusters(
dataset.id,
"clusters_semantic",
"umap.text_qa.unsupervised",
df=df,
source_run_id=run.id,
)
# Slice delta: group_by=saved.id