param_heatmap¶
The plot produced by heatmap from model seaborn can help you visualize the joint sampling frequency of two parameters. By default, this plot uses all configuration values on the selected parameters, you can also use argument configs to focus on the selected configurations. You can select two parameters using the parameters argument, or provide only one parameter to visualize its sampling frequency with slice_sampled, that when the configuration sampled.
You can use argument colormap to color the plot, and its available values could be checked using code:
import matplotlib.pyplot as plt
plt.colormaps( )
To check more details for its available arguments, call:
import craceplot as cplot
help(cplot.param_heatmap)
Help on function param_heatmap in module craceplot.plots.parameters:
param_heatmap(data: 'CraceResults' = None, options: 'CplotOptions' = None, configs: "Union[Literal['all', 'final', 'elites'], list[int], None]" = 'all', parameters: 'Union[list[str], str, None]' = None, _console: 'bool' = True, shownan: 'bool' = True, nbins: 'int' = 5, dpi: 'int' = 800, colormap: 'Optional[Union[str, list, Colormap]]' = 'PuBu', fmt: 'str' = 'g')
Entrance to call heatmap in python console
:param data: object CraceResults that must be provided.
:param options: object CplotOptions that must be provided.
:param configs: Optional. Selected configurations for plotting, higher priority than option numConfigurations/selConfigurations.
| Union[Literal['all', 'final', 'elites'], list[int], None]='all'
:param parameters: a list of parameter names selected for plotting, higher priority than option multiParameters.
:param shownan: boolean used to plot including/excluding missing values.
:param colormap: a string of matplotlib colormap name for plotting.
:param nbins: integer used to split the domain for continouos paramters
Take ACOTSP for example:
import os
from pathlib import Path
cplot_home = cplot.where()
p = Path(os.path.join(cplot_home, 'inst', 'examples', 'acotsp'))
path_to_acotsp = os.path.relpath(p, Path.cwd())
results, options = cplot.run('-l', path_to_acotsp)
/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/site-packages/craceplot
#---------------------------------------------------------------------------------------------------
# Reading crace plot options...
# Arguments: ['-l', '../../../../../../../../opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/site-packages/craceplot/inst/examples/acotsp']
#
# Loading crace plot options...
You can plot heatmap with the param_heatmap method:
cplot.param_heatmap(data=results, options=options, parameters='algorithm')
You can draw more flexible heatmap plots via providing parameters configs, parameters, colormap, shownan and nbins. The argument nbins is used to split the domain of continouos paramters.
cplot.param_heatmap(data=results, options=options,
parameters=['q0', 'rasrank'],
shownan=True, colormap='YlGnBu')
#
# Mapping parameter type..
# (WARNING: convert parameter q0(r) to categorical for plotting)
# (WARNING: convert parameter rasrank(i) to categorical for plotting)