relevanceai.visualise.projector
Module Contents
Classes
Projector class. |
Attributes
- relevanceai.visualise.projector.chained_assignment
- relevanceai.visualise.projector.RELEVANCEAI_BLUE = #1854FF
- class relevanceai.visualise.projector.Projector(project, api_key)
Bases:
relevanceai.utils.Utils,relevanceai.api.client.BatchAPIClient,relevanceai.base._Base,doc_utils.DocUtilsProjector class.
Example
>>> from relevanceai import Client >>> project = input() >>> api_key = input() >>> client = Client(project, api_key) >>> client.projector.plot( dataset_id, vector_field, number_of_points_to_render, random_state, dr, dr_args, dims, vector_label, label_char_length, color_label, colour_label_char_length, hover_label, cluster, cluster_args, )
- plot(self, dataset_id: str, vector_field: str, number_of_points_to_render: int = 1000, vector_label: relevanceai.vector_tools.constants.Union[None, str] = None, dr: relevanceai.vector_tools.constants.Union[relevanceai.vector_tools.constants.DIM_REDUCTION, relevanceai.vector_tools.dim_reduction.DimReductionBase] = 'pca', dims: relevanceai.vector_tools.constants.Literal[2, 3] = 3, dr_args: relevanceai.vector_tools.constants.Union[None, relevanceai.vector_tools.constants.Dict] = None, cluster: relevanceai.vector_tools.constants.Union[relevanceai.vector_tools.constants.CLUSTER, relevanceai.vector_tools.cluster.ClusterBase] = None, num_clusters: relevanceai.vector_tools.constants.Union[None, int] = 10, cluster_args: relevanceai.vector_tools.constants.Dict = {}, cluster_on_dr: bool = False, hover_label: list = [], show_image: bool = False, label_char_length: int = 50, marker_size: int = 5, interactive: bool = False)
Dimension reduce vectors and plot with functionality to visualise different clusters and nearest neighbours
To write your own custom dimensionality reduction, you should inherit from DimReductionBase: from relevanceai.visualise.dim_reduction import DimReductionBase class CustomDimReduction(DimReductionBase):
- def fit_transform(self, vectors):
return np.arange(512, 2)
Example
>>> from relevanceai import Client >>> project = input() >>> api_key = input() >>> client = Client(project, api_key) >>> client.projector.plot( dataset_id, vector_field, number_of_points_to_render, random_state, dr, dr_args, dims, vector_label, label_char_length, color_label, colour_label_char_length, hover_label, cluster, cluster_args, )
- Parameters
dataset_id (string) – Unique name of dataset
vector_field (list) – Vector field to plot
number_of_points_to_render (int) – Number of vector fields to plot
vector_label (string) – Field to use as label to describe vector on plot
dr (string) – Method of dimension reduction for vectors
dims (int) – Number of dimensions to reduce to
dr_args (dict) – Additional arguments for dimension reduction
cluster (string) – Method of clustering for vectors
num_clusters (string) – Number of clusters to create
cluster_args (dict) – Additional arguments for clustering
cluster_on_dr (int) – Whether to cluster on the dimension reduced or original vectors
hover_label (list) – Additional labels to include as plot labels
show_image (bool) – Whether vector labels are image urls
label_char_length (int) – Maximum length of text for each hover label
marker_size (int) – Marker size of the plot
interactive (bool) – Whether to include interactive features including nearest neighbours
- plot_from_docs(self, docs: relevanceai.vector_tools.constants.List[relevanceai.vector_tools.constants.Dict], vector_field: str, vector_label: relevanceai.vector_tools.constants.Union[None, str] = None, dr: relevanceai.vector_tools.constants.Union[relevanceai.vector_tools.constants.DIM_REDUCTION, relevanceai.vector_tools.dim_reduction.DimReductionBase] = 'pca', dims: relevanceai.vector_tools.constants.Literal[2, 3] = 3, dr_args: relevanceai.vector_tools.constants.Union[None, relevanceai.vector_tools.constants.Dict] = None, cluster: relevanceai.vector_tools.constants.Union[relevanceai.vector_tools.constants.CLUSTER, relevanceai.vector_tools.cluster.ClusterBase] = None, num_clusters: relevanceai.vector_tools.constants.Union[None, int] = 10, cluster_args: relevanceai.vector_tools.constants.Dict = {}, cluster_on_dr: bool = False, hover_label: list = [], show_image: bool = False, label_char_length: int = 50, marker_size: int = 5, dataset_name: relevanceai.vector_tools.constants.Union[None, str] = None, interactive: bool = False)
- _generate_plot_data(self, embedding_df: pandas.DataFrame, hover_label: relevanceai.vector_tools.constants.List[str], dims: int, marker_size: int, cluster: relevanceai.vector_tools.constants.Union[relevanceai.vector_tools.constants.Literal[kmeans], relevanceai.vector_tools.constants.Literal[kmedoids], relevanceai.vector_tools.constants.Literal[hdbscan], relevanceai.vector_tools.cluster.ClusterBase, None], label_char_length: int)
- _generate_layout(self, plot_title)
- _generate_plot_info(self, embedding_df, hover_label, dims, marker_size, label_char_length)
- _generate_hover_template(self, df: pandas.DataFrame, dims: int, hover_label: list, label_char_length: int)
Generating hover template
- _generate_plot_title(self, dims, dataset_name, number_of_points, vector_field, vector_label, label_char_length)