-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add example for nevergrad and some comments+typing
- Loading branch information
1 parent
a93cb89
commit 3d2686c
Showing
15 changed files
with
398 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from sklearn.datasets import load_boston | ||
from sklearn.model_selection import ShuffleSplit | ||
import nevergrad as ng | ||
|
||
from photonai.base import Hyperpipe, PipelineElement, OutputSettings | ||
from photonai.optimization import BooleanSwitch, FloatRange | ||
|
||
X, y = load_boston(return_X_y=True) | ||
|
||
# list of all available nevergrad optimizer | ||
print(list(ng.optimizers.registry.values())) | ||
|
||
my_pipe = Hyperpipe('basic_svm_pipe_no_performance', | ||
optimizer='nevergrad', | ||
optimizer_params={'facade': 'NGO', 'n_configurations': 30}, | ||
metrics=['mean_squared_error', 'pearson_correlation', 'mean_absolute_error', 'explained_variance'], | ||
best_config_metric='mean_squared_error', | ||
outer_cv=ShuffleSplit(n_splits=3, test_size=0.2), | ||
inner_cv=ShuffleSplit(n_splits=3, test_size=0.2), | ||
verbosity=0, | ||
output_settings=OutputSettings(project_folder='./tmp/')) | ||
|
||
# ADD ELEMENTS TO YOUR PIPELINE | ||
# first normalize all features | ||
my_pipe += PipelineElement('StandardScaler') | ||
|
||
my_pipe += PipelineElement('PCA', n_components='mle') | ||
|
||
my_pipe += PipelineElement('Ridge', | ||
hyperparameters={'alpha': FloatRange(0.1, 100), | ||
'fit_intercept': BooleanSwitch(), | ||
'normalize': BooleanSwitch()}) | ||
|
||
my_pipe.fit(X, y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.