relevanceai.operations.dr.base#

Module Contents#

class relevanceai.operations.dr.base.DimReductionBase(**kwargs)#

Using verbose loguru as base logger for now

abstract fit_transform(self, *args, **kw) numpy.ndarray#
abstract fit(self, *args, **kw)#
abstract transform(self, *args, **kw)#
transform_documents(self, vector_fields: List[str], documents: List[Dict])#
fit_documents(self, vector_fields: List[str], documents: List[Dict])#
get_dr_vector_field_name(self, vector_field: str, alias: str)#
fit_transform_documents(self, vector_fields: List[str], documents: List[Dict], alias: str, exclude_original_vectors: bool = True, dims: int = 3)#

This function takes a list of documents, a field name, and a dimensionality reduction algorithm, and returns a list of documents with a new field containing the dimensionality reduced vectors

Parameters
  • vector_field (str) – The name of the field in the documents that contains the vectors to be reduced.

  • documents (List[Dict]) – The documents to transform.

  • alias (str) – The name of the new field that will be created in the documents.

  • exclude_original_vectors (bool, optional) – If True, the original vector field will be excluded from the returned documents.

  • dims (int, optional) – The number of dimensions to reduce the vectors to.

Return type

A list of documents with the original vector field and the new vector field.

class relevanceai.operations.dr.base.DimReduction(credentials: relevanceai.client.helpers.Credentials)#

_Base class for all relevanceai client utilities

static dim_reduce(vectors: numpy.ndarray, dr: Union[relevanceai.operations.cluster.constants.DIM_REDUCTION, DimReductionBase], dr_args: Union[None, dict], dims: typing_extensions.Literal[2, 3]) numpy.ndarray#

Dimensionality reduction