Skip to content

Commit

Permalink
updated meta_optimizer example
Browse files Browse the repository at this point in the history
  • Loading branch information
RLeenings committed Aug 21, 2023
1 parent 87715bf commit e042908
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/optimizer/meta_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
inner_cv=KFold(n_splits=5),
outer_cv=KFold(n_splits=3),
optimizer='switch',
optimizer_params={'name': 'sk_opt', 'n_configurations': 50},
optimizer_params={'name': 'grid_search'},
# optimizer_params={'name': 'random_search', 'n_configurations': 50},
metrics=['accuracy', 'precision', 'recall', 'balanced_accuracy'],
best_config_metric='accuracy',
project_folder='./tmp',
Expand All @@ -16,7 +17,7 @@
my_pipe.add(PipelineElement('StandardScaler'))

my_pipe += PipelineElement('PCA',
hyperparameters={'n_components': IntegerRange(10, 30)},
hyperparameters={'n_components': IntegerRange(10, 30, step=5)},
test_disabled=True)

# set up two learning algorithms in an ensemble
Expand All @@ -25,15 +26,15 @@
estimator_selection += PipelineElement('RandomForestClassifier',
criterion='gini',
hyperparameters={'min_samples_split': IntegerRange(2, 4),
'max_features': ['auto', 'sqrt', 'log2'],
'max_features': ['sqrt', 'log2'],
'bootstrap': [True, False]})
estimator_selection += PipelineElement('SVC',
hyperparameters={'C': FloatRange(0.5, 25),
hyperparameters={'C': FloatRange(0.5, 25, num=10),
'kernel': ['linear', 'rbf']})

my_pipe += estimator_selection

X, y = load_breast_cancer(return_X_y=True)
my_pipe.fit(X, y)

my_pipe.results_handler.get_mean_of_best_validation_configs_per_estimator()
print(my_pipe.results_handler.get_mean_of_best_validation_configs_per_estimator())

0 comments on commit e042908

Please sign in to comment.