relevanceai.api.endpoints.cluster

Module Contents

Classes

ClusterClient

Base class for all relevanceai client utilities

class relevanceai.api.endpoints.cluster.ClusterClient(project, api_key)

Bases: relevanceai.base._Base

Base class for all relevanceai client utilities

aggregate(self, dataset_id: str, vector_fields: list, metrics: list = [], groupby: list = [], filters: list = [], page_size: int = 20, page: int = 1, asc: bool = False, flatten: bool = True, alias: str = 'default')

Takes an aggregation query and gets the aggregate of each cluster in a collection. This helps you interpret each cluster and what is in them. It can only can be used after a vector field has been clustered.

For more information about aggregations check out services.aggregate.aggregate.

Parameters
  • dataset_id (string) – Unique name of dataset

  • vector_fields (list) – The vector field that was clustered on

  • metrics (list) – Fields and metrics you want to calculate

  • groupby (list) – Fields you want to split the data into

  • filters (list) – Query for filtering the search results

  • page_size (int) – Size of each page of results

  • page (int) – Page of the results

  • asc (bool) – Whether to sort results by ascending or descending order

  • flatten (bool) – Whether to flatten

  • alias (string) – Alias used to name a vector field. Belongs in field_{alias}vector

facets(self, dataset_id: str, facets_fields: list = [], page_size: int = 20, page: int = 1, asc: bool = False, date_interval: str = 'monthly')

Takes a high level aggregation of every field and every cluster in a collection. This helps you interpret each cluster and what is in them.

Only can be used after a vector field has been clustered.

Parameters
  • dataset_id (string) – Unique name of dataset

  • facets_fields (list) – Fields to include in the facets, if [] then all

  • page_size (int) – Size of each page of results

  • page (int) – Page of the results

  • asc (bool) – Whether to sort results by ascending or descending order

  • date_interval (string) – Interval for date facets