Cluster Metadata

Open In ColabOpen In Colab

In addition to cluster centroids, there may be additional information you want to store (such as the number of clusters). This information can be stored as metadata in RelevanceAI.

What you will need

You will need to have followed the quickstart clustering guide.

Code Example

Open In ColabOpen In Colab

The following code extracts the metadata from the clustering algorithm and adds this information to RelevanceAI

DATASET_ID = "quickstart_clustering"
VECTOR_FIELD = "product_name_default_vector_"

# Extract all the metadata 
metadata = clusterer.to_metadata()

client.services.cluster.centroids.metadata(
    dataset_id = DATASET_ID,
    vector_field = VECTOR_FIELD,
    alias = "default",
    metadata = metadata
)

Once you have stored the metadata, you can view them using the following code.

client.services.cluster.centroids.metadata(
    dataset_id = DATASET_ID,
    vector_field = VECTOR_FIELD,
    alias = "default"
)

Did this page help you?