Optimization#

class HyperparameterTuning(method_name: str, description: str, plot_settings)[source]#

Bases: MeasureEvaluator

Perform hyperparameter tuning using grid or random search.

This evaluator provides comprehensive hyperparameter optimization capabilities using either grid search or random search methods. It supports visualization of tuning results for 1D, 2D, and multi-dimensionalparameter spaces using line plots, 3D surface plots, and parallel coordinate plots respectively.

Attributes:
namestr

The name of the evaluator, set to ‘hyperparameter_tuning’

primary_colorstr

Primary color for plot elements

secondary_colorstr

Secondary color for plot elements

accent_colorstr

Accent color for plot elements

categorical_columnsList[str]

List of categorical parameter columns for parallel coordinate plots

evaluate(model: BaseEstimator, method: str, X_train: DataFrame, y_train: Series, scorer: str, kf: int, num_rep: int, n_jobs: int, plot_results: bool = False, filename: str = 'hyperparameter_tuning') BaseEstimator[source]#

Perform hyperparameter tuning using grid or random search.

Executes hyperparameter optimization using the specified search method and returns the best model found. Optionally generates performance visualizations for the tuning results.

Parameters:
modelbase.BaseEstimator

The model to be tuned

methodstr

The search method to use (“grid” or “random”)

X_trainpd.DataFrame

The training features

y_trainpd.Series

The training target values

scorerstr

The scoring metric to optimize

kfint

Number of folds for cross-validation

num_repint

Number of repetitions for cross-validation

n_jobsint

Number of parallel jobs to run

plot_resultsbool, optional

Whether to generate performance plots, by default False

filenamestr, optional

Filename for saving plots, by default “hyperparameter_tuning”

Returns:
base.BaseEstimator

The tuned model with optimal hyperparameters