Visualizer
Visualizer bound to a trainer. Exposes single-model plots. User can subclass to customize plotting behavior.
Source code in gradiend/visualizer/visualizer.py
compute_topk_sets
staticmethod
Compute top-k weight sets for multiple models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
Dict[str, Any]
|
Mapping from model label to model with |
required |
topk
|
int
|
Number of top weights to select per model. |
100
|
part
|
str
|
Model part passed to |
'decoder-weight'
|
Source code in gradiend/visualizer/visualizer.py
plot_encoder_by_target
plot_encoder_by_target(encoder_df=None, *, plot_style='strip', title=None, output=None, show=True, figsize=None, jitter=0.25, dodge=True, point_size=1.5, interactive=False, height=520, legend_loc='upper right', highlight_non_convergence=None, **kwargs)
Plot encoded values by masked target token for this trainer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoder_df
|
Optional[DataFrame]
|
Optional precomputed encoder analysis DataFrame. |
None
|
plot_style
|
Literal['strip', 'box', 'violin']
|
Static plot style: |
'strip'
|
title
|
Optional[str]
|
Optional plot title. |
None
|
output
|
Optional[str]
|
Explicit output path. |
None
|
show
|
bool
|
Whether to display the plot. |
True
|
figsize
|
Optional[Tuple[float, float]]
|
Static figure size in inches. |
None
|
jitter
|
float
|
Jitter width for static strip plots. |
0.25
|
dodge
|
bool
|
Whether to dodge points by hue. |
True
|
point_size
|
float
|
Marker size for static strip plots. |
1.5
|
interactive
|
bool
|
Return/write a Plotly interactive strip plot instead of a static plot. |
False
|
height
|
int
|
Plotly figure height for interactive plots. |
520
|
legend_loc
|
str
|
Matplotlib legend location for static plots. |
'upper right'
|
highlight_non_convergence
|
Optional[bool]
|
Append a non-convergence marker when requested. |
None
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in gradiend/visualizer/visualizer.py
plot_encoder_distributions
plot_encoder_distributions(encoder_df=None, *, output=None, output_dir=None, show=True, title=True, target_and_neutral_only=True, split_plot_mode='facet', include_neutral=False, figsize=None, img_format='png', dpi=None, highlight_non_convergence=None, return_fig_ax=False, **kwargs)
Plot encoder distributions for this trainer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoder_df
|
Optional[DataFrame]
|
Optional precomputed encoder analysis DataFrame. |
None
|
output
|
Optional[str]
|
Explicit output path. |
None
|
output_dir
|
Optional[str]
|
Directory used when resolving the default output filename. |
None
|
show
|
bool
|
Whether to display the plot. |
True
|
title
|
Union[str, bool]
|
True for the default title, False for no title, or a custom title string. |
True
|
target_and_neutral_only
|
bool
|
Restrict to target transitions and neutral rows. |
True
|
split_plot_mode
|
str
|
Multi-split layout mode. |
'facet'
|
include_neutral
|
bool
|
Include neutral encoder rows. |
False
|
figsize
|
Optional[Tuple[float, float]]
|
Figure size in inches. |
None
|
img_format
|
str
|
File format used when saving. |
'png'
|
dpi
|
Optional[int]
|
Optional savefig DPI. |
None
|
highlight_non_convergence
|
Optional[bool]
|
Append a non-convergence marker when requested. |
None
|
return_fig_ax
|
bool
|
Return |
False
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in gradiend/visualizer/visualizer.py
plot_encoder_scatter
plot_encoder_scatter(encoder_df=None, *, color_by='label', x_col=None, label_name_mapping=None, max_points=None, show=True, title=None, height=500, split='test', highlight_non_convergence=None, **kwargs)
Create an interactive encoder scatter plot for this trainer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoder_df
|
Optional[DataFrame]
|
Optional precomputed encoder analysis DataFrame. |
None
|
color_by
|
str
|
Column used for point colors. |
'label'
|
x_col
|
Optional[str]
|
Optional column used for the x-axis. Defaults to target token when available. |
None
|
label_name_mapping
|
Optional[dict]
|
Optional display-name mapping for color labels. |
None
|
max_points
|
Optional[int]
|
Optional stratified point limit. |
None
|
show
|
bool
|
Whether to display the Plotly figure. |
True
|
title
|
Optional[str]
|
Optional plot title. |
None
|
height
|
int
|
Plotly figure height. |
500
|
split
|
str
|
Encoder split to compute when |
'test'
|
highlight_non_convergence
|
Optional[bool]
|
Append a non-convergence marker when requested. |
None
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in gradiend/visualizer/visualizer.py
plot_encoder_strip_by_split
plot_encoder_strip_by_split(encoder_df=None, *, include_neutral=False, title=None, output=None, show=True, figsize=None, jitter=0.08, dodge=True, point_size=5.0, label_points=False, highlight_non_convergence=None, **kwargs)
Plot encoded values by feature group and data split for this trainer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoder_df
|
Optional[DataFrame]
|
Optional precomputed encoder analysis DataFrame. |
None
|
include_neutral
|
bool
|
Include neutral encoder rows. |
False
|
title
|
Optional[str]
|
Optional plot title. |
None
|
output
|
Optional[str]
|
Explicit output path. |
None
|
show
|
bool
|
Whether to display the plot. |
True
|
figsize
|
Optional[Tuple[float, float]]
|
Figure size in inches. |
None
|
jitter
|
float
|
Horizontal jitter width. |
0.08
|
dodge
|
bool
|
Whether to dodge points by hue. |
True
|
point_size
|
float
|
Marker size. |
5.0
|
label_points
|
Union[bool, Literal['outliers', 'outliers+sample', 'sample'], str]
|
Point-label mode. |
False
|
highlight_non_convergence
|
Optional[bool]
|
Append a non-convergence marker when requested. |
None
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in gradiend/visualizer/visualizer.py
plot_probability_shifts
plot_probability_shifts(decoder_results=None, class_ids=None, target_class=None, increase_target_probabilities=True, use_cache=None, *, output=None, show=True, figsize=None, highlight_non_convergence=None, return_fig_ax=False, **kwargs)
Plot decoder probability shifts for this trainer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
decoder_results
|
Optional[Dict[str, Any]]
|
Optional precomputed decoder evaluation results. |
None
|
class_ids
|
Optional[List[str]]
|
Classes to include. Defaults to trainer classes. |
None
|
target_class
|
Optional[str]
|
Target class whose probability shift is highlighted. |
None
|
increase_target_probabilities
|
bool
|
Select strengthening or weakening summary. |
True
|
use_cache
|
Optional[bool]
|
Cache flag forwarded to trainer decoder evaluation/analysis. |
None
|
output
|
Optional[str]
|
Explicit output path. |
None
|
show
|
bool
|
Whether to display the plot. |
True
|
figsize
|
Optional[Tuple[float, float]]
|
Figure size in inches. |
None
|
highlight_non_convergence
|
Optional[bool]
|
Append a non-convergence marker when requested. |
None
|
return_fig_ax
|
bool
|
Return |
False
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in gradiend/visualizer/visualizer.py
plot_topk_neuron_intersection
Plot a top-k neuron intersection Venn diagram.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
Optional[Dict[str, Any]]
|
Optional mapping of model label to model. When |
None
|
topk
|
int
|
Number of top weights to include per model. |
100
|
part
|
str
|
Model part passed to |
'decoder-weight'
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in gradiend/visualizer/visualizer.py
plot_training_convergence
plot_training_convergence(*, plot_mean_by_class=True, plot_mean_by_feature_class=None, plot_correlation=True, class_spread=None, output=None, show=True, title=True, figsize=None, img_format='png', dpi=None, highlight_non_convergence=None, return_fig_ax=False, **kwargs)
Plot convergence statistics for this trainer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plot_mean_by_class
|
bool
|
Include mean encoded value by class. |
True
|
plot_mean_by_feature_class
|
Optional[bool]
|
Include mean encoded value by feature class. |
None
|
plot_correlation
|
bool
|
Include correlation over training steps. |
True
|
class_spread
|
Optional[Literal['minmax', 'iqr', 'ci95']]
|
Optional spread band behind class means.
|
None
|
output
|
Optional[str]
|
Explicit output path. |
None
|
show
|
bool
|
Whether to display the plot. |
True
|
title
|
Union[str, bool]
|
True for the default title, False for no title, or a custom title string. |
True
|
figsize
|
Optional[Tuple[float, float]]
|
Figure size in inches. |
None
|
img_format
|
str
|
File format used when saving. |
'png'
|
dpi
|
Optional[int]
|
Optional savefig DPI. |
None
|
highlight_non_convergence
|
Optional[bool]
|
Append a non-convergence marker when requested. |
None
|
return_fig_ax
|
bool
|
Return |
False
|
**kwargs
|
Any
|
Forwarded to |
{}
|