stk.SelectionPlotter
- class stk.SelectionPlotter(filename, selector, x_label='Molecule: InChIKey - Fitness Value', record_label=<function SelectionPlotter.<lambda>>, heat_map_value=<function SelectionPlotter.<lambda>>, heat_map_label='Fitness', order_by=<function SelectionPlotter.<lambda>>)[source]
Bases:
Generic
[T
]Plots which molecule records a
Selector
selects.Examples
Plotting Which Molecule Records Got Selected
import stk # Make a selector. roulette = stk.Roulette(num_batches=10) # Make a population. population = { stk.MoleculeRecord( topology_graph=stk.polymer.Linear( building_blocks=( stk.BuildingBlock( smiles='BrCCBr', functional_groups=[stk.BromoFactory()], ), ), repeating_unit='A', num_repeating_units=2, ), ): i for i in range(100) } # Make a plotter. You do not have to assign it to a variable. stk.SelectionPlotter('roulette_counter', roulette) # Select the molecule records. selected = tuple(roulette.select(population)) # There should now be a file called "roulette_counter_1.png" # which shows a graph of all the selected records. # Select records again. selected2 = tuple(roulette.select(population)) # There should now be a file called "roulette_counter_2.png" # which shows a graph of all the selected molecules. # And so on every time you use "roulette.select()".
- Parameters:
filename (Path | str) – The basename of the files. This means it should not include file extensions.
selector (Selector[T]) – The
Selector
whose selection of molecule records is plotted.x_label (str) – The label use for the x axis.
record_label (Callable[[MoleculeRecord[Any], float], str]) – A function which takes a
MoleculeRecord
and its fitness value and returns a string, which is the label used for theMoleculeRecord
on the plot.heat_map_value (Callable[[MoleculeRecord[Any], float], float]) – A function which takes a
MoleculeRecord
and its fitness value and returns a value. The value is used for coloring the heat map used in the plot.heat_map_label (str) – The label used for the heat map key.
order_by (Callable[[MoleculeRecord[Any], float], float]) – A function which takes a
MoleculeRecord
and its fitness value and returns a value. The value is used to sort the plotted records along the x-axis in descending order.
Methods