8.2.2. The Bayesian Extension and utilities
Summary of the main classes for the Bayesian Optimization extension
|
PyMoDAQ extension of the DashBoard to perform the optimization of a target signal taken form the detectors as a function of one or more parameters controlled by the actuators. |
|
Methods |
|
Methods |
8.2.2.1. The Extension module
- class pymodaq.extensions.BayesianOptimisation(dockarea, dashboard)[source]
PyMoDAQ extension of the DashBoard to perform the optimization of a target signal taken form the detectors as a function of one or more parameters controlled by the actuators.
- Attributes
modules_manager
useful tool to interact with DAQ_Moves and DAQ_Viewers
Methods
Connect actions and/or other widgets signal to methods
Method where to create actions to be subclassed.
to be subclassed to setup the docks layout for instance:
to be subclassed create menu for actions contained into the self.actions_manager, for instance:
value_changed
(param)to be subclassed for actions to perform when one of the param's value in self.settings is changed
clean_h5_temp
command_runner
enable_controls_opti
format_bounds
get_set_model_params
get_stopping_parameters
go_to_best
ini_live_plot
ini_model
ini_optimisation_runner
ini_temp_file
optimisation_done
optimisation_done_signal
process_output
quit
run_optimisation
set_algorithm
set_model
update_actuators
update_bounds
update_data_plot
update_stopping_criteria
update_utility_function
- setup_actions()[source]
Method where to create actions to be subclassed. Mandatory
Examples
>>> self.add_action('Quit', 'close2', "Quit program") >>> self.add_action('Grab', 'camera', "Grab from camera", checkable=True) >>> self.add_action('Load', 'Open', "Load target file (.h5, .png, .jpg) or data from camera", checkable=False) >>> self.add_action('Save', 'SaveAs', "Save current data", checkable=False)
See also
ActionManager.add_action
- setup_docks()[source]
to be subclassed to setup the docks layout for instance:
self.docks[‘ADock’] = gutils.Dock(‘ADock name) self.dockarea.addDock(self.docks[‘ADock”]) self.docks[‘AnotherDock’] = gutils.Dock(‘AnotherDock name) self.dockarea.addDock(self.docks[‘AnotherDock”], ‘bottom’, self.docks[‘ADock”])
See also
pyqtgraph.dockarea.Dock
to be subclassed create menu for actions contained into the self.actions_manager, for instance:
For instance:
file_menu = self.menubar.addMenu(‘File’) self.actions_manager.affect_to(‘load’, file_menu) self.actions_manager.affect_to(‘save’, file_menu)
file_menu.addSeparator() self.actions_manager.affect_to(‘quit’, file_menu)
- value_changed(param)[source]
to be subclassed for actions to perform when one of the param’s value in self.settings is changed
For instance: if param.name() == ‘do_something’:
- if param.value():
print(‘Do something’) self.settings.child(‘main_settings’, ‘something_done’).setValue(False)
- Parameters
param ((Parameter) the parameter whose value just changed) –
- property modules_manager: ModulesManager
useful tool to interact with DAQ_Moves and DAQ_Viewers
Will be available if a DashBoard has been set
- Return type
8.2.2.2. The Base Models
- class pymodaq.extensions.BayesianModelGeneric(optimisation_controller: BayesianOptimisation)[source]
Methods
convert_input
(measurements)Convert the measurements in the units to be fed to the Optimisation Controller :param measurements: data object exported from the detectors from which the model extract a float value (fitness) to be fed to the algorithm :type measurements: DataToExport
convert_output
(outputs[, best_individual])Convert the output of the Optimisation Controller in units to be fed into the actuators :param outputs: output value from the controller from which the model extract a value of the same units as the actuators :type outputs: list of numpy ndarray :param best_individual: the coordinates of the best individual so far :type best_individual: np.ndarray
To be subclassed
To be subclassed
Called when updating the live plots
update_settings
(param)Get a parameter instance whose value has been modified by a user on the UI To be overwritten in child class
check_modules
ini_model_base
optimisation_algorithm
update_detector_names
- convert_input(measurements: DataToExport) float [source]
Convert the measurements in the units to be fed to the Optimisation Controller :param measurements: data object exported from the detectors from which the model extract a float value
(fitness) to be fed to the algorithm
- Return type
- convert_output(outputs: List[ndarray], best_individual=None) DataToActuators [source]
Convert the output of the Optimisation Controller in units to be fed into the actuators :param outputs: output value from the controller from which the model extract a value of the same units as the actuators :type outputs: list of numpy ndarray :param best_individual: the coordinates of the best individual so far :type best_individual: np.ndarray
- Returns
DataToActuatorOpti – attribute, either ‘rel’ for relative or ‘abs’ for absolute.
- Return type
derived from DataToExport. Contains value to be fed to the actuators with a a mode
- class pymodaq.extensions.BayesianModelDefault(optimisation_controller: BayesianOptimisation)[source]
Methods
convert_input
(measurements)Convert the measurements in the units to be fed to the Optimisation Controller
convert_output
(outputs[, best_individual])Convert the output of the Optimisation Controller in units to be fed into the actuators :param outputs: output value from the controller from which the model extract a value of the same units as the actuators :type outputs: list of numpy ndarray :param best_individual: the coordinates of the best individual so far :type best_individual: np.ndarray
To be subclassed
update_settings
(param)Get a parameter instance whose value has been modified by a user on the UI To be overwritten in child class
optimize_from
- convert_input(measurements: DataToExport) float [source]
Convert the measurements in the units to be fed to the Optimisation Controller
- Parameters
measurements (DataToExport) – data object exported from the detectors from which the model extract a float value (fitness) to be fed to the algorithm
- Return type
- convert_output(outputs: List[ndarray], best_individual=None) DataToActuators [source]
Convert the output of the Optimisation Controller in units to be fed into the actuators :param outputs: output value from the controller from which the model extract a value of the same units as the actuators :type outputs: list of numpy ndarray :param best_individual: the coordinates of the best individual so far :type best_individual: np.ndarray
- Returns
DataToActuators (derived from DataToExport. Contains value to be fed to the actuators)
with a mode attribute, either ‘rel’ for relative or ‘abs’ for absolute.