'n_estimators': 20000,
    'max_depth': 5,
    'max_delta_step': 5,
    'colsample_bylevel': 0.9,
    'colsample_bytree': 0.95,
    'subsample': 0.8,
    'gamma': 1.5,
    'max_leaves': 10,
    'min_child_weight': 50,
    'reg_alpha': 0.6,  # L1 regularization
    'reg_lambda': 50,  # L2 regularization
    'seed': 42
}

model = ModelLoader(xgb.XGBClassifier, model_params, **xgboost_params)

fit_params = {'early_stopping_rounds': 2500, 'verbose': 1000}
predict_params = {}

results = model.run(data_loader,
                    roc_auc_score,
                    fit_params,
                    predict_params,
                    verbose=True)

if args.save:
    current_file_path = os.path.abspath(__file__)  # to save this .py file
    model.save(data_loader, results, current_file_path, args.preds,
               args.models)
## << Create and train model
Ejemplo n.º 2
0
            "verbosity": 0,
            "seed": 42
        }

    def fit(self, train, cv):
        x_tr, y_tr = train
        x_cv, y_cv = cv
        trn_data = lgb.Dataset(x_tr, label=y_tr)
        val_data = lgb.Dataset(x_cv, label=y_cv)
        evals_result = {}
        self.model = lgb.train(self.lgb_params,
                               trn_data,
                               100000,
                               valid_sets=[trn_data, val_data],
                               early_stopping_rounds=3000,
                               verbose_eval=1000,
                               evals_result=evals_result)

    def predict(self, test):
        return self.model.predict(test)


model = ModelLoader(LightGbmTrainer, model_params)
results = model.run(data_loader, roc_auc_score, {}, {}, verbose=True)

if args.save:
    current_file_path = os.path.abspath(__file__)  # to save this .py file
    model.save(data_loader, results, current_file_path, args.preds,
               args.models)
## << Create and train model