Inserting Centroids

How to insert your cluster centroids into Relevance AI

Open In ColabOpen In Colab

Centroids from your clustering algorithm describe the 'average' of each cluster. You can insert these centroids into RelevanceAI to facilitate:

  • Future acceleration of vector search
  • Ability to identify the cluster a new document can belong to
  • Ability to store the centroid vectors with relevant metadata such as a topic

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 centroids from the clustering algorithm and adds this information to RelevanceAI.

DATASET_ID = "quickstart_clustering"
VECTOR_FIELD = "product_image_clip_vector_"

centers = clusterer.get_centroid_documents()
    dataset_id = DATASET_ID,
    cluster_centers = centers,
    vector_field = VECTOR_FIELD,
    alias = "default",

Once you have stored your cluster centroids, you can view them using the following code.
    dataset_id = DATASET_ID,
    vector_field = VECTOR_FIELD,
    page_size = 10,
    include_vector = False,
    alias = "default"

Did this page help you?