Beispiel #1
0
def tune_rbfsvr():
    name = 'RbfSVR'
    dimension = 'length'
    
    stage, rbfsvr_reg, scale, features, rbfsvr_checkpoint_score = stage_meta_init(meta_dimension, name, dimension)
    
    if stage == 0:
        rbfsvr_reg = SVR(kernel = 'rbf')
        rbfsvr_checkpoint_score = -np.inf
#        features = init_feat_selection(X, Y, rbfsvr_reg)
        scale, rbfsvr_checkpoint_score = test_scaler(rbfsvr_reg, X, Y) 
        _save_meta_model(meta_dimension, stage, dimension, name, rbfsvr_reg, scale, rbfsvr_checkpoint_score, list(X), final = False)
        
    elif stage == 1: 
        rbfsvr_checkpoint_score, features = feat_selection_2(X[features], Y, scale, rbfsvr_reg, rbfsvr_checkpoint_score, 24, -1, False)
        _save_meta_model(meta_dimension, stage, dimension, name, rbfsvr_reg, scale, rbfsvr_checkpoint_score, features, final = False)
    
    elif stage == 2:
        scale, linsvc_checkpoint_score = test_scaler(rbfsvr_reg, X[features], Y) 
        _save_meta_model(meta_dimension, stage, dimension, name, rbfsvr_reg, scale, rbfsvr_checkpoint_score, features, final = False)
            
    elif stage == 3:
        rbfsvr_reg, rbfsvr_checkpoint_score = svc_hyper_parameter_tuning(X[features], Y, rbfsvr_reg, scale, rbfsvr_checkpoint_score)
        _save_meta_model(meta_dimension, stage, dimension, name, rbfsvr_reg, scale, rbfsvr_checkpoint_score, features, final = False)
    
    elif stage == 4:
        scale, rbfsvr_checkpoint_score = test_scaler(rbfsvr_reg, X[features], Y) 
        _save_meta_model(meta_dimension, stage, dimension, name, rbfsvr_reg, scale, rbfsvr_checkpoint_score, features, final = False)

    elif stage == 5:
        rbfsvr_checkpoint_score, features = feat_selection_2(X[features], Y, scale, rbfsvr_reg, rbfsvr_checkpoint_score, 10, -1, False)
        _save_meta_model(meta_dimension, stage, dimension, name, rbfsvr_reg, scale, rbfsvr_checkpoint_score, features, final = True)
Beispiel #2
0
def tune_polysvr():
    name = 'PolySVR'
    dimension = 'length'
    
    stage, polysvr_reg, scale, features, polysvr_checkpoint_score = stage_meta_init(meta_dimension, name, dimension)
    
    if stage == 0:
        polysvr_reg = SVR(kernel = 'poly')
        polysvr_checkpoint_score = -np.inf
#        features = init_feat_selection(X, Y, rbfsvc_clf)
        scale, polysvr_checkpoint_score = test_scaler(polysvr_reg, X, Y) 
        _save_meta_model(meta_dimension, stage, dimension, name, polysvr_reg, scale, polysvr_checkpoint_score, list(X), final = False)
        
    elif stage == 1: 
        polysvr_checkpoint_score, features = feat_selection_2(X[features], Y, scale, polysvr_reg, polysvr_checkpoint_score, 24, -1, False)
        _save_meta_model(meta_dimension, stage, dimension, name, polysvr_reg, scale, polysvr_checkpoint_score, features, final = False)
    
    elif stage == 2:
        scale, polysvr_checkpoint_score = test_scaler(polysvr_reg, X[features], Y) 
        _save_meta_model(meta_dimension, stage, dimension, name, polysvr_reg, scale, polysvr_checkpoint_score, features, final = False)
            
    elif stage == 3:
        polysvr_reg, polysvr_checkpoint_score = poly_hyper_parameter_tuning(X[features], Y, polysvr_reg, scale, polysvr_checkpoint_score, iter_ = 50)
        _save_meta_model(meta_dimension, stage, dimension, name, polysvr_reg, scale, polysvr_checkpoint_score, features, final = False)
    
    elif stage == 4:
        scale, polysvr_checkpoint_score = test_scaler(polysvr_reg, X[features], Y) 
        _save_meta_model(meta_dimension, stage, dimension, name, polysvr_reg, scale, polysvr_checkpoint_score, features, final = False)

    elif stage == 5:
        polysvr_checkpoint_score, features = feat_selection_2(X[features], Y, scale, polysvr_reg, polysvr_checkpoint_score, 10, -1, False)
        _save_meta_model(meta_dimension, stage, dimension, name, polysvr_reg, scale, polysvr_checkpoint_score, features, final = True)
Beispiel #3
0
def tune_rf():
    name = 'RFreg'
    dimension = 'length'
    
    stage, rf_reg, scale, features, rf_checkpoint_score = stage_meta_init(meta_dimension, name, dimension)
    
    if stage == 0:
        rf_reg = RandomForestRegressor(random_state = 1108, n_estimators = 100)
        rf_checkpoint_score = -np.inf    
        scale, rf_checkpoint_score = test_scaler(rf_reg, X, Y) 
        _save_meta_model(meta_dimension, stage, dimension, name, rf_reg, scale, rf_checkpoint_score, list(X), final = False)

    elif stage == 1: 
        rf_checkpoint_score, features = feat_selection_2(X[features], Y, scale, rf_reg, rf_checkpoint_score, 24, -1, False)
        _save_meta_model(meta_dimension, stage, dimension, name, rf_reg, scale, rf_checkpoint_score, features, final = False)

    elif stage == 2:
        scale, rf_checkpoint_score = test_scaler(rf_reg, X[features], Y) 
        _save_meta_model(meta_dimension, stage, dimension, name, rf_reg, scale, rf_checkpoint_score, features, final = False)
          
    elif stage == 3: 
        rf_reg, rf_checkpoint_score = forest_params(X[features], Y, rf_reg, scale, rf_checkpoint_score, iter_ = 1000)
        _save_meta_model(meta_dimension, stage, dimension, name, rf_reg, scale, rf_checkpoint_score, features, final = False)

    elif stage == 4:
        scale, rf_checkpoint_score = test_scaler(rf_reg, X[features], Y) 
        _save_meta_model(meta_dimension, stage, dimension, name, rf_reg, scale, rf_checkpoint_score, features, final = False)

    elif stage == 5: 
        rf_checkpoint_score, features = feat_selection(X[features], Y, scale, rf_reg, rf_checkpoint_score, 24, -1, False)
        _save_meta_model(meta_dimension, stage, dimension, name, rf_reg, scale, rf_checkpoint_score, features, final = False)
     
    elif stage == 6:
        rf_reg, rf_checkpoint_score = rf_trees(X, Y, scale, rf_reg, rf_checkpoint_score)
        _save_meta_model(meta_dimension, stage, dimension, name, rf_reg, scale, rf_checkpoint_score, features, final = True)
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
0
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)
Beispiel #7
0
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)