Esempio n. 1
0
    def train(self, params_list=None):
        self.read_data()

        # debug mode only load part of data, to test whether the whole pipeline works
        if self.debug:
            self.train_X = self.train_X[:1000]
            self.test = self.test[:1000]
            self.train_Y = self.train_Y[:1000]
            self.bayesian_iteration = 1

        if not self.bayesian_optimisation:
            # frid search the best parameter
            params_list = {
                "objective": ["regression"],
                "metric": ["rmse"],
                'boosting': ["gbdt"],
                "num_leaves": [10, 30, 50],
                "min_child_weight": [40, 50, 60],
                "max_depth": [5, 7, 10],
                "learning_rate": [0.01, 0.03, 0.05, 0.06],
                "bagging_fraction": [0.6, 0.7, 0.8],
                "feature_fraction": [0.6, 0.7, 0.8],
                "bagging_frequency": [4, 5, 6],
            }

            super(LGBModel, self).train(params_list)
        else:
            func_param = self.prepare_baysian_optimization()
            xp, yp, param_candidate = bayesian_optimisation(**func_param)
            self.so_far_best_rmse = yp[0]
            for i in range(1, len(param_candidate)):
                if yp[i] < self.so_far_best_rmse:
                    self.so_far_best_rmse = yp[i]
                    self.so_far_best_params = param_candidate[i]
Esempio n. 2
0
    def train(self, params_list=None):
        self.read_data()

        # debug mode only load part of data, to test whether the whole pipeline works
        if self.debug:
            self.train_X = self.train_X[:1000]
            self.test = self.test[:1000]
            self.train_Y = self.train_Y[:1000]
            self.bayesian_iteration = 1

        if not self.bayesian_optimisation:
            # frid search the best parameter
            params_list = {
                "objective": ["regression"],
                "learning_rate" : ["0.02,0.03,0.04,0.05"],
                "depth":[4,5,6,7,8],
                "eval_metric":['RMSE'],
                "bagging_temperature":[0.8,0.9],
                "metric_period":[80,90,100],
                "od_wait":[50,60]
            }

            super(CatBoostModel, self).train(params_list)
        else:
            func_param = self.prepare_baysian_optimization()
            xp, yp, param_candidate = bayesian_optimisation(**func_param)
            self.so_far_best_rmse = yp[0]
            for i in range(1, len(param_candidate)):
                if yp[i] < self.so_far_best_rmse:
                    self.so_far_best_rmse = yp[i]
                    self.so_far_best_params = param_candidate[i]
Esempio n. 3
0
 def train(self, params_list=None):
     if self.debug:
         params = {
             "task": "reg",
             "metric": "rmse",
             "lr": 0.2,
             "lambda": 0.005
         }
         self._train(params)
         return
     if not self.bayesian_optimisation:
         # frid search the best parameter
         params_list = {
             "task": ["reg"],
             "metric": ["rmse"],
             'lr': [0.05, 0.1, 0.15, 0.2, 0.25, 0.3],
             'lambda': [0.002, 0.003, 0.004, 0.005]
         }
         super(FFMModel, self).train(params_list)
     else:
         func_param = self.prepare_baysian_optimization()
         xp, yp, param_candidate = bayesian_optimisation(**func_param)
         self.so_far_best_rmse = yp[0]
         # iterate all the result from bayesian process and choose the best one
         for i in range(1, len(param_candidate)):
             if yp[i] < self.so_far_best_rmse:
                 self.so_far_best_rmse = yp[i]
                 self.so_far_best_params = param_candidate[i]