param_histplot

In some cases it might be interesting to have a look at the values sampled during the racing procedure as a distribution. Such plot shows the areas in the parameter space where crace detected a high performance. A general overview of the distribution of sampled parameters values can be obtained with the param_histplot which generates frequency and density plots for the sampled values of selected parameters.

The plot produced by histplot from model seaborn, and by default, the plot randomly selects 6 parameters from all sampled configurations.

In order to draw more flexible plots for the distribution of selected parameters, you can provide arguments configs, parameters, shownan, stat, density, sharex and sharey. stat is a string from provided values [‘count’, ‘frequency’, ‘probability’, ‘percent’, ‘density’] for the type/shape of plots and its default value is ‘percent’.

To check more details for its available arguments, call:

import craceplot as cplot

help(cplot.param_histplot)
Help on function param_histplot in module craceplot.plots.parameters:

param_histplot(data: 'CraceResults' = None, options: 'CplotOptions' = None, configs: "Union[Literal['all', 'final', 'elites'], list[int], None]" = 'all', parameters: 'Union[list[str], str, None]' = None, slice: 'bool' = False, _console: 'bool' = True, shownan: 'bool' = True, nbins: 'int' = 5, dpi: 'int' = 1600, stat: "Literal['count', 'frequency', 'probability', 'percent', 'density']" = 'percent', density: 'bool' = False, sharex: 'bool' = False, sharey: 'bool' = True)
    Entrance to call histplot 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]
    :param parameters: A list of parameter names selected for plotting, higher priority than option multiParameters.
    :param slice: A boolean value used to enable/disable mapping plot aspects to different slices.
    :param shownan: A boolean value used to plot including/excluding missing values.
    :param stat: A string from provided values for the type/shape of plots. 
                 | Literal['count', 'frequency', 'probability', 'percent', 'density']='percent'
    :param density: A boolean value used to enable/disable plotting the rugplot in addition.
    :param sharex: A boolean value used to enable/disable sharing x axis when plotting.
    :param sharey: A boolean value used to enable/disable sharing y axis when plotting.

Take ACOTSP and CATS200 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())

p = Path(os.path.join(cplot_home, 'inst', 'examples', 'cats200'))
path_to_cats200 = os.path.relpath(p, Path.cwd())

results1, options1 = cplot.run('-l', path_to_acotsp)
results2, options2 = cplot.run('-l', path_to_cats200)
/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...
#---------------------------------------------------------------------------------------------------
# Reading crace plot options...
# Arguments: ['-l', '../../../../../../../../opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/site-packages/craceplot/inst/examples/cats200']
#
# Loading crace plot options...

You can plot with the param_histplot method:

cplot.param_histplot(data=results1, options=options1)
#
# No parameters selected to draw plot, set to the default(random selected 8 parameters).
#    selected parameters: ants, beta, dlb, localsearch, nnls, q0, rasrank, rho
../../_images/2b08226891b35f4140b637e9807f078d4698cf55b1b1f6b51bb40bbc6551577f.png
cplot.param_histplot(data=results2, options=options2,
                     configs='all',
                     parameters='sifting_algorithm',
                     slice=True,
                     stat='count',
                     density=True,)
../../_images/02b92fe031269fed0ee2d04c43916227229564662ba60cc82ba48fd4b54cc484.png