-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add starting point * Add categorical parameters, treat discrete and categorical as discrete * Fix discrete setting * Add n_jobs * Fix for 0.2.22 * Fix eps * Fix initial point * Add multi objective * Rebase * Minor
- Loading branch information
Showing
5 changed files
with
167 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from datetime import timedelta | ||
|
||
from golem.core.optimisers.graph import OptNode, OptGraph | ||
from golem.core.optimisers.objective import ObjectiveEvaluate, Objective | ||
from golem.core.tuning.iopt_tuner import IOptTuner | ||
from golem.core.tuning.search_space import SearchSpace | ||
from test.unit.utils import ParamsSumMetric | ||
|
||
|
||
def opt_graph_with_params(): | ||
node_a = OptNode('a') | ||
node_b = OptNode({'name': 'b', 'params': {'b2': 0.7, 'b3': 2}}) | ||
node_c = OptNode('c', nodes_from=[node_a]) | ||
node_d = OptNode('d', nodes_from=[node_b]) | ||
node_final = OptNode('e', nodes_from=[node_c, node_d]) | ||
graph = OptGraph(node_final) | ||
return graph | ||
|
||
|
||
def get_search_space(): | ||
params_per_operation = { | ||
'a': { | ||
'a1': { | ||
'sampling-scope': [2, 7], | ||
'type': 'discrete' | ||
}, | ||
'a2': { | ||
'sampling-scope': [1e-3, 1], | ||
'type': 'continuous' | ||
}, | ||
'a3': { | ||
'sampling-scope': [['A', 'B', 'C']], | ||
'type': 'categorical' | ||
} | ||
}, | ||
'b': { | ||
'b1': { | ||
'sampling-scope': [["first", "second", "third"]], | ||
'type': 'categorical' | ||
}, | ||
'b2': { | ||
'sampling-scope': [0.04, 1.0], | ||
'type': 'continuous' | ||
}, | ||
}, | ||
'e': { | ||
'e1': { | ||
'sampling-scope': [0.05, 1.0], | ||
'type': 'continuous' | ||
}, | ||
'e2': { | ||
'sampling-scope': [0.05, 1.0], | ||
'type': 'continuous' | ||
} | ||
}, | ||
'k': { | ||
'k': { | ||
'sampling-scope': [1e-2, 10.0], | ||
'type': 'continuous' | ||
} | ||
}} | ||
return SearchSpace(params_per_operation) | ||
|
||
|
||
if __name__ == '__main__': | ||
search_space = get_search_space() | ||
graph = opt_graph_with_params() | ||
# search for parameters that will maximize their sum | ||
obj_eval = ObjectiveEvaluate(Objective({'sum_metric': ParamsSumMetric.get_value})) | ||
|
||
tuner = IOptTuner(obj_eval, search_space, iterations=10, n_jobs=-1) | ||
tuned_graph = tuner.tune(graph) |
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 |
---|---|---|
|
@@ -24,7 +24,7 @@ psutil>=5.9.2 | |
|
||
# Optimisation | ||
hyperopt>=0.2.7 | ||
iOpt==0.1.6 | ||
iOpt==0.2.22 | ||
optuna>=3.2.0 | ||
|
||
# Tests | ||
|
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