panther.tuner.SkAutoTuner.Searching package#
Submodules#
panther.tuner.SkAutoTuner.Searching.GridSearch module#
- class panther.tuner.SkAutoTuner.Searching.GridSearch.GridSearch(max_iterations=10)[source]#
Bases:
SearchAlgorithmGrid search algorithm that systematically tries all combinations of parameters up to a maximum number of iterations.
This implementation performs a search through a pre-generated grid of parameter combinations. It iterates through these combinations and keeps track of the best parameters found and their corresponding score.
- max_iterations#
The maximum number of parameter combinations to try.
- param_space#
Dictionary mapping parameter names to lists of their possible values.
- indexed_param_space#
A list of dictionaries, where each dictionary represents a unique combination of parameter values.
- curr_iteration#
The current iteration number, indicating which parameter combination is being evaluated or will be evaluated next.
- best_score#
The highest score achieved so far during the search.
- best_params#
The dictionary of parameters that achieved the best_score.
- __init__(max_iterations=10)[source]#
Initialize the GridSearch algorithm.
- Parameters:
max_iterations – The maximum number of iterations to run.
- property current_idx#
Alias for curr_iteration for backward compatibility.
- property param_combinations#
Alias for indexed_param_space for backward compatibility.
- initialize(param_space)[source]#
Initialize the search algorithm with the parameter space.
- Parameters:
param_space – Dictionary of parameter names and their possible values
- get_next_params()[source]#
Get the next set of parameters to try.
- Returns:
Dictionary of parameter names and values to try, or None if finished
- update(params, score)[source]#
Update the search algorithm with the results of the latest trial.
- Parameters:
params – Dictionary of parameter names and values that were tried
score – The evaluation score for the parameters
- save_state(filepath)[source]#
Save the current state of the search algorithm to a file.
- Parameters:
filepath – The path to the file where the state should be saved.
- load_state(filepath)[source]#
Load the state of the search algorithm from a file.
- Parameters:
filepath – The path to the file from which the state should be loaded.
- get_best_params()[source]#
Get the best set of parameters found so far.
- Returns:
Dictionary of the best parameter names and values, or None if no params yet.
- get_best_score()[source]#
Get the best score achieved so far.
- Returns:
The best score, or None if no score yet.
panther.tuner.SkAutoTuner.Searching.OptunaSearch module#
panther.tuner.SkAutoTuner.Searching.SearchAlgorithm module#
- class panther.tuner.SkAutoTuner.Searching.SearchAlgorithm.SearchAlgorithm[source]#
Bases:
ABCAbstract base class for search algorithms to use in autotuning.
- abstractmethod initialize(param_space)[source]#
Initialize the search algorithm with the parameter space.
- Parameters:
param_space – Dictionary of parameter names and their possible values. Values can be lists (legacy) or ParamSpec types (Categorical, Int, Float).
- abstractmethod get_next_params()[source]#
Get the next set of parameters to try.
- Returns:
Dictionary of parameter names and values to try, or None if finished
- abstractmethod update(params, score)[source]#
Update the search algorithm with the results of the latest trial.
- Parameters:
params – Dictionary of parameter names and values that were tried
score – The evaluation score for the parameters
- abstractmethod save_state(filepath)[source]#
Save the current state of the search algorithm to a file.
- Parameters:
filepath – The path to the file where the state should be saved.
- abstractmethod load_state(filepath)[source]#
Load the state of the search algorithm from a file.
- Parameters:
filepath – The path to the file from which the state should be loaded.
- abstractmethod get_best_params()[source]#
Get the best set of parameters found so far.
- Returns:
Dictionary of the best parameter names and values, or None if no params yet.