Ejemplo n.º 1
0
def cascade_LR():   #意义不大
    if config.cascade_LR:
        LinearRgressor = quantum_forest.Linear_Regressor({'cascade':"ridge"})
        y_New = LinearRgressor.BeforeFit((data.X_train, data.y_train),[(data.X_valid, data.y_valid),(data.X_test, data.y_test)])
        YY_train = y_New[0]
        YY_valid,YY_test = y_New[1],y_New[2]
    else:
        YY_train,YY_valid,YY_test = data.y_train, data.y_valid, data.y_test
    return YY_train,YY_valid,YY_test
Ejemplo n.º 2
0
def Fold_learning(fold_n,data,config,visual):
    t0 = time.time()
    if config.model=="QForest":
        if config.feat_info == "importance":
            feat_info = get_feature_info(data,fold_n)            
        else:
            feat_info = None
        accu,_ = NODE_test(data,fold_n,config,visual,feat_info)
    elif config.model=="GBDT":
        accu,_ = GBDT_test(data,fold_n)
    else:        #"LinearRegressor"    
        model = quantum_forest.Linear_Regressor({'cascade':"ridge"})
        accu,_ = model.fit((data.X_train, data.y_train),[(data.X_test, data.y_test)])

    print(f"\n======\n====== Fold_{fold_n}\tACCURACY={accu:.5f},time={time.time() - t0:.2f} ====== \n======\n")
    return
Ejemplo n.º 3
0
def Fold_learning(fold_n, data, config, visual):
    t0 = time.time()
    if config.model == "QForest":
        if config.feat_info == "importance":
            feat_info = get_feature_info(data, fold_n)
        else:
            feat_info = None
        accu, _ = QF_test(data, fold_n, config, visual, feat_info)
    elif config.model == "GBDT" or config.model == "Catboost" or config.model == "XGBoost" or config.model == "LightGBM":
        accu, _ = GBDT_test(config,
                            data,
                            fold_n,
                            num_rounds=config.nMostEpochs)
    else:  #"LinearRegressor"
        model = quantum_forest.Linear_Regressor({'cascade': "ridge"})
        accu, _ = model.fit((data.X_train, data.y_train),
                            [(data.X_test, data.y_test)])

    print(f"\n======\n====== Fold_{fold_n}@{data.name}\t{data.problem()}"\
            f"\tACCURACY={accu:.5f},time={time.time() - t0:.2f} ====== \n======\n")
    return