def tune_dartr(): name = 'DartrGBM' dimension = 'length' stage, dart_reg, scale, features, dartr_checkpoint_score = stage_meta_init(meta_dimension, name, dimension) if stage == 0: dart_reg = lgb.LGBMRegressor(random_state = 1108, n_estimators = 100, subsample = .8, verbose=-1) dartr_checkpoint_score = -np.inf scale, dartr_checkpoint_score = test_scaler(dart_reg, X, Y) _save_meta_model(meta_dimension, stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, list(X), final = False) elif stage == 1: dartr_checkpoint_score, features = feat_selection(X[features], Y, scale, dart_reg, dartr_checkpoint_score, 24, -1, False) _save_meta_model(meta_dimension, stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final = False) elif stage == 2: scale, dartr_checkpoint_score = test_scaler(dart_reg, X[features], Y) _save_meta_model(meta_dimension, stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final = False) elif stage == 3: dart_reg, dartr_checkpoint_score = lgb_find_lr(dart_reg, X[features], Y, scale, dartr_checkpoint_score) _save_meta_model(meta_dimension, stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final = False) elif stage == 4: scale, dartr_checkpoint_score = test_scaler(dart_reg, X[features], Y) _save_meta_model(meta_dimension, stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final = False) elif stage == 5: dartr_checkpoint_score, features = feat_selection(X[features], Y, scale, dart_reg, dartr_checkpoint_score, 24, -1, False) _save_meta_model(meta_dimension, stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final = False) elif stage == 6: dart_reg, dartr_checkpoint_score = lgb_tree_params(X[features], Y, dart_reg, scale, dartr_checkpoint_score, iter_ = 1000) _save_meta_model(meta_dimension, stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final = False) elif stage == 7: scale, dartr_checkpoint_score = test_scaler(dart_reg, X[features], Y) _save_meta_model(meta_dimension, stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final = False) elif stage == 8: dartr_checkpoint_score, features = feat_selection(X[features], Y, scale, dart_reg, dartr_checkpoint_score, 24, -1, False) _save_meta_model(meta_dimension, stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final = False) elif stage == 9: dart_reg, dartr_checkpoint_score = lgb_drop_lr(dart_reg, X[features], Y, scale, dartr_checkpoint_score) _save_meta_model(meta_dimension, stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final = True)
def tune_dartr(): name = 'DartrGBM' dimension = 'length' stage, dart_reg, scale, features, dartr_checkpoint_score = stage_init( name, dimension) if stage == 0: # import time # start = time.time() dart_reg = lgb.LGBMRegressor(random_state=1108, n_estimators=100, subsample=.8, verbose=-1) dartr_checkpoint_score = -np.inf scale, dartr_checkpoint_score = test_scaler(dart_reg, X, Y) # done = time.time() # done - start #ubuntu #sinlge: 50.78195834159851 #multi: 64.57199811935425 _save_model(stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, list(X), final=False) elif stage == 1: dartr_checkpoint_score, features = feat_selection_2( X[features], Y, scale, dart_reg, dartr_checkpoint_score) _save_model(stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final=False) elif stage == 2: scale, dartr_checkpoint_score = test_scaler(dart_reg, X[features], Y) _save_model(stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final=False) elif stage == 3: dart_reg, dartr_checkpoint_score = lgb_find_lr(dart_reg, X[features], Y, scale, dartr_checkpoint_score) _save_model(stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final=False) elif stage == 4: scale, dartr_checkpoint_score = test_scaler(dart_reg, X[features], Y) _save_model(stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final=False) elif stage == 5: dartr_checkpoint_score, features = feat_selection( X[features], Y, scale, dart_reg, dartr_checkpoint_score, _iter=25) _save_model(stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final=False) elif stage == 6: dart_reg, dartr_checkpoint_score = lgb_tree_params( X[features], Y, dart_reg, scale, dartr_checkpoint_score) _save_model(stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final=False) elif stage == 7: scale, dartr_checkpoint_score = test_scaler(dart_reg, X[features], Y) _save_model(stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final=False) elif stage == 8: dartr_checkpoint_score, features = feat_selection( X[features], Y, scale, dart_reg, dartr_checkpoint_score) _save_model(stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final=False) elif stage == 9: dart_reg, dartr_checkpoint_score = lgb_drop_lr(dart_reg, X[features], Y, scale, dartr_checkpoint_score) _save_model(stage, dimension, name, dart_reg, scale, dartr_checkpoint_score, features, final=True)
def tune_lgr(): name = 'LightGBR' dimension = 'length' stage, lgb_reg, scale, features, lgbr_checkpoint_score = stage_init( name, dimension) if stage == 0: lgb_reg = lgb.LGBMRegressor(random_state=1108, n_estimators=100, subsample=.8, verbose=-1) lgbr_checkpoint_score = -np.inf scale, lgbr_checkpoint_score = test_scaler(lgb_reg, X, Y) _save_model(stage, dimension, name, lgb_reg, scale, lgbr_checkpoint_score, list(X), final=False) elif stage == 1: lgbr_checkpoint_score, features = feat_selection_2( X[features], Y, scale, lgb_reg, lgbr_checkpoint_score) _save_model(stage, dimension, name, lgb_reg, scale, lgbr_checkpoint_score, features, final=False) elif stage == 2: scale, lgbr_checkpoint_score = test_scaler(lgb_reg, X[features], Y) _save_model(stage, dimension, name, lgb_reg, scale, lgbr_checkpoint_score, features, final=False) elif stage == 3: lgb_reg, lgbr_checkpoint_score = lgb_find_lr(lgb_reg, X[features], Y, scale, lgbr_checkpoint_score) _save_model(stage, dimension, name, lgb_reg, scale, lgbr_checkpoint_score, features, final=False) elif stage == 4: scale, lgbr_checkpoint_score = test_scaler(lgb_reg, X[features], Y) _save_model(stage, dimension, name, lgb_reg, scale, lgbr_checkpoint_score, features, final=False) elif stage == 5: lgbr_checkpoint_score, features = feat_selection( X[features], Y, scale, lgb_reg, lgbr_checkpoint_score) _save_model(stage, dimension, name, lgb_reg, scale, lgbr_checkpoint_score, features, final=False) elif stage == 6: lgb_reg, lgbr_checkpoint_score = lgb_tree_params( X[features], Y, lgb_reg, scale, lgbr_checkpoint_score) _save_model(stage, dimension, name, lgb_reg, scale, lgbr_checkpoint_score, features, final=False) elif stage == 7: scale, lgbr_checkpoint_score = test_scaler(lgb_reg, X[features], Y) _save_model(stage, dimension, name, lgb_reg, scale, lgbr_checkpoint_score, features, final=False) elif stage == 8: lgbr_checkpoint_score, features = feat_selection(X[features], Y, scale, lgb_reg, lgbr_checkpoint_score, _iter=25) _save_model(stage, dimension, name, lgb_reg, scale, lgbr_checkpoint_score, features, final=False) elif stage == 9: lgb_reg, lgbr_checkpoint_score = lgb_drop_lr(lgb_reg, X[features], Y, scale, lgbr_checkpoint_score) _save_model(stage, dimension, name, lgb_reg, scale, lgbr_checkpoint_score, features, final=True)
def tune_dart(): name = 'DartGBM' dimension = 'winner' stage, dart_clf, dart_checkpoint_score = stage_init(name, dimension, extension=EXTENSION) if stage == 0: dart_clf = lgb.LGBMClassifier(random_state=1108, n_estimators=100, subsample=.8, verbose=-1, is_unbalance=True) dart_clf, dart_checkpoint_score = pipe_init(X, Y, dart_clf) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 1: dart_clf, dart_checkpoint_score = test_scaler(dart_clf, dart_checkpoint_score, X, Y) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 2: dart_clf, dart_checkpoint_score = feat_selection( X, Y, dart_clf, dart_checkpoint_score) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 3: dart_clf, dart_checkpoint_score = test_scaler(dart_clf, dart_checkpoint_score, X, Y) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 4: dart_clf, dart_checkpoint_score = pca_tune(X, Y, dart_clf, dart_checkpoint_score) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 5: dart_clf, dart_checkpoint_score = feat_selection( X, Y, dart_clf, dart_checkpoint_score) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 6: dart_clf, dart_checkpoint_score = test_scaler(dart_clf, dart_checkpoint_score, X, Y) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 7: dart_clf, dart_checkpoint_score = lgb_find_lr(dart_clf, X, Y, dart_checkpoint_score) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 8: dart_clf, dart_checkpoint_score = pca_tune(X, Y, dart_clf, dart_checkpoint_score, iter_=10) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 9: dart_clf, dart_checkpoint_score = feat_selection( X, Y, dart_clf, dart_checkpoint_score) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 10: dart_clf, dart_checkpoint_score = test_scaler(dart_clf, dart_checkpoint_score, X, Y) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 11: dart_clf, dart_checkpoint_score = lgb_tree_params( X, Y, dart_clf, dart_checkpoint_score) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 12: dart_clf, dart_checkpoint_score = pca_tune(X, Y, dart_clf, dart_checkpoint_score, iter_=10) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 13: dart_clf, dart_checkpoint_score = feat_selection( X, Y, dart_clf, dart_checkpoint_score) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 14: dart_clf, dart_checkpoint_score = test_scaler(dart_clf, dart_checkpoint_score, X, Y) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=False, extension=EXTENSION) elif stage == 15: dart_clf, dart_checkpoint_score = lgb_drop_lr(dart_clf, X, Y, dart_checkpoint_score) _save_model(stage, 'winner', name, dart_clf, dart_checkpoint_score, final=True, extension=EXTENSION)