Exemplo n.º 1
0
        def objective(hyperparams):
            model = XGBModel(n_estimators=self.n_est, **self.params, **hyperparams)
            model.fit(X=X_trn, y=y_trn,
                      eval_set=[(X_val, y_val)],
                      eval_metric=self.metric,
                      early_stopping_rounds=self.n_stop,
                      verbose=False)
            score = model.evals_result()['validation_0'][self.metric][model.best_iteration] * self.loss_sign

            return {'loss': score, 'status': STATUS_OK, 'model': model}
Exemplo n.º 2
0
        def objective(hyperparams):
            model = XGBModel(n_estimators=self.n_est,
                             **self.params,
                             **hyperparams)
            model.fit(
                X=X_trn,
                y=y_trn,
                eval_set=[(X_val, y_val)],
                eval_metric=self.metric,
                early_stopping_rounds=self.n_stop,
                verbose=False,
            )
            score = (model.evals_result()["validation_0"][self.metric][
                model.best_iteration] * self.loss_sign)

            return {"loss": score, "status": STATUS_OK, "model": model}