示例#1
0
#Designate distributions to sample hyperparameters from
C_range = np.power(2, np.arange(-10, 8, dtype=float))
n_features_to_test = [0.85, 0.9, 0.95]

clf = TransformedTargetRegressor(regressor=SVR(kernel='linear'),
                                 transformer=MinMaxScaler())

#SVM
steps = [('scaler', StandardScaler()), ('red_dim', PCA()), ('clf', clf)]

pipeline = Pipeline(steps)

parameteres = [{
    'scaler': [StandardScaler()],
    'red_dim': [PCA(random_state=42)],
    'red_dim__n_components': list(n_features_to_test),
    'clf__regressor__C': list(C_range)
}, {
    'scaler': [StandardScaler()],
    'red_dim': [None],
    'clf__regressor__C': list(C_range)
}]

results = GSCV.function_GSCV(data_train, labels_train, data_test, labels_test,
                             pipeline, parameteres)

#create folder and save

save_output.function_save_output(results, name_clf)
    'clf__algorithm': ['SAMME', 'SAMME.R']
}, {
    'scaler': scalers_to_test,
    'red_dim': [SelectPercentile(f_classif, percentile=10)],
    'clf__n_estimators': n_estimators,
    'clf__learning_rate': lr,
    'clf__algorithm': ['SAMME', 'SAMME.R']
}, {
    'scaler':
    scalers_to_test,
    'red_dim': [SelectPercentile(mutual_info_classif, percentile=10)],
    'clf__n_estimators':
    n_estimators,
    'clf__learning_rate':
    lr,
    'clf__algorithm': ['SAMME', 'SAMME.R']
}, {
    'scaler': scalers_to_test,
    'red_dim': [None],
    'clf__n_estimators': n_estimators,
    'clf__learning_rate': lr,
    'clf__algorithm': ['SAMME', 'SAMME.R']
}]

results = GSCV.function_GSCV(X_train, y_train, X_test, y_test, pipeline,
                             parameteres)

#create folder and save

save_output.function_save_output(results, name_clf)