-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathexpert_priors_for_hyperparameters.py
47 lines (41 loc) · 1.29 KB
/
expert_priors_for_hyperparameters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import logging
import time
from warnings import warn
import neps
def run_pipeline(some_float, some_integer, some_cat):
warn("run_pipeline is deprecated, use evaluate_pipeline instead", DeprecationWarning)
return evaluate_pipeline(some_float, some_integer, some_cat)
def evaluate_pipeline(some_float, some_integer, some_cat):
start = time.time()
if some_cat != "a":
y = some_float + some_integer
else:
y = -some_float - some_integer
end = time.time()
return {
"objective_to_minimize": y,
"info_dict": {
"test_score": y,
"train_time": end - start,
},
}
# neps uses the default values and a confidence in this default value to construct a prior
# that speeds up the search
pipeline_space = dict(
some_float=neps.Float(
lower=1, upper=1000, log=True, prior=900, prior_confidence="medium"
),
some_integer=neps.Integer(
lower=0, upper=50, prior=35, prior_confidence="low"
),
some_cat=neps.Categorical(
choices=["a", "b", "c"], prior="a", prior_confidence="high"
),
)
logging.basicConfig(level=logging.INFO)
neps.run(
evaluate_pipeline=evaluate_pipeline,
pipeline_space=pipeline_space,
root_directory="results/user_priors_example",
max_evaluations_total=15,
)