Plots

plot_fitness_evolution(estimator[, metric, ...])

Plot one or more evolution metrics stored in estimator.history.

plot_history(estimator[, fields, source, ...])

Plot arbitrary history or logbook fields in an easier-to-read layout.

plot_search_space(estimator[, height, s, ...])

Plot the sampled search space used during the optimization.

sklearn_genetic.plots.plot_fitness_evolution(estimator, metric='fitness_best', metrics=None, *, kind='line', window=None, ax=None, title=None, palette=None)[source]

Plot one or more evolution metrics stored in estimator.history.

Parameters:
estimator: estimator object

A fitted estimator from GASearchCV or GAFeatureSelectionCV.

metric: str, default=”fitness_best”

Backward-compatible name for a single metric to plot.

metrics: list[str] | tuple[str] | None, default=None

Optional collection of history fields to plot together.

kind: {“line”, “bar”, “area”, “step”}, default=”line”

Plot style.

window: int | None, default=None

Optional rolling window applied before plotting.

ax: matplotlib.axes.Axes | None, default=None

Axis to draw on. A new axis is created if omitted.

title: str | None, default=None

Optional plot title.

palette: str | None, default=None

Optional seaborn palette name used for multiple series.

Returns:
matplotlib.axes.Axes

The axis used for the plot.

sklearn_genetic.plots.plot_history(estimator, fields=None, *, source='history', kind='line', rolling=None, subplots=None, figsize=None, title=None, palette=None)[source]

Plot arbitrary history or logbook fields in an easier-to-read layout.

Parameters:
estimator: estimator object

A fitted estimator with history or logbook data.

fields: list[str] | str | None, default=None

Explicit fields to plot. If omitted, numeric fields are selected automatically from the chosen source.

source: {“history”, “logbook”}, default=”history”

Data source to plot from.

kind: {“line”, “bar”, “area”, “step”}, default=”line”

Plot style for each field.

rolling: int | None, default=None

Optional rolling window applied to the plotted values.

subplots: bool | None, default=None

If True, plot one subplot per field. If False, overlay everything on one axis. If None, a readable default is chosen automatically.

figsize: tuple[float, float] | None, default=None

Optional figure size.

title: str | None, default=None

Optional figure title.

palette: str | None, default=None

Optional seaborn palette name.

Returns:
matplotlib.axes.Axes | numpy.ndarray[matplotlib.axes.Axes]

The created axis or axes.

sklearn_genetic.plots.plot_search_space(estimator, height=2, s=25, features=None, *, kind='pair', hue=None)[source]

Plot the sampled search space used during the optimization.

Parameters:
estimator: estimator object

A fitted estimator from GASearchCV.

height: float, default=2

Height of each facet for pair plots.

s: float, default=25

Marker size for scatter-based plots.

features: list[str] | None, default=None

Subset of fields to plot. If omitted, numeric parameter fields are used.

kind: {“pair”, “heatmap”}, default=”pair”

Plot style. pair shows pairwise relationships, while heatmap shows a correlation matrix.

hue: str | None, default=None

Optional column used to color the pair plot.

Returns:
seaborn.axisgrid.PairGrid | matplotlib.axes.Axes

Pair grid or heatmap axis depending on kind.