Front visualization

The jmetal.lab.visualization submodule contains several classes useful for plotting solutions. jMetalPy includes three types of visualization charts: static, interactive and streaming.

Static plots

  • It is possible to visualize the final front approximation by using the Plot class:

    from jmetal.lab.visualization import Plot
    
    plot_front = Plot(title='Pareto front approximation', axis_labels=['x', 'y'])
    plot_front.plot(front, label='NSGAII-ZDT1')
    

    Note

    Static charts can be shown in the screen or stored in a file by setting the filename.

    For problems with two and three objectives, the figure produced is a scatter plot; for problems with more than three objectives, a parallel coordinates plot is used. Note that any arbitrary number of fronts can be plotted for comparison purposes:

    plot_front = Plot(title='Pareto front approximation', axis_labels=['x', 'y'])
    plot_front.plot([front1, front2], label=['zdt1', 'zdt2'], filename='output', format='eps')
    

API

class jmetal.lab.visualization.plotting.Plot(title: str = 'Pareto front approximation', reference_front: List[S] | None = None, reference_point: list | None = None, axis_labels: list | None = None)[source]

Bases: object

static get_points(solutions: List[S]) Tuple[DataFrame, int][source]

Get points for each solution of the front.

Parameters:

solutions – List of solutions.

Returns:

Pandas dataframe with one column for each objective and one row for each solution.

pcoords(fronts: List[list], normalize: bool = False, filename: str | None = None, format: str = 'eps')[source]

Plot any arbitrary number of fronts in parallel coordinates.

Parameters:
  • fronts – List of fronts (containing solutions).

  • filename – Output filename.

plot(front, label='', normalize: bool = False, filename: str | None = None, format: str = 'eps')[source]

Plot any arbitrary number of fronts in 2D, 3D or p-coords.

Parameters:
  • front – Pareto front or a list of them.

  • label – Pareto front title or a list of them.

  • normalize – If True, normalize data (for p-coords).

  • filename – Output filename.

  • format – Output file format.

three_dim(fronts: List[list], labels: List[str] | None = None, filename: str | None = None, format: str = 'eps')[source]

Plot any arbitrary number of fronts in 3D.

Parameters:
  • fronts – List of fronts (containing solutions).

  • labels – List of fronts title (if any).

  • filename – Output filename.

two_dim(fronts: List[list], labels: List[str] | None = None, filename: str | None = None, format: str = 'eps')[source]

Plot any arbitrary number of fronts in 2D.

Parameters:
  • fronts – List of fronts (containing solutions).

  • labels – List of fronts title (if any).

  • filename – Output filename.

Interactive plots

  • This kind of plots are interactive in such a way that every solution can be manipulated (e.g., actions such as zoom, selecting part of the graph, or clicking in a point to see its objective values are allowed).

    plot_front = InteractivePlot(title='Pareto front approximation')
    plot_front.plot(front, label='NSGAII-ZDT1', filename='NSGAII-ZDT1-interactive')
    

API

class jmetal.lab.visualization.interactive.InteractivePlot(title: str = 'Pareto front approximation', reference_front: List[S] | None = None, reference_point: list | None = None, axis_labels: list | None = None)[source]

Bases: Plot

export_to_div(filename=None, include_plotlyjs: bool = False) str[source]

Export as a div for embedding the graph in an HTML file.

Parameters:
  • filename – Output file name (if desired, default to None).

  • include_plotlyjs – If True, include plot.ly JS script (default to False).

Returns:

Script as string.

export_to_html(filename: str) str[source]

Export the graph to an interactive HTML (solutions can be selected to show some metadata).

Parameters:

filename – Output file name.

Returns:

Script as string.

plot(front, label=None, normalize: bool = False, filename: str | None = None, format: str = 'HTML')[source]

Plot a front of solutions (2D, 3D or parallel coordinates).

Parameters:
  • front – List of solutions.

  • label – Front name.

  • normalize – Normalize the input front between 0 and 1 (for problems with more than 3 objectives).

  • filename – Output filename.

Streaming plots

  • The visualizer observer displays the front in real-time (note it only works for problems with two and three objectives) during the execution of multi-objective algorithms; this can be useful to observe the evolution of the Pareto front approximation:

    from jmetal.util.observer import VisualizerObserver
    
    algorithm.observable.register(observer=VisualizerObserver(reference_front=problem.reference_front))
    

API

class jmetal.lab.visualization.streaming.StreamingPlot(plot_title: str = 'Pareto front approximation', reference_front: List[S] | None = None, reference_point: list | None = None, axis_labels: list | None = None)[source]

Bases: object

create_layout(dimension: int) None[source]
plot(front)[source]
update(front: List[S], reference_point: list | None = None) None[source]

Chord plot

API

jmetal.lab.visualization.chord_plot.chord_diagram(solutions: List[FloatSolution], nbins='auto', ax=None, obj_labels=None, prop_labels={'fontsize': 13, 'ha': 'center', 'va': 'center'}, pad=6)[source]
jmetal.lab.visualization.chord_plot.draw_chord(start_angle1=0, end_angle1=60, start_angle2=180, end_angle2=240, radius=1.0, chord_width=0.7, ax=None, color=(1, 0, 0), z_order=1)[source]
jmetal.lab.visualization.chord_plot.draw_sector(start_angle=0, end_angle=60, radius=1.0, width=0.2, lw=2, ls='-', ax=None, fc=(1, 0, 0), ec=(0, 0, 0), z_order=1)[source]
jmetal.lab.visualization.chord_plot.hover_over_bin(event, handle_tickers, handle_plots, colors, fig)[source]
jmetal.lab.visualization.chord_plot.polar_to_cartesian(r, theta)[source]

Posterior plot

API

jmetal.lab.visualization.posterior.plot_posterior(sample, higher_is_better: bool = False, min_points_per_hexbin: int = 2, alg_names: list | None = None, filename: str = 'posterior.eps')[source]

Plots the sample from posterior distribution of a Bayesian statistical test. Parameters: ———– data: An (n x 3) array or DataFrame contaning the probabilities. alg_names: array of strings. Default np.array([‘Alg1’, ‘Alg2’])

Names of the algorithms under evaluation

Return:

Figure