Optimizers¶
-
class
hana_automl.optimizers.base_optimizer.BaseOptimizer¶ Base optimizer class. Inherit from it to create custom optimizers.
-
abstract
get_algorithm()¶ Return tuned AutoML algorithm
-
abstract
get_model()¶ Return tuned HANA PAL model
-
abstract
get_preprocessor_settings()¶ Return a
PreprocessorSettings()object with preprocessor settings
-
abstract
get_tuned_params()¶ Return hyperparameters that your optimizer has tuned
-
abstract
objective()¶ Implement the objective function here. It must take hyperparameters to be tuned in optimizer
-
abstract
tune()¶ Tune hyperparameters here
-
abstract
-
class
hana_automl.optimizers.bayes.BayesianOptimizer(algo_list: list, data, iterations: int, time_limit: int, problem: str, categorical_features: Optional[list] = None, verbose=2, tuning_metric: Optional[str] = None)¶ Bayesian hyperparameters optimizer. (https://github.com/fmfn/BayesianOptimization)
-
algo_list¶ List of algorithms to be tuned and compared.
- Type
list
-
iter¶ Number of iterations.
- Type
int
-
problem¶ Machine learning problem. Currently supported: ‘cls’, ‘reg’
- Type
str
-
tuned_params¶ Final tuned hyperparameters of best algorithm.
- Type
str
-
algo_index¶ Index of algorithm in algorithms list.
- Type
int
-
time_limit¶ Time in seconds.
- Type
int
-
categorical_features¶ List of categorical features in dataframe.
- Type
list
-
inner_data¶ Copy of Data object to prevent from preprocessing data object multiple times while optimizing.
- Type
-
prepset¶ Imputer for preprocessing
-
model¶ Tuned HANA ML model in algorithm.
-
child_objective(**hyperparameters) → float¶ Mini objective function. It is used to tune hyperparameters of algorithm that was chosen in main objective.
- Parameters
**hyperparameters – Parameters of algorithm’s model.
- Returns
score – Tuning metric score of a model.
- Return type
float
-
fit(algo, data)¶ Fits given model from data. Small method to reduce code repeating.
-
get_algorithm()¶ Returns tuned AutoML algorithm
-
get_model()¶ Returns tuned model.
-
get_preprocessor_settings() → hana_automl.preprocess.settings.PreprocessorSettings¶ Returns tuned preprocessor settings.
-
get_tuned_params() → dict¶ Returns tuned hyperparameters.
-
objective(algo_index_tuned: int, num_strategy_method: int, normalizer_strategy: int, z_score_method: int, normalize_int: int, drop_outers: int)¶ Main objective function. Optimizer uses it to search for best algorithm and preprocess method.
- Parameters
algo_index_tuned (int) – Index of algorithm in algo_list.
num_strategy_method (int) – Strategy to decode categorical variables.
normalizer_strategy (int) – Strategy for normalization
z_score_method (int) – A z-score (also called a standard score) gives you an idea of how far from the mean a data point is
normalize_int (int) – How to normalize integers
- Returns
Optimal hyperparameters.
- Return type
Best params
Note
Total number of child objective iterations is n_iter + init_points!
-
tune()¶ Starts hyperparameter searching.
-
-
class
hana_automl.optimizers.optuna_optimizer.OptunaOptimizer(algo_list: list, data, problem: str, iterations: int, time_limit: int, algo_dict: dict, categorical_features: Optional[list] = None, droplist_columns: Optional[list] = None, verbose=2, tuning_metric: Optional[str] = None)¶ Optuna hyperparameters optimizer. (https://optuna.org/)
-
algo_list¶ List of algorithms to be tuned and compared.
- Type
list
-
algo_dict¶ Dictionary of algorithms to be tuned and compared.
- Type
dict
-
iter¶ Number of iterations.
- Type
int
-
problem¶ Machine learning problem.
- Type
str
-
tuned_params¶ Final tuned hyperparameters of best algorithm.
- Type
str
-
categorical_features¶ List of categorical features in dataframe.
- Type
list
-
prepset¶ prepset for preprocessing.
-
model¶ Tuned HANA ML model in algorithm.
-
droplist_columns¶ Columns in dataframe to be dropped.
-
fit(algo, data)¶ Fits given model from data. Small method to reduce code repeating.
-
get_algorithm()¶ Returns tuned AutoML algorithm
-
get_model()¶ Returns tuned model.
-
get_preprocessor_settings() → hana_automl.preprocess.settings.PreprocessorSettings¶ Returns tuned preprocessor settings.
-
get_tuned_params() → dict¶ Returns tuned hyperparameters.
-
objective(trial: optuna.trial._trial.Trial) → int¶ Objective function. Optimizer uses it to search for best algorithm and preprocess method.
- Parameters
trial (optuna.trial.Trial) – Optuna trial. Details here: https://optuna.readthedocs.io/en/stable/reference/trial.html
- Returns
acc – Model’s accuracy.
- Return type
float
-
tune()¶ Tune hyperparameters here
-