tabular/src/autogluon/tabular/task/tabular_prediction/predictor.py
def fit_weighted_ensemble(self, base_models: list = None, name_suffix='_custom', expand_pareto_frontier=False, time_limits=None):
        """
        Fits new weighted ensemble models to combine predictions of previously-trained models.
        `cache_data` must have been set to `True` during the original training to enable this functionality.

        Parameters
        ----------
        base_models : list, default = None
            List of model names the weighted ensemble can consider as candidates.
            If None, all previously trained models are considered except for weighted ensemble models.
            As an example, to train a weighted ensemble that can only have weights assigned to the models 'model_a' and 'model_b', set `base_models=['model_a', 'model_b']`
        name_suffix : str, default = '_custom'
            Name suffix to add to the name of the newly fitted ensemble model.
            Warning: If the name of a trained model from this function is identical to an existing model, it will overwrite the existing model.
            Ensure that `name_suffix` is unique each time `fit_weighted_ensemble` is called to avoid this.
        expand_pareto_frontier : bool, default = False
            If True, will train N-1 weighted ensemble models instead of 1, where `N=len(base_models)`.
            The final model trained when True is equivalent to the model trained when False.
            These weighted ensemble models will attempt to expand the pareto frontier.
            This will create many different weighted ensembles which have different accuracy/memory/inference-speed trade-offs.
            This is particularly useful when inference speed is an important consideration.
        time_limits : int, default = None
            Time in seconds each weighted ensemble model is allowed to train for. If `expand_pareto_frontier=True`, the `time_limits` value is applied to each model.
            If None, the ensemble models train without time restriction.

        Returns
        -------
        List of newly trained weighted ensemble model names.
        If an exception is encountered while training an ensemble model, that model's name will be absent from the list.
        """
        trainer = self._learner.load_trainer()

        if trainer.bagged_mode:
            X = trainer.load_X_train()
            y = trainer.load_y_train()
            fit = True
        else:
            X = trainer.load_X_val()
            y = trainer.load_y_val()
            fit = False

        stack_name = 'aux1'
        if base_models is None:
            base_models = trainer.get_model_names(stack_name='core')

        X_train_stack_preds = trainer.get_inputs_to_stacker(X=X, base_models=base_models, fit=fit, use_orig_features=False)

        models = []

        if expand_pareto_frontier:
            leaderboard = self.leaderboard(silent=True)
            leaderboard = leaderboard[leaderboard['model'].isin(base_models)]
            leaderboard = leaderboard.sort_values(by='pred_time_val')
            models_to_check = leaderboard['model'].tolist()
            for i in range(1, len(models_to_check) - 1):
                models_to_check_now = models_to_check[:i+1]
                max_base_model_level = max([trainer.get_model_level(base_model) for base_model in models_to_check_now])
                weighted_ensemble_level = max_base_model_level + 1
                models += trainer.generate_weighted_ensemble(X=X_train_stack_preds, y=y, level=weighted_ensemble_level, stack_name=stack_name, base_model_names=models_to_check_now, name_suffix=name_suffix + '_pareto' + str(i), time_limit=time_limits)

        max_base_model_level = max([trainer.get_model_level(base_model) for base_model in base_models])
        weighted_ensemble_level = max_base_model_level + 1
        models += trainer.generate_weighted_ensemble(X=X_train_stack_preds, y=y, level=weighted_ensemble_level, stack_name=stack_name, base_model_names=base_models, name_suffix=name_suffix, time_limit=time_limits)

        return models

        Fits new weighted ensemble models to combine predictions of previously-trained models.
        `cache_data` must have been set to `True` during the original training to enable this functionality.

        Parameters
        ----------
        base_models : list, default = None
            List of model names the weighted ensemble can consider as candidates.
            If None, all previously trained models are considered except for weighted ensemble models.
            As an example, to train a weighted ensemble that can only have weights assigned to the models 'model_a' and 'model_b', set `base_models=['model_a', 'model_b']`
        name_suffix : str, default = '_custom'
            Name suffix to add to the name of the newly fitted ensemble model.
            Warning: If the name of a trained model from this function is identical to an existing model, it will overwrite the existing model.
            Ensure that `name_suffix` is unique each time `fit_weighted_ensemble` is called to avoid this.
        expand_pareto_frontier : bool, default = False
            If True, will train N-1 weighted ensemble models instead of 1, where `N=len(base_models)`.
            The final model trained when True is equivalent to the model trained when False.
            These weighted ensemble models will attempt to expand the pareto frontier.
            This will create many different weighted ensembles which have different accuracy/memory/inference-speed trade-offs.
            This is particularly useful when inference speed is an important consideration.
        time_limits : int, default = None
            Time in seconds each weighted ensemble model is allowed to train for. If `expand_pareto_frontier=True`, the `time_limits` value is applied to each model.
            If None, the ensemble models train without time restriction.

        Returns
        -------
        List of newly trained weighted ensemble model names.
        If an exception is encountered while training an ensemble model, that model's name will be absent from the list.
        
Fits new weighted ensemble models to combine predictions of previously-trained models.
`cache_data` must have been set to `True` during the original training to enable this functionality.

Parameters

base_models : list, default = None
List of model names the weighted ensemble can consider as candidates.
If None, all previously trained models are considered except for weighted ensemble models.

Returns

List of newly trained weighted ensemble model names.
If an exception is encountered while training an ensemble model, that model's name will be absent from the list.
Fits new weighted ensemble models to combine predictions of previously - trained models . ` cache_data ` must have been set to ` True ` during the original training to enable this functionality . Parameters base_models : list default = None List of model names the weighted ensemble can consider as candidates . If None all previously trained models are considered except for weighted ensemble models . Returns List of newly trained weighted ensemble model names . If an exception is encountered while training an ensemble model that model ' s name will be absent from the list .
def fit_weighted_ensemble(self, base_models: list = None, name_suffix='_custom', expand_pareto_frontier=False, time_limits=None):
        trainer = self._learner.load_trainer()
        if trainer.bagged_mode:
            X = trainer.load_X_train()
            y = trainer.load_y_train()
            fit = True
        else:
            X = trainer.load_X_val()
            y = trainer.load_y_val()
            fit = False
        stack_name = 'aux1'
        if base_models is None:
            base_models = trainer.get_model_names(stack_name='core')
        X_train_stack_preds = trainer.get_inputs_to_stacker(X=X, base_models=base_models, fit=fit, use_orig_features=False)
        models = []
        if expand_pareto_frontier:
            leaderboard = self.leaderboard(silent=True)
            leaderboard = leaderboard[leaderboard['model'].isin(base_models)]
            leaderboard = leaderboard.sort_values(by='pred_time_val')
            models_to_check = leaderboard['model'].tolist()
            for i in range(1, len(models_to_check) - 1):
                models_to_check_now = models_to_check[:i+1]
                max_base_model_level = max([trainer.get_model_level(base_model) for base_model in models_to_check_now])
                weighted_ensemble_level = max_base_model_level + 1
                models += trainer.generate_weighted_ensemble(X=X_train_stack_preds, y=y, level=weighted_ensemble_level, stack_name=stack_name, base_model_names=models_to_check_now, name_suffix=name_suffix + '_pareto' + str(i), time_limit=time_limits)
        max_base_model_level = max([trainer.get_model_level(base_model) for base_model in base_models])
        weighted_ensemble_level = max_base_model_level + 1
        models += trainer.generate_weighted_ensemble(X=X_train_stack_preds, y=y, level=weighted_ensemble_level, stack_name=stack_name, base_model_names=base_models, name_suffix=name_suffix, time_limit=time_limits)
        return models
def fit_weighted_ensemble ( self , base_models : list = None , name_suffix = '_custom' , expand_pareto_frontier = False , time_limits = None ) : trainer = self . _learner . load_trainer ( ) if trainer . bagged_mode : X = trainer . load_X_train ( ) y = trainer . load_y_train ( ) fit = True else : X = trainer . load_X_val ( ) y = trainer . load_y_val ( ) fit = False stack_name = 'aux1' if base_models is None : base_models = trainer . get_model_names ( stack_name = 'core' ) X_train_stack_preds = trainer . get_inputs_to_stacker ( X = X , base_models = base_models , fit = fit , use_orig_features = False ) models = [ ] if expand_pareto_frontier : leaderboard = self . leaderboard ( silent = True ) leaderboard = leaderboard [ leaderboard [ 'model' ] . isin ( base_models ) ] leaderboard = leaderboard . sort_values ( by = 'pred_time_val' ) models_to_check = leaderboard [ 'model' ] . tolist ( ) for i in range ( 1 , len ( models_to_check ) - 1 ) : models_to_check_now = models_to_check [ : i + 1 ] max_base_model_level = max ( [ trainer . get_model_level ( base_model ) for base_model in models_to_check_now ] ) weighted_ensemble_level = max_base_model_level + 1 models += trainer . generate_weighted_ensemble ( X = X_train_stack_preds , y = y , level = weighted_ensemble_level , stack_name = stack_name , base_model_names = models_to_check_now , name_suffix = name_suffix + '_pareto' + str ( i ) , time_limit = time_limits ) max_base_model_level = max ( [ trainer . get_model_level ( base_model ) for base_model in base_models ] ) weighted_ensemble_level = max_base_model_level + 1 models += trainer . generate_weighted_ensemble ( X = X_train_stack_preds , y = y , level = weighted_ensemble_level , stack_name = stack_name , base_model_names = base_models , name_suffix = name_suffix , time_limit = time_limits ) return models
Fits new weighted ensemble models to combine predictions of previously-trained models.
Fits new weighted ensemble models to combine predictions of previously - trained models .
"""
        Fits new weighted ensemble models to combine predictions of previously-trained models.
        `cache_data` must have been set to `True` during the original training to enable this functionality.

        Parameters
        ----------
        base_models : list, default = None
            List of model names the weighted ensemble can consider as candidates.
            If None, all previously trained models are considered except for weighted ensemble models.
            As an example, to train a weighted ensemble that can only have weights assigned to the models 'model_a' and 'model_b', set `base_models=['model_a', 'model_b']`
        name_suffix : str, default = '_custom'
            Name suffix to add to the name of the newly fitted ensemble model.
            Warning: If the name of a trained model from this function is identical to an existing model, it will overwrite the existing model.
            Ensure that `name_suffix` is unique each time `fit_weighted_ensemble` is called to avoid this.
        expand_pareto_frontier : bool, default = False
            If True, will train N-1 weighted ensemble models instead of 1, where `N=len(base_models)`.
            The final model trained when True is equivalent to the model trained when False.
            These weighted ensemble models will attempt to expand the pareto frontier.
            This will create many different weighted ensembles which have different accuracy/memory/inference-speed trade-offs.
            This is particularly useful when inference speed is an important consideration.
        time_limits : int, default = None
            Time in seconds each weighted ensemble model is allowed to train for. If `expand_pareto_frontier=True`, the `time_limits` value is applied to each model.
            If None, the ensemble models train without time restriction.

        Returns
        -------
        List of newly trained weighted ensemble model names.
        If an exception is encountered while training an ensemble model, that model's name will be absent from the list.
        """
self
base_models
list
name_suffix
expand_pareto_frontier
time_limits