from imblearn.over_sampling import SMOTE
from metrics_list import metric_list

path = "High_IR_Data_cross_folder"
dirs = os.listdir(path)  #Get files in the folder
First_line = True

for Dir in dirs:
    print("Data Set Name: ", Dir)
    dir_path = path + "/" + Dir
    files = os.listdir(dir_path)  # Get files in the folder

    methods = ["xGBoost", "SMOTE", "SMOTE-SMOTE"]
    for m in methods:
        Num_Cross_Folders = 5
        ml_record = metric_list(np.array([1]), np.array([1]),
                                Num_Cross_Folders)
        i = 0
        for file in files:
            name = dir_path + '/' + file
            r = np.load(name)

            Positive_Features_train = r["P_F_tr"]
            Num_Positive_train = Positive_Features_train.shape[0]
            Positive_Labels_train = np.linspace(1, 1, Num_Positive_train)

            Positive_Features_test = r["P_F_te"]
            Num_Positive_test = Positive_Features_test.shape[0]
            Positive_Labels_test = np.linspace(1, 1, Num_Positive_test)

            Negative_Features_train = r["N_F_tr"]
            Num_Negative_train = Negative_Features_train.shape[0]
示例#2
0
dirs = os.listdir(path)  #Get files in the folder

for Dir in dirs:
    print("Data Set Name: ", Dir)
    dir_path = path + "/" + Dir
    files = os.listdir(dir_path)  # Get files in the folder
    f_i = 0
    par_a = []
    par_b = []

    Num_Gamma = 100
    gamma = np.logspace(-4, 2, Num_Gamma)
    Num_C = 100
    C = np.logspace(-2, 4, Num_C)
    Num_Cross_Folders = 3
    ml_record = metric_list(gamma, C, Num_Cross_Folders)
    '''
    max_depth = np.arange(3,10,1)           # best = 3
    min_child_weight = np.arange(1,6,1)     # best = 1
    gamma = np.arange(0,1,0.1)              # best = 0.0
    subsample = np.arange(0.5,1,0.1)        # best = 0.5
    colsample_bytree = np.arange(0.5,1,0.1) # best = 0.6
    reg_alpha = np.logspace(-5, 5, 10)      # best = 0.002
    learning_rate = np.logspace(-2, 0, 10)  # best = 0.215
    '''

    Num_Cross_Folders = 3
    ml_record = metric_list(gamma, C, Num_Cross_Folders)

    i = 0
    for file in files: