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)
def tune_polysvc(): name = 'PolySVC' dimension = 'winner' stage, polysvc_clf, polysvc_checkpoint_score = stage_init( name, dimension, extension=EXTENSION) if stage == 0: polysvc_clf = SVC(random_state=1108, class_weight='balanced', kernel='poly', probability=True) polysvc_clf, polysvc_checkpoint_score = pipe_init(X, Y, polysvc_clf) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 1: polysvc_clf, polysvc_checkpoint_score = test_scaler( polysvc_clf, polysvc_checkpoint_score, X, Y) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 2: polysvc_clf, polysvc_checkpoint_score = feat_selection_2( X, Y, polysvc_clf, polysvc_checkpoint_score) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 3: polysvc_clf, polysvc_checkpoint_score = test_scaler( polysvc_clf, polysvc_checkpoint_score, X, Y) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 4: polysvc_clf, polysvc_checkpoint_score = pca_tune( X, Y, polysvc_clf, polysvc_checkpoint_score) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 5: polysvc_clf, polysvc_checkpoint_score = feat_selection_2( X, Y, polysvc_clf, polysvc_checkpoint_score) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 6: polysvc_clf, polysvc_checkpoint_score = test_scaler( polysvc_clf, polysvc_checkpoint_score, X, Y) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 7: polysvc_clf, polysvc_checkpoint_score = svc_hyper_parameter_tuning( X, Y, polysvc_clf, polysvc_checkpoint_score) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 8: polysvc_clf, polysvc_checkpoint_score = pca_tune( X, Y, polysvc_clf, polysvc_checkpoint_score, iter_=10) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 9: polysvc_clf, polysvc_checkpoint_score = feat_selection_2( X, Y, polysvc_clf, polysvc_checkpoint_score) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 10: polysvc_clf, polysvc_checkpoint_score = test_scaler( polysvc_clf, polysvc_checkpoint_score, X, Y) _save_model(stage, 'winner', name, polysvc_clf, polysvc_checkpoint_score, final=True, extension=EXTENSION)
def tune_log(): name = 'LogRegression' dimension = 'winner' stage, log_clf, log_checkpoint_score = stage_init(name, dimension, extension=EXTENSION) if stage == 0: log_clf = LogisticRegression(max_iter=1000, random_state=1108, class_weight='balanced', solver='lbfgs') log_clf, log_checkpoint_score = pipe_init(X, Y, log_clf) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 1: log_clf, log_checkpoint_score = test_scaler(log_clf, log_checkpoint_score, X, Y) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 2: log_clf, log_checkpoint_score = feat_selection( X, Y, log_clf, log_checkpoint_score) #, _iter = 5) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 3: log_clf, log_checkpoint_score = test_scaler(log_clf, log_checkpoint_score, X, Y) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 4: log_clf, log_checkpoint_score = pca_tune(X, Y, log_clf, log_checkpoint_score) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 5: log_clf, log_checkpoint_score = feat_selection( X, Y, log_clf, log_checkpoint_score) #, _iter = 5) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 6: log_clf, log_checkpoint_score = test_scaler(log_clf, log_checkpoint_score, X, Y) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 7: log_clf, log_checkpoint_score = C_parameter_tuning( X, Y, log_clf, log_checkpoint_score) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 8: log_clf, log_checkpoint_score = pca_tune(X, Y, log_clf, log_checkpoint_score, iter_=10) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 9: log_clf, log_checkpoint_score = feat_selection( X, Y, log_clf, log_checkpoint_score) #, _iter = 5) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 10: log_clf, log_checkpoint_score = test_scaler(log_clf, log_checkpoint_score, X, Y) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 11: log_clf, log_checkpoint_score = test_solver(X, Y, log_clf, log_checkpoint_score) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 12: log_clf, log_checkpoint_score = pca_tune(X, Y, log_clf, log_checkpoint_score, iter_=10) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 13: log_clf, log_checkpoint_score = feat_selection( X, Y, log_clf, log_checkpoint_score) #, _iter = 5) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=False, extension=EXTENSION) elif stage == 14: log_clf, log_checkpoint_score = test_scaler(log_clf, log_checkpoint_score, X, Y) _save_model(stage, 'winner', name, log_clf, log_checkpoint_score, final=True, extension=EXTENSION)
def tune_linsvc(): name = 'LinSVC' dimension = 'winner' stage, linsvc_clf, linsvc_checkpoint_score = stage_init( name, dimension, extension=EXTENSION) if stage == 0: linsvc_clf = SVC(random_state=1108, class_weight='balanced', kernel='linear', probability=True) linsvc_clf, linsvc_checkpoint_score = pipe_init(X, Y, linsvc_clf) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 1: linsvc_clf, linsvc_checkpoint_score = test_scaler( linsvc_clf, linsvc_checkpoint_score, X, Y) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 2: linsvc_clf, linsvc_checkpoint_score = feat_selection( X, Y, linsvc_clf, linsvc_checkpoint_score) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 3: linsvc_clf, linsvc_checkpoint_score = test_scaler( linsvc_clf, linsvc_checkpoint_score, X, Y) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 4: linsvc_clf, linsvc_checkpoint_score = pca_tune( X, Y, linsvc_clf, linsvc_checkpoint_score) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 5: linsvc_clf, linsvc_checkpoint_score = feat_selection( X, Y, linsvc_clf, linsvc_checkpoint_score) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 6: linsvc_clf, linsvc_checkpoint_score = test_scaler( linsvc_clf, linsvc_checkpoint_score, X, Y) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 7: linsvc_clf, linsvc_checkpoint_score = C_parameter_tuning( X, Y, linsvc_clf, linsvc_checkpoint_score) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 8: linsvc_clf, linsvc_checkpoint_score = pca_tune(X, Y, linsvc_clf, linsvc_checkpoint_score, iter_=10) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 9: linsvc_clf, linsvc_checkpoint_score = feat_selection( X, Y, linsvc_clf, linsvc_checkpoint_score) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=False, extension=EXTENSION) elif stage == 10: linsvc_clf, linsvc_checkpoint_score = test_scaler( linsvc_clf, linsvc_checkpoint_score, X, Y) _save_model(stage, 'winner', name, linsvc_clf, linsvc_checkpoint_score, final=True, extension=EXTENSION)
def tune_knn(): name = 'KNN' dimension = 'winner' stage, knn_clf, knn_checkpoint_score = stage_init(name, dimension, extension=EXTENSION) if stage == 0: knn_clf = KNeighborsClassifier() knn_clf, knn_checkpoint_score = pipe_init(X, Y, knn_clf) _save_model(stage, 'winner', name, knn_clf, knn_checkpoint_score, final=False, extension=EXTENSION) elif stage == 1: knn_clf, knn_checkpoint_score = test_scaler(knn_clf, knn_checkpoint_score, X, Y) _save_model(stage, 'winner', name, knn_clf, knn_checkpoint_score, final=False, extension=EXTENSION) elif stage == 2: knn_clf, knn_checkpoint_score = feat_selection_2( X, Y, knn_clf, knn_checkpoint_score) _save_model(stage, 'winner', name, knn_clf, knn_checkpoint_score, final=False, extension=EXTENSION) elif stage == 3: knn_clf, knn_checkpoint_score = test_scaler(knn_clf, knn_checkpoint_score, X, Y) _save_model(stage, 'winner', name, knn_clf, knn_checkpoint_score, final=False, extension=EXTENSION) elif stage == 4: knn_clf, knn_checkpoint_score = pca_tune(X, Y, knn_clf, knn_checkpoint_score) _save_model(stage, 'winner', name, knn_clf, knn_checkpoint_score, final=False, extension=EXTENSION) elif stage == 5: knn_clf, knn_checkpoint_score = knn_hyper_parameter_tuning( X, Y, knn_clf, knn_checkpoint_score) _save_model(stage, 'winner', name, knn_clf, knn_checkpoint_score, final=False, extension=EXTENSION) elif stage == 6: knn_clf, knn_checkpoint_score = feat_selection_2( X, Y, knn_clf, knn_checkpoint_score) _save_model(stage, 'winner', name, knn_clf, knn_checkpoint_score, final=False, extension=EXTENSION) elif stage == 7: knn_clf, knn_checkpoint_score = test_scaler(knn_clf, knn_checkpoint_score, X, Y) _save_model(stage, 'winner', name, knn_clf, knn_checkpoint_score, final=False, extension=EXTENSION) elif stage == 8: knn_clf, knn_checkpoint_score = pca_tune(X, Y, knn_clf, knn_checkpoint_score, iter_=10) _save_model(stage, 'winner', name, knn_clf, knn_checkpoint_score, final=True, extension=EXTENSION)
def tune_rf(): name = 'RFclass' dimension = 'winner' stage, rf_clf, rf_checkpoint_score = stage_init(name, dimension, extension=EXTENSION) if stage == 0: rf_clf = RandomForestClassifier(random_state=1108, n_estimators=100) rf_clf, rf_checkpoint_score = pipe_init(X, Y, rf_clf) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 1: rf_clf, rf_checkpoint_score = test_scaler(rf_clf, rf_checkpoint_score, X, Y) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 2: rf_clf, rf_checkpoint_score = feat_selection(X, Y, rf_clf, rf_checkpoint_score) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 3: rf_clf, rf_checkpoint_score = test_scaler(rf_clf, rf_checkpoint_score, X, Y) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 4: rf_clf, rf_checkpoint_score = pca_tune(X, Y, rf_clf, rf_checkpoint_score) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 5: rf_clf, rf_checkpoint_score = feat_selection(X, Y, rf_clf, rf_checkpoint_score) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 6: rf_clf, rf_checkpoint_score = test_scaler(rf_clf, rf_checkpoint_score, X, Y) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 7: rf_clf, rf_checkpoint_score = forest_params(X, Y, rf_clf, rf_checkpoint_score) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 8: rf_clf, rf_checkpoint_score = pca_tune(X, Y, rf_clf, rf_checkpoint_score, iter_=10) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 9: rf_clf, rf_checkpoint_score = feat_selection(X, Y, rf_clf, rf_checkpoint_score) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 10: rf_clf, rf_checkpoint_score = test_scaler(rf_clf, rf_checkpoint_score, X, Y) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=False, extension=EXTENSION) elif stage == 11: rf_clf, rf_checkpoint_score = rf_trees(X, Y, rf_clf, rf_checkpoint_score) _save_model(stage, 'winner', name, rf_clf, rf_checkpoint_score, final=True, extension=EXTENSION)