tabular_ml_toolkit/tmlt.py
def do_xgb_optuna_optimization(self, X_train_np, y_train_np, X_valid_np, y_valid_np, optuna_db_path:str,
                                   use_gpu=False, opt_trials=100, opt_timeout=360, verbose=False):
        """
            This methods returns and do optuna bases study optimization for hyperparmaeter search
            optuna_db_path is output directory you want to use for storing sql db used for optuna
            use_gpu=False by default, make it True if running on gpu machine
            opt_trials=100 by default, change it based upon need
            opt_timeout=360 by default, timeout value in seconds

        """

        # get params based on problem type
        xgb_model_type, val_preds_metrics, eval_metric, direction, _ = fetch_xgb_params_for_problem_type(self.problem_type)

        # Load the dataset in advance for reusing it each trial execution.
        objective = XGB_Optuna_Objective(X_train_np, y_train_np, X_valid_np, y_valid_np,
                                         val_preds_metrics=val_preds_metrics,
                                         xgb_model_type=xgb_model_type, xgb_eval_metric=eval_metric,
                                         use_gpu=use_gpu, verbose=verbose)
        # create sql db in optuna db path
        db_path = os.path.join(optuna_db_path, "params.db")

        # now create study
        logger.info(f"Optimization Direction is: {direction}")
        study = optuna.create_study(
            direction=direction,
            study_name="tmlt_autoxgb",
            storage=f"sqlite:///{db_path}",
            load_if_exists=True,
        )
        study.optimize(objective, n_trials=opt_trials, timeout=opt_timeout)
        gc.collect()
        return study

            This methods returns and do optuna bases study optimization for hyperparmaeter search
            optuna_db_path is output directory you want to use for storing sql db used for optuna
            use_gpu=False by default, make it True if running on gpu machine
            opt_trials=100 by default, change it based upon need
            opt_timeout=360 by default, timeout value in seconds

        
This methods returns and do optuna bases study optimization for hyperparmaeter search
optuna_db_path is output directory you want to use for storing sql db used for optuna
use_gpu=False by default, make it True if running on gpu machine
opt_trials=100 by default, change it based upon need
opt_timeout=360 by default, timeout value in seconds
This methods returns and do optuna bases study optimization for hyperparmaeter search optuna_db_path is output directory you want to use for storing sql db used for optuna use_gpu = False by default make it True if running on gpu machine opt_trials = 100 by default change it based upon need opt_timeout = 360 by default timeout value in seconds
def do_xgb_optuna_optimization(self, X_train_np, y_train_np, X_valid_np, y_valid_np, optuna_db_path:str,
                                   use_gpu=False, opt_trials=100, opt_timeout=360, verbose=False):
        xgb_model_type, val_preds_metrics, eval_metric, direction, _ = fetch_xgb_params_for_problem_type(self.problem_type)
        objective = XGB_Optuna_Objective(X_train_np, y_train_np, X_valid_np, y_valid_np,
                                         val_preds_metrics=val_preds_metrics,
                                         xgb_model_type=xgb_model_type, xgb_eval_metric=eval_metric,
                                         use_gpu=use_gpu, verbose=verbose)
        db_path = os.path.join(optuna_db_path, "params.db")
        logger.info(f"Optimization Direction is: {direction}")
        study = optuna.create_study(
            direction=direction,
            study_name="tmlt_autoxgb",
            storage=f"sqlite:///{db_path}",
            load_if_exists=True,
        )
        study.optimize(objective, n_trials=opt_trials, timeout=opt_timeout)
        gc.collect()
        return study
def do_xgb_optuna_optimization ( self , X_train_np , y_train_np , X_valid_np , y_valid_np , optuna_db_path : str , use_gpu = False , opt_trials = 100 , opt_timeout = 360 , verbose = False ) : xgb_model_type , val_preds_metrics , eval_metric , direction , _ = fetch_xgb_params_for_problem_type ( self . problem_type ) objective = XGB_Optuna_Objective ( X_train_np , y_train_np , X_valid_np , y_valid_np , val_preds_metrics = val_preds_metrics , xgb_model_type = xgb_model_type , xgb_eval_metric = eval_metric , use_gpu = use_gpu , verbose = verbose ) db_path = os . path . join ( optuna_db_path , "params.db" ) logger . info ( f"Optimization Direction is: {direction}" ) study = optuna . create_study ( direction = direction , study_name = "tmlt_autoxgb" , storage = f"sqlite:///{db_path}" , load_if_exists = True , ) study . optimize ( objective , n_trials = opt_trials , timeout = opt_timeout ) gc . collect ( ) return study
This methods returns and do optuna bases study optimization for hyperparmaeter search
optuna_db_path is output directory you want to use for storing sql db used for optuna
use_gpu=False by default, make it True if running on gpu machine
opt_trials=100 by default, change it based upon need
opt_timeout=360 by default, timeout value in seconds
This methods returns and do optuna bases study optimization for hyperparmaeter search optuna_db_path is output directory you want to use for storing sql db used for optuna use_gpu = False by default make it True if running on gpu machine opt_trials = 100 by default change it based upon need opt_timeout = 360 by default timeout value in seconds
"""
            This methods returns and do optuna bases study optimization for hyperparmaeter search
            optuna_db_path is output directory you want to use for storing sql db used for optuna
            use_gpu=False by default, make it True if running on gpu machine
            opt_trials=100 by default, change it based upon need
            opt_timeout=360 by default, timeout value in seconds

        """ # get params based on problem type # Load the dataset in advance for reusing it each trial execution. # create sql db in optuna db path # now create study
self
X_train_np
y_train_np
X_valid_np
y_valid_np
optuna_db_path
str
use_gpu
opt_trials
opt_timeout
verbose