« Back to top page

Visualization

Visualization

Contour Plot

Class or Function Names plot_contour Example from optuna.visualization import plot_contour plot_contour(study) Others See the documentation for more details.

Empirical Distribution Function Plot

Class or Function Names plot_edf Example from optuna.visualization import plot_edf plot_edf(study) Others See the documentation for more details.

Hyperparameter Importances Plot

Class or Function Names plot_param_importances Example from optuna.visualization import plot_param_importances plot_param_importances(study) Others See the documentation for more details.

Hypervolume History Plot

Class or Function Names plot_hypervolume_history Example from optuna.visualization import plot_hypervolume_history plot_hypervolume_history(study, reference_point) Others See the documentation for more details.

Intermediate Values Plot

Class or Function Names plot_intermediate_values Example from optuna.visualization import plot_intermediate_values plot_intermediate_values(study) Others See the documentation for more details.

Optimization History Plot

Class or Function Names plot_optimization_history Example from optuna.visualization import plot_optimization_history plot_optimization_history(study) Others See the documentation for more details.

Parallel Coordinate Plot

Class or Function Names plot_parallel_coordinate Example from optuna.visualization import plot_parallel_coordinate plot_parallel_coordinate(study) Others See the documentation for more details.

Pareto-front Plot

Class or Function Names plot_pareto_front Example from optuna.visualization import plot_pareto_front plot_pareto_front(study) Others See the documentation for more details.

Plot Hypervolume History for Multiple Studies

Class or Function Names plot_optimization_history Example import optuna import optunahub def objective(trial: optuna.Trial) -> tuple[float, float]: x = trial.suggest_float("x", 0, 5) y = trial.suggest_float("y", 0, 3) v0 = 4 * x**2 + 4 * y**2 v1 = (x - 5) ** 2 + (y - 5) ** 2 return v0, v1 samplers = [ optuna.samplers.RandomSampler(), optuna.samplers.TPESampler(), optuna.samplers.NSGAIISampler(), ] studies = [] for sampler in samplers: study = optuna.create_study( sampler=sampler, study_name=f"{sampler.__class__.__name__}", directions=["minimize", "minimize"], ) study.

Plot Hypervolume History with Reference Point

Class or Function Names plot_hypervolume_history Example mod = optunahub.load_module("visualization/plot_hypervolume_history_with_rp") mod.plot_hypervolume_history(study, reference_point) See example.py for more details. The example of generated image is as follows.

Plot Pareto Front for Multiple Studies

Class or Function Names plot_pareto_front Example import optuna import optunahub def objective(trial: optuna.Trial) -> tuple[float, float]: x = trial.suggest_float("x", 0, 5) y = trial.suggest_float("y", 0, 3) v0 = 4 * x**2 + 4 * y**2 v1 = (x - 5) ** 2 + (y - 5) ** 2 return v0, v1 samplers = [ optuna.samplers.RandomSampler(), optuna.samplers.TPESampler(), optuna.samplers.NSGAIISampler(), ] studies = [] for sampler in samplers: study = optuna.create_study( sampler=sampler, study_name=f"{sampler.__class__.__name__}", directions=["minimize", "minimize"], ) study.

Plot the Sampling Speed Benchmark to Compare Multiple Samplers

Class or Function Names plot_sampling_speed Installation This module requires the following dependencies: matplotlib scipy Example A minimal example would be the following: from collections import defaultdict import matplotlib.pyplot as plt import optuna import optunahub def objective(trial) -> float: return trial.suggest_float("x", -5, 5)**2 studies = defaultdict(lambda: []) for i in range(3): sampler = optuna.samplers.RandomSampler() study = optuna.create_study(sampler=sampler) study.optimize(objective, timeout=1.0) studies["Random"].append(study) sampler = optuna.samplers.TPESampler() study = optuna.create_study(sampler=sampler) study.optimize(objective, timeout=3.0) studies["TPE"].append(study) plot_sampling_speed = optunahub.

Rank Plot

Class or Function Names plot_rank Example from optuna.visualization import plot_rank plot_rank(study) Others See the documentation for more details.

Slice Plot

Class or Function Names plot_slice Example from optuna.visualization import plot_slice plot_slice(study) Others See the documentation for more details.

Step Distribution Plot

Class or Function Names plot_step_distribution Installation You should install plotly to use this visualization. $ pip install plotly Example This plot shows how many steps (budget, epoch, iterations, etc.) were consumed before pruning occurred for each trial. fig = plot_step_distribution(study) See example.py for a full example. The following figures are obtained from the analysis of the optimization.

Terminator Improvement Plot

Class or Function Names plot_terminator_improvement Example from optuna.visualization import plot_terminator_improvement plot_terminator_improvement(study) Others See the documentation for more details.

Timeline Plot

Class or Function Names plot_timeline Example from optuna.visualization import plot_timeline plot_timeline(study) Others See the documentation for more details.