nirs4all.visualization.branch_diagram module
Branch Diagram - DAG visualization for pipeline branching structure.
DEPRECATED: This module is deprecated in favor of pipeline_diagram.py which provides a more comprehensive visualization of the entire pipeline structure.
The BranchDiagram and plot_branch_diagram are now aliases for PipelineDiagram and plot_pipeline_diagram respectively.
Example
>>> from nirs4all.visualization.pipeline_diagram import PipelineDiagram
>>> diagram = PipelineDiagram(pipeline_steps, predictions)
>>> fig = diagram.render()
>>> fig.savefig('pipeline_diagram.png')
- class nirs4all.visualization.branch_diagram.BranchDiagram(predictions: Any = None, config: Dict[str, Any] | None = None)[source]
Bases:
PipelineDiagramDEPRECATED: Use PipelineDiagram instead.
This class is kept for backward compatibility only. It wraps PipelineDiagram with the old API.
- render(show_metrics: bool | None = None, metric: str | None = None, partition: str | None = None, figsize: Tuple[float, float] | None = None, title: str | None = None) Figure[source]
Render the branch diagram (deprecated API).
- Parameters:
show_metrics – Override config’s show_metrics setting.
metric – Override metric to display.
partition – Override partition for metrics.
figsize – Override figure size.
title – Optional title for the diagram.
- Returns:
matplotlib Figure object.
- class nirs4all.visualization.branch_diagram.PipelineDiagram(pipeline_steps: List[Any] | None = None, predictions: Any = None, execution_trace: Any = None, config: Dict[str, Any] | None = None)[source]
Bases:
objectCreate DAG visualization for pipeline execution structure.
Renders a visual diagram showing the complete pipeline topology, including all steps, shapes, branches, and models.
- pipeline_steps
List of pipeline step definitions
- predictions
Optional Predictions object with execution data
- execution_trace
Optional ExecutionTrace with actual runtime shapes
- config
Optional dict for customization
- NODE_STYLES = {'branch': ('#E0F2F1', '#00796B'), 'concat_transform': ('#F3E5F5', '#7B1FA2'), 'default': ('#ECEFF1', '#455A64'), 'feature_augmentation': ('#E0F2F1', '#00796B'), 'input': ('#FAFAFA', '#616161'), 'merge': ('#E0F2F1', '#00796B'), 'merge_sources': ('#E0F2F1', '#00796B'), 'model': ('#FFEBEE', '#D32F2F'), 'output': ('#FAFAFA', '#616161'), 'preprocessing': ('#E3F2FD', '#1976D2'), 'sample_augmentation': ('#E8F5E9', '#388E3C'), 'source_branch': ('#E0F2F1', '#00796B'), 'splitter': ('#F3E5F5', '#7B1FA2'), 'y_processing': ('#FFF8E1', '#FFA000')}
- classmethod from_trace(execution_trace: Any, predictions: Any = None, config: Dict[str, Any] | None = None) PipelineDiagram[source]
Create a PipelineDiagram from an ExecutionTrace.
This builds the diagram using actual runtime data including measured shapes at each step.
- Parameters:
execution_trace – ExecutionTrace object from pipeline execution
predictions – Optional Predictions object to enrich nodes with scores
config – Optional configuration dict
- Returns:
PipelineDiagram instance ready for rendering
Example
>>> from nirs4all.visualization import PipelineDiagram >>> diagram = PipelineDiagram.from_trace(trace) >>> fig = diagram.render(title="Execution Trace")
- nodes: Dict[str, PipelineNode]
- render(show_shapes: bool | None = None, figsize: Tuple[float, float] | None = None, title: str | None = None, initial_shape: Tuple[int, int, int] | None = None) Figure[source]
Render the pipeline diagram.
- Parameters:
show_shapes – Override config’s show_shapes setting
figsize – Override figure size
title – Optional title for the diagram
initial_shape – Initial dataset shape (samples, processings, features)
- Returns:
matplotlib Figure object
- nirs4all.visualization.branch_diagram.plot_branch_diagram(predictions: Any = None, show_metrics: bool = True, metric: str = 'rmse', partition: str = 'test', figsize: Tuple[float, float] | None = None, title: str | None = None, config: Dict[str, Any] | None = None) Figure[source]
DEPRECATED: Use plot_pipeline_diagram instead.
- Parameters:
predictions – Predictions object with branch metadata.
show_metrics – Whether to show metrics in nodes.
metric – Metric to display (default: ‘rmse’).
partition – Partition for metrics (default: ‘test’).
figsize – Figure size tuple.
title – Optional title for the diagram.
config – Additional configuration dict.
- Returns:
matplotlib Figure object.
- nirs4all.visualization.branch_diagram.plot_pipeline_diagram(pipeline_steps: List[Any] | None = None, predictions: Any = None, show_shapes: bool = True, figsize: Tuple[float, float] | None = None, title: str | None = None, initial_shape: Tuple[int, int, int] | None = None, config: Dict[str, Any] | None = None, execution_trace: Any = None) Figure[source]
Convenience function to create a pipeline diagram.
- Parameters:
pipeline_steps – List of pipeline step definitions
predictions – Optional Predictions object with execution data
show_shapes – Whether to show shape info in nodes
figsize – Figure size tuple
title – Optional title for the diagram
initial_shape – Initial dataset shape (samples, processings, features)
config – Additional configuration dict
execution_trace – Optional ExecutionTrace object
- Returns:
matplotlib Figure object
Example
>>> from nirs4all.visualization.pipeline_diagram import plot_pipeline_diagram >>> fig = plot_pipeline_diagram(pipeline, initial_shape=(189, 1, 2151)) >>> fig.savefig('pipeline_diagram.png')