probinet.visualization.plot#
It provides a set of plotting functions for visualizing the results of the generative models.
Functions
|
Extract the properties of the bridges of a node i. |
|
Map the nodes of a graph G to the nodes of a graph A. |
|
Plot the adjacency tensor produced by the generative algorithm. |
|
Plot the log-likelihood. |
|
Plot the M matrix produced by the generative algorithm. |
|
Plot the adjacency matrix and its reconstruction given by the marginal and the conditional expected values. |
|
Plot the adjacency matrix and five sampled networks. |
|
Plot a graph and its reconstruction given by the marginal and the conditional expected values. |
|
Plot a graph with nodes colored by their hard memberships. |
|
Plot precision and recall of a given confusion matrix. |
|
Plot a graph with nodes colored by their mixed (soft) memberships. |
- probinet.visualization.plot.extract_bridge_properties(i: int, color: dict, U: ndarray, threshold: float = 0.2) Tuple[ndarray, list] [source]#
Extract the properties of the bridges of a node i.
- Parameters:
i (int) – Index of the node.
color (dict) – Dictionary with the colors of the nodes.
U (ndarray) – Out-going membership matrix.
threshold (float) – Threshold for the membership values.
- Returns:
wedge_sizes (ndarray) – Sizes of the wedges.
wedge_colors (list) – Colors of the wedges.
- probinet.visualization.plot.mapping(G: DiGraph, A: DiGraph) DiGraph [source]#
Map the nodes of a graph G to the nodes of a graph A.
- Parameters:
G (nx.DiGraph) – Graph to be mapped.
A (nx.DiGraph) – Graph to be mapped to.
- Returns:
G – Graph G with the nodes mapped to the nodes of A.
- Return type:
nx.DiGraph
- probinet.visualization.plot.plot_A(A: List, cmap: str = 'Blues') List[Figure] [source]#
Plot the adjacency tensor produced by the generative algorithm.
- Parameters:
A (list) – List of scipy sparse matrices, one for each layer.
cmap (Matplotlib object) – Colormap used for the plot.
- Returns:
figures – List of matplotlib figure objects.
- Return type:
list
- probinet.visualization.plot.plot_L(values: List, indices: List | None = None, k_i: int = 0, xlab: str = 'Iterations', ylabel: str = 'Log-likelihood values', figsize: tuple = (10, 5), int_ticks: bool = False) Figure [source]#
Plot the log-likelihood. :param values: List of log-likelihood values. :type values: list :param indices: List of indices. :type indices: list :param k_i: Number of initial iterations to be ignored. :type k_i: int :param xlab: Label of the x-axis. :type xlab: str :param ylabel: :type ylabel: str :param figsize: Figure size. :type figsize: tuple :param int_ticks: Flag to use integer ticks. :type int_ticks: bool
- Returns:
fig – The matplotlib figure object.
- Return type:
plt.Figure
- probinet.visualization.plot.plot_M(M: ndarray, cmap: str = 'PuBuGn', figsize: Tuple[int, int] = (7, 7), fontsize: int = 15) None [source]#
Plot the M matrix produced by the generative algorithm. Each entry is the Poisson mean associated with each pair of nodes in the graph.
- Parameters:
M (np.ndarray) – NxN M matrix associated with the graph. Contains all the means used for generating edges.
cmap (str, optional) – Colormap used for the plot.
figsize (Tuple[int, int], optional) – Size of the figure to be plotted.
fontsize (int, optional) – Font size to be used in the plot title.
- probinet.visualization.plot.plot_adjacency(Bd: ndarray, M_marginal: ndarray, M_conditional: ndarray, nodes: List, cm: str = 'Blues') Figure [source]#
Plot the adjacency matrix and its reconstruction given by the marginal and the conditional expected values.
- Parameters:
Bd (ndarray) – Adjacency matrix.
M_marginal (ndarray) – Marginal expected values.
M_conditional (ndarray) – Conditional expected values.
nodes (list) – List of nodes.
cm (Matplotlib object) – Colormap used for the plot.
- Returns:
fig – The matplotlib figure object.
- Return type:
plt.Figure
- probinet.visualization.plot.plot_adjacency_samples(Bdata: List, Bsampled: List, cm: str = 'Blues') Figure [source]#
Plot the adjacency matrix and five sampled networks.
- Parameters:
Bdata (list) – List of adjacency matrices for the data.
Bsampled (list) – List of adjacency matrices for sampled networks.
cm (Matplotlib object) – Colormap used for the plot.
- Returns:
fig – The matplotlib figure object.
- Return type:
plt.Figure
- probinet.visualization.plot.plot_graph(graph: DiGraph, M_marginal: ndarray, M_conditional: ndarray, pos: Dict, node_size: int, node_color: str, edge_color: str, threshold: float = 0.2) Figure [source]#
Plot a graph and its reconstruction given by the marginal and the conditional expected values.
- Parameters:
graph (nx.DiGraph) – Graph to be plotted.
M_marginal (ndarray) – Marginal expected values.
M_conditional (ndarray) – Conditional expected values.
pos (dict) – Dictionary with the positions of the nodes.
node_size (int) – Size of the nodes.
node_color (str) – Color of the nodes.
edge_color (str) – Color of the edges.
threshold (float) – Threshold for the membership values.
- Returns:
fig – The matplotlib figure object.
- Return type:
plt.Figure
- probinet.visualization.plot.plot_hard_membership(graph: DiGraph, communities: Dict, pos: Dict, node_size: ndarray, colors: Dict, edge_color: str) Figure [source]#
Plot a graph with nodes colored by their hard memberships.
- Parameters:
graph (nx.DiGraph) – Graph to be plotted.
communities (Dict) – Dictionary with the communities.
pos (Dict) – Dictionary with the positions of the nodes.
node_size (ndarray) – Array with the sizes of the nodes.
colors (Dict) – Dictionary with the colors of the nodes.
edge_color (str) – Color of the edges.
- Returns:
fig – The matplotlib figure object.
- Return type:
plt.Figure
- probinet.visualization.plot.plot_precision_recall(conf_matrix: ndarray, cm: str = 'Blues') Figure [source]#
Plot precision and recall of a given confusion matrix.
- Parameters:
conf_matrix (ndarray) – Confusion matrix.
cm (Matplotlib object) – Colormap used for the plot.
- Returns:
fig – The matplotlib figure object.
- Return type:
plt.Figure
- probinet.visualization.plot.plot_soft_membership(graph: DiGraph, thetas: Dict, pos: Dict, node_size: ndarray, colors: Dict, edge_color: str) Figure [source]#
Plot a graph with nodes colored by their mixed (soft) memberships.
- Parameters:
graph (nx.DiGraph) – Graph to be plotted.
thetas (Dict) – Dictionary with the mixed memberships.
pos (Dict) – Dictionary with the positions of the nodes.
node_size (ndarray) – Array with the sizes of the nodes.
colors (Dict) – Dictionary with the colors of the nodes.
edge_color (str) – Color of the edges.
- Returns:
fig – The matplotlib figure object.
- Return type:
plt.Figure