The jmetal.lab.visualization
submodule contains several classes useful for plotting solutions. jMetalPy includes three types of visualization charts: static, interactive and streaming.
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')
jmetal.lab.visualization.plotting.
Plot
(title: str = 'Pareto front approximation', reference_front: List[S] = None, reference_point: list = None, axis_labels: list = None)[source]¶Bases: object
get_points
(solutions: List[S]) → Tuple[pandas.core.frame.DataFrame, int][source]¶Get points for each solution of the front.
solutions – List of solutions.
Pandas dataframe with one column for each objective and one row for each solution.
pcoords
(fronts: List[list], normalize: bool = False, filename: str = None, format: str = 'eps')[source]¶Plot any arbitrary number of fronts in parallel coordinates.
fronts – List of fronts (containing solutions).
filename – Output filename.
plot
(front, label='', normalize: bool = False, filename: str = None, format: str = 'eps')[source]¶Plot any arbitrary number of fronts in 2D, 3D or p-coords.
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.
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')
jmetal.lab.visualization.interactive.
InteractivePlot
(title: str = 'Pareto front approximation', reference_front: List[S] = None, reference_point: list = None, axis_labels: list = None)[source]¶Bases: jmetal.lab.visualization.plotting.Plot
export_to_div
(filename=None, include_plotlyjs: bool = False) → str[source]¶Export as a div for embedding the graph in an HTML file.
filename – Output file name (if desired, default to None).
include_plotlyjs – If True, include plot.ly JS script (default to False).
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).
filename – Output file name.
Script as string.
plot
(front, label=None, normalize: bool = False, filename: str = None, format: str = 'HTML')[source]¶Plot a front of solutions (2D, 3D or parallel coordinates).
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.
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))
jmetal.lab.visualization.chord_plot.
chord_diagram
(solutions: List[jmetal.core.solution.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.posterior.
plot_posterior
(sample, higher_is_better: bool = False, min_points_per_hexbin: int = 2, alg_names: list = 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
Figure