Skip to content

Plotting

scree_plot

scree_plot(model: VBPCA | VBPCA, *, ax: Axes | None = None, cumulative: bool = True) -> Figure

Plot explained variance ratio per component (scree plot).

Parameters:

Name Type Description Default
model VBPCA | VBPCA

A fitted VBPCA instance.

required
ax Axes | None

Optional matplotlib Axes to draw on. A new figure is created when None.

None
cumulative bool

If True, overlay a cumulative variance line.

True

Returns:

Type Description
Figure

The matplotlib Figure containing the plot.

Raises:

Type Description
RuntimeError

If the model has not been fitted or lacks explained-variance information.

loadings_barplot

loadings_barplot(model: VBPCA | VBPCA, component: int = 0, *, ax: Axes | None = None, top_n: int | None = None, feature_names: list[str] | None = None) -> Figure

Bar plot of loadings (weights) for a single component.

Parameters:

Name Type Description Default
model VBPCA | VBPCA

A fitted VBPCA instance.

required
component int

Zero-based component index.

0
ax Axes | None

Optional matplotlib Axes.

None
top_n int | None

If set, show only the top_n features by absolute loading.

None
feature_names list[str] | None

Optional labels for the feature axis.

None

Returns:

Type Description
Figure

The matplotlib Figure containing the plot.

Raises:

Type Description
RuntimeError

If the model has not been fitted.

variance_explained_plot

variance_explained_plot(model: VBPCA | VBPCA, *, ax: Axes | None = None) -> Figure

Plot per-component explained variance (absolute, not ratio).

Parameters:

Name Type Description Default
model VBPCA | VBPCA

A fitted VBPCA instance.

required
ax Axes | None

Optional matplotlib Axes.

None

Returns:

Type Description
Figure

The matplotlib Figure containing the plot.

Raises:

Type Description
RuntimeError

If the model has not been fitted or lacks explained-variance information.