autointent.nodes.NodeOptimizer#
- class autointent.nodes.NodeOptimizer(node_type, search_space, target_metric, metrics=None)#
Class for optimizing nodes in a computational pipeline.
This class is responsible for optimizing different modules within a node using various search strategies and logging the results.
- Parameters:
- node_type#
- node_info#
- target_metric#
- metrics = None#
- modules_search_spaces#
- fit(context, sampler='brute')#
Performs the optimization process for the node.
- Parameters:
context (autointent.context.Context) – The optimization context containing relevant data.
sampler (autointent.custom_types.SamplerType) – The sampling strategy used for optimization.
- Raises:
AssertionError – If an invalid sampler type is provided.
- Return type:
None
- objective(trial, module_name, search_space, context)#
Defines the objective function for optimization.
- Parameters:
trial (optuna.trial.Trial) – The Optuna trial instance.
module_name (str) – The name of the module being optimized.
search_space (dict[str, ParamSpaceInt | ParamSpaceFloat | list[Any]]) – The parameter search space.
context (autointent.context.Context) – The execution context.
- Returns:
The value of the target metric for the given trial.
- Return type:
- suggest(trial, search_space)#
Suggests parameter values based on the search space.
- Parameters:
trial (optuna.trial.Trial) – The Optuna trial instance.
search_space (dict[str, Any | list[Any]]) – A dictionary defining the parameter search space.
- Returns:
A dictionary containing the suggested parameter values.
- Raises:
TypeError – If an unsupported parameter search space type is encountered.
- Return type:
- get_module_dump_dir(dump_dir, module_name, j_combination)#
Creates and returns the path to the module dump directory.
- Parameters:
dump_dir (pathlib.Path) – The base directory for storing module dumps.
module_name (str) – The name of the module being optimized.
j_combination (int) – The combination index for the parameters.
- Returns:
The path to the module dump directory.
- Return type:
- validate_nodes_with_dataset(dataset, mode)#
Validates nodes against the dataset.
- Parameters:
dataset (autointent.Dataset) – The dataset used for validation.
mode (autointent.custom_types.SearchSpaceValidationMode) – The validation mode (“raise” or “warning”).
- Raises:
ValueError – If validation fails and mode is set to “raise”.
- Return type:
None