|
|
|
@ -502,11 +502,11 @@ def dataSetSelection(): |
|
|
|
|
|
|
|
|
|
def create_global_function(): |
|
|
|
|
global estimator |
|
|
|
|
def estimator(n_estimators, eta, max_depth): |
|
|
|
|
def estimator(n_estimators, eta, max_depth, subsample, colsample_bytree): |
|
|
|
|
# initialize model |
|
|
|
|
n_estimators = int(n_estimators) |
|
|
|
|
max_depth = int(max_depth) |
|
|
|
|
model = XGBClassifier(n_estimators=n_estimators, eta=eta, max_depth=max_depth, n_jobs=-1, random_state=RANDOM_SEED, silent=True, verbosity = 0, use_label_encoder=False) |
|
|
|
|
model = XGBClassifier(n_estimators=n_estimators, eta=eta, max_depth=max_depth, subsample=subsample, colsample_bytree=colsample_bytree, n_jobs=-1, random_state=RANDOM_SEED, silent=True, verbosity = 0, use_label_encoder=False) |
|
|
|
|
# set in cross-validation |
|
|
|
|
result = cross_validate(model, XData, yData, cv=crossValidation, scoring='accuracy') |
|
|
|
|
# result is mean of test_score |
|
|
|
@ -568,11 +568,11 @@ def executeModel(exeCall, flagEx, nodeTransfName): |
|
|
|
|
# Bayesian Optimization CHANGE INIT_POINTS! |
|
|
|
|
if (keyFirstTime): |
|
|
|
|
create_global_function() |
|
|
|
|
params = {"n_estimators": (5, 200), "eta": (0.05, 0.3), "max_depth": (6,12)} |
|
|
|
|
params = {"n_estimators": (5, 200), "eta": (0.05, 0.3), "max_depth": (6,12), "subsample": (0.8,1), "colsample_bytree": (0.8,1)} |
|
|
|
|
bayesopt = BayesianOptimization(estimator, params, random_state=RANDOM_SEED) |
|
|
|
|
bayesopt.maximize(init_points=10, n_iter=5, acq='ucb') # 35 and 15 |
|
|
|
|
bayesopt.maximize(init_points=35, n_iter=15, acq='ucb') # 35 and 15 |
|
|
|
|
bestParams = bayesopt.max['params'] |
|
|
|
|
estimator = XGBClassifier(n_estimators=int(bestParams.get('n_estimators')), eta=bestParams.get('eta'), max_depth=int(bestParams.get('max_depth')), probability=True, random_state=RANDOM_SEED, silent=True, verbosity = 0, use_label_encoder=False) |
|
|
|
|
estimator = XGBClassifier(n_estimators=int(bestParams.get('n_estimators')), eta=bestParams.get('eta'), max_depth=int(bestParams.get('max_depth')), subsample=bestParams.get('subsample'), colsample_bytree=bestParams.get('colsample_bytree'), probability=True, random_state=RANDOM_SEED, silent=True, verbosity = 0, use_label_encoder=False) |
|
|
|
|
columnsNewGen = OrignList |
|
|
|
|
|
|
|
|
|
if (len(exeCall) != 0): |
|
|
|
|