viz.poincare
– Visualize Poincare embeddings¶
Utilities for creating 2-D visualizations of Poincare models and Poincare distance heatmaps.
-
gensim.viz.poincare.
poincare_2d_visualization
(model, tree, figure_title, num_nodes=50, show_node_labels=())¶ Create a 2-d plot of the nodes and edges of a 2-d poincare embedding.
- Parameters
model (
PoincareModel
) – The model to visualize, model size must be 2.tree (set) – Set of tuples containing the direct edges present in the original dataset.
figure_title (str) – Title of the plotted figure.
num_nodes (int or None) – Number of nodes for which edges are to be plotted. If None, all edges are plotted. Helpful to limit this in case the data is too large to avoid a messy plot.
show_node_labels (iterable) – Iterable of nodes for which to show labels by default.
- Returns
Plotly figure that contains plot.
- Return type
plotly.graph_objs.Figure
-
gensim.viz.poincare.
poincare_distance_heatmap
(origin_point, x_range=(-1.0, 1.0), y_range=(-1.0, 1.0), num_points=100)¶ Create a heatmap of Poincare distances from origin_point for each point (x, y), where x and y lie in x_range and y_range respectively, with num_points points chosen uniformly in both ranges.
- Parameters
origin_point (tuple (int, int)) – (x, y) from which distances are to be measured and plotted.
x_range (tuple (int, int)) – Range for x-axis from which to choose num_points points.
y_range (tuple (int, int)) – Range for y-axis from which to choose num_points points.
num_points (int) – Number of points to choose from x_range and y_range.
Notes
Points outside the unit circle are ignored, since the Poincare distance is defined only for points inside the circle boundaries (exclusive of the boundary).
- Returns
Plotly figure that contains plot
- Return type
plotly.graph_objs.Figure