ml_grid.pipeline.main ===================== .. py:module:: ml_grid.pipeline.main Classes ------- .. autoapisummary:: ml_grid.pipeline.main.run Module Contents --------------- .. py:class:: run(ml_grid_object: ml_grid.pipeline.data.pipe, local_param_dict: Dict[str, Any]) Initializes the run class. This class takes the main data pipeline object and a dictionary of local parameters to set up and prepare for executing a series of hyperparameter searches across multiple machine learning models. :param ml_grid_object: The main data pipeline object, which contains the data (X_train, y_train, etc.) and a list of model classes to be evaluated. :type ml_grid_object: pipe :param local_param_dict: A dictionary of parameters for the current experimental run, such as `param_space_size`. :type local_param_dict: Dict[str, Any] .. py:attribute:: global_params :type: ml_grid.util.global_params.global_parameters A reference to the global parameters singleton instance. .. py:attribute:: verbose :type: int The verbosity level for logging, inherited from global parameters. .. py:attribute:: error_raise :type: bool A flag to control error handling. If True, exceptions will be raised. .. py:attribute:: ml_grid_object :type: ml_grid.pipeline.data.pipe The main data pipeline object, containing data and model configurations. .. py:attribute:: sub_sample_param_space_pct :type: float The percentage of the parameter space to sample in a randomized search. .. py:attribute:: parameter_space_size :type: str The size of the parameter space for base learners (e.g., 'medium', 'xsmall'). .. py:attribute:: model_class_list :type: List[Any] A list of instantiated model class objects to be evaluated in this run. .. py:attribute:: pg_list :type: List[int] A list containing the calculated size of the parameter grid for each model. .. py:attribute:: mean_parameter_space_val :type: float The mean size of the parameter spaces across all models in the run. .. py:attribute:: sub_sample_parameter_val :type: int The calculated number of iterations for randomized search, based on `sub_sample_param_space_pct`. .. py:attribute:: arg_list :type: List[Tuple] A list of argument tuples, one for each model, to be passed to the grid search function. .. py:attribute:: multiprocess :type: bool A flag to enable or disable multiprocessing for running grid searches in parallel. .. py:attribute:: local_param_dict :type: Dict[str, Any] A dictionary of parameters for the current experimental run. .. py:attribute:: model_error_list :type: List[List[Any]] A list to store details of any errors encountered during model training. .. py:attribute:: highest_score :type: float The highest score achieved across all successful model runs in the execute step. .. py:method:: execute() -> Tuple[List[List[Any]], float] Executes the grid search for each model in the list. This method iterates through the list of configured models and their parameter spaces, running a cross-validated grid search for each one. It captures any errors that occur during the process and returns a list of those errors along with the highest score achieved. :returns: A tuple containing: - A list of model errors, where each error is a list containing the algorithm instance, the exception, and the traceback. - The highest score achieved across all successful model runs. :rtype: Tuple[List[List[Any]], float]