Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
2271609
1
Parent(s):
4f5f994
Add pretty printing to hyperparam optimization
Browse files
benchmarks/hyperparamopt.py
CHANGED
@@ -13,10 +13,9 @@ from space import *
|
|
13 |
TRIALS_FOLDER = "trials2"
|
14 |
NUMBER_TRIALS_PER_RUN = 1
|
15 |
timeout_in_minutes = 10
|
|
|
16 |
|
17 |
# Test run to compile everything:
|
18 |
-
binary_operators = ["*", "/", "+", "-"]
|
19 |
-
unary_operators = ["sin", "cos", "exp", "log"]
|
20 |
julia_project = None
|
21 |
procs = 4
|
22 |
model = PySRRegressor(
|
@@ -210,8 +209,13 @@ path = TRIALS_FOLDER + "/*.pkl"
|
|
210 |
n_prior_trials = len(list(glob.glob(path)))
|
211 |
|
212 |
loaded_fnames = []
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
215 |
n = NUMBER_TRIALS_PER_RUN
|
216 |
|
217 |
# Run new hyperparameter trials until killed
|
|
|
13 |
TRIALS_FOLDER = "trials2"
|
14 |
NUMBER_TRIALS_PER_RUN = 1
|
15 |
timeout_in_minutes = 10
|
16 |
+
start_from_init_vals = False
|
17 |
|
18 |
# Test run to compile everything:
|
|
|
|
|
19 |
julia_project = None
|
20 |
procs = 4
|
21 |
model = PySRRegressor(
|
|
|
209 |
n_prior_trials = len(list(glob.glob(path)))
|
210 |
|
211 |
loaded_fnames = []
|
212 |
+
if start_from_init_vals:
|
213 |
+
trials = generate_trials_to_calculate(init_vals)
|
214 |
+
i = 0
|
215 |
+
else:
|
216 |
+
trials = Trials()
|
217 |
+
i = 1
|
218 |
+
|
219 |
n = NUMBER_TRIALS_PER_RUN
|
220 |
|
221 |
# Run new hyperparameter trials until killed
|
benchmarks/print_best_model.py
CHANGED
@@ -5,6 +5,7 @@ import pickle as pkl
|
|
5 |
import hyperopt
|
6 |
from hyperopt import hp, fmin, tpe, Trials
|
7 |
from space import space
|
|
|
8 |
|
9 |
|
10 |
# Change the following code to your file
|
@@ -87,6 +88,8 @@ for trial in trials:
|
|
87 |
|
88 |
clean_trials = sorted(clean_trials, key=lambda x: x[0])
|
89 |
|
|
|
|
|
90 |
for trial in clean_trials:
|
91 |
loss, params = trial
|
92 |
for k, value in params.items():
|
@@ -101,5 +104,5 @@ for trial in clean_trials:
|
|
101 |
|
102 |
params[k] = value
|
103 |
|
104 |
-
|
105 |
|
|
|
5 |
import hyperopt
|
6 |
from hyperopt import hp, fmin, tpe, Trials
|
7 |
from space import space
|
8 |
+
from pprint import PrettyPrinter
|
9 |
|
10 |
|
11 |
# Change the following code to your file
|
|
|
88 |
|
89 |
clean_trials = sorted(clean_trials, key=lambda x: x[0])
|
90 |
|
91 |
+
pp = PrettyPrinter(indent=4)
|
92 |
+
|
93 |
for trial in clean_trials:
|
94 |
loss, params = trial
|
95 |
for k, value in params.items():
|
|
|
104 |
|
105 |
params[k] = value
|
106 |
|
107 |
+
pp.pprint({"loss": loss, "params": params})
|
108 |
|