예제 #1
0
n_features_to_test = [0.85, 0.9, 0.95]


#SVM
steps = [('scaler', MinMaxScaler()), ('red_dim', PCA()), ('clf', SVC(kernel='linear', probability=True, random_state=503))]

pipeline = Pipeline(steps)



#MMS
parameteres_1 = [{'scaler':[MinMaxScaler()], 'red_dim':[PCA(random_state=42)], 'red_dim__n_components':list(n_features_to_test), 
              'clf__C':list(C_range), 'clf__class_weight':[None, 'balanced']}]
              
for j in range(1,6):
    results, best_estimators_dict = nested_cv.function_nested_cv(public_data, public_labels, pipeline, parameteres_1, j*2)

    #create folder and save

    save_output.function_save_output(results, dim_reduction, name_1, j*2)



#RBTS
parameteres_2 = [{'scaler':[RobustScaler()], 'red_dim':[PCA(random_state=42)], 'red_dim__n_components':list(n_features_to_test), 
              'clf__C':list(C_range), 'clf__class_weight':[None, 'balanced']}]
              
for j in range(1,6):
    results, best_estimators_dict = nested_cv.function_nested_cv(public_data, public_labels, pipeline, parameteres_2, j*2)

    #create folder and save
#SVM
steps = [('scaler', MinMaxScaler()), ('red_dim', PCA()),
         ('clf', LinearSVC(loss='hinge', random_state=503))]

pipeline = Pipeline(steps)

#MMS
parameteres_1 = [{
    'scaler': [MinMaxScaler()],
    'red_dim': [PCA(random_state=42)],
    'red_dim__n_components': list(n_features_to_test),
    'clf__C': list(C_range),
    'clf__class_weight': [None, 'balanced']
}]

results_1 = nested_cv.function_nested_cv(public_data, public_labels, pipeline,
                                         parameteres_1)

#create folder and save

save_output.function_save_output(results_1, dim_reduction, name_1)

#RBTS
parameteres_2 = [{
    'scaler': [RobustScaler()],
    'red_dim': [PCA(random_state=42)],
    'red_dim__n_components': list(n_features_to_test),
    'clf__C': list(C_range),
    'clf__class_weight': [None, 'balanced']
}]

results_2 = nested_cv.function_nested_cv(public_data, public_labels, pipeline,