# Specify how results are going to be saved
# Define hyperpipe
hyperpipe = Hyperpipe('None',
project_folder = './results',
optimizer="random_grid_search",
optimizer_params={'n_configurations': 30},
metrics=['accuracy', 'balanced_accuracy', 'specificity', 'sensitivity'],
best_config_metric="balanced_accuracy",
outer_cv = KFold(n_splits=5,shuffle=True),
inner_cv = KFold(n_splits=3, shuffle=True))
# Add transformer elements
preprocessing_pipe = Preprocessing()
hyperpipe += preprocessing_pipe
preprocessing_pipe += PipelineElement("LabelEncoder")
hyperpipe += PipelineElement("SimpleImputer", hyperparameters={},
test_disabled=False, missing_values=np.nan, strategy='mean', fill_value=0)
hyperpipe += PipelineElement("PCA", hyperparameters={'n_components': FloatRange(0.2, 0.99)},
test_disabled=False)
# Add estimator
estimator_switch = Switch('EstimatorSwitch')
estimator_switch += PipelineElement("RandomForestClassifier", hyperparameters={'n_estimators': [25, 50, 75], 'min_samples_split': IntegerRange(2, 10), 'min_samples_leaf': IntegerRange(1, 10)}, criterion='gini', max_depth=None)
estimator_switch += PipelineElement("GaussianProcessClassifier", hyperparameters={}, optimizer='fmin_l_bfgs_b', n_restarts_optimizer=0)
estimator_switch += PipelineElement("AdaBoostClassifier", hyperparameters={'n_estimators': IntegerRange(30, 80), 'learning_rate': FloatRange(0.1, 1)})
estimator_switch += PipelineElement("SVC", hyperparameters={'C': FloatRange(1e-7, 1e7, range_type="geomspace"), 'kernel': ['linear', 'rbf']}, gamma='scale', max_iter=1000000.0)
hyperpipe += estimator_switch