torchcell.viz.graph_recovery.GraphRecoveryVisualization
- class GraphRecoveryVisualization(base_dir: str, mplstyle_path: str | None = None)[source]
Bases:
objectVisualization class for graph regularization and edge recovery metrics.
- save_and_log_figure(fig: Figure, name: str, timestamp_str: str | None = None) None[source]
Log figure to wandb only (no disk save).
- Parameters:
fig – Matplotlib figure
name – Wandb panel key (e.g., “val_edge_recovery_summary/recall”)
timestamp_str – Unused, kept for API compatibility
- plot_graph_info_summary(graph_info: dict[str, dict[str, float]], save_path: str | None = None) None[source]
Create a comprehensive summary visualization of graph statistics.
- Parameters:
graph_info – Dict mapping graph_name -> {num_edges, num_nodes, avg_degree, reg_layer, reg_head}
save_path – Optional path to save the figure to disk
- plot_edge_recovery_recall(recall_metrics: dict[str, float], num_epochs: int, timestamp_str: str | None = None, stage: str = 'val') None[source]
Plot recall@degree for each graph as a bar chart.
- Parameters:
recall_metrics – Dict mapping metric_key (e.g., “physical_L0_H1”) -> recall@degree value
num_epochs – Current epoch number
timestamp_str – Unused, kept for API compatibility
stage – Stage name (e.g., “val”)
- plot_edge_recovery_precision(precision_metrics: dict[str, dict[int, float]], k_values: list[int], num_epochs: int, timestamp_str: str | None = None, stage: str = 'val') None[source]
Plot precision@k for each graph as line plots.
- Parameters:
precision_metrics – Dict mapping metric_key (e.g., “physical_L0_H1”) -> {k -> precision value}
k_values – List of k values (e.g., [8, 32, 128, 320])
num_epochs – Current epoch number
timestamp_str – Unused, kept for API compatibility
stage – Stage name (e.g., “val”)
- plot_edge_recovery_per_graph(recall_metrics: dict[str, float], precision_metrics: dict[str, dict[int, float]], k_values: list[int], num_epochs: int, timestamp_str: str | None = None, stage: str = 'val') None[source]
Create individual edge recovery plots for each graph showing both recall and precision@k.
- Parameters:
recall_metrics – Dict mapping graph_name -> recall@degree value
precision_metrics – Dict mapping graph_name -> {k -> precision value}
k_values – List of k values (e.g., [8, 32, 128, 320])
num_epochs – Current epoch number
timestamp_str – Unused, kept for API compatibility
stage – Stage name (e.g., “val”)
- plot_edge_mass_alignment(edge_mass_metrics: dict[str, float], num_epochs: int, timestamp_str: str | None = None, stage: str = 'val') None[source]
Plot edge-mass alignment for each graph as a bar chart.
Edge-mass alignment = fraction of total attention mass on known graph edges.
- Parameters:
edge_mass_metrics – Dict mapping metric_key (e.g., “physical_L0_H1”) -> edge_mass_fraction
num_epochs – Current epoch number
timestamp_str – Unused, kept for API compatibility
stage – Stage name (e.g., “val”)