Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
7b7f087
1
Parent(s):
dadf84b
Adjust hyperparameters based on 1000 trial search
Browse files
eureqa.py
CHANGED
@@ -5,24 +5,51 @@ import pathlib
|
|
5 |
import numpy as np
|
6 |
import pandas as pd
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
binary_operators=["plus", "mult"],
|
13 |
unary_operators=["cos", "exp", "sin"],
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
timeout=None,
|
|
|
|
|
|
|
26 |
):
|
27 |
""" Runs symbolic regression in Julia, to fit y given X.
|
28 |
Either provide a 2D numpy array for X, 1D array for y, or declare a test to run.
|
@@ -163,15 +190,15 @@ if __name__ == "__main__":
|
|
163 |
parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
|
164 |
|
165 |
parser.add_argument("--threads", type=int, default=4, help="Number of threads")
|
166 |
-
parser.add_argument("--parsimony", type=float, default=
|
167 |
-
parser.add_argument("--alpha", type=
|
168 |
parser.add_argument("--maxsize", type=int, default=20, help="Max size of equation")
|
169 |
parser.add_argument("--niterations", type=int, default=20, help="Number of total migration periods")
|
170 |
-
parser.add_argument("--npop", type=int, default=
|
171 |
-
parser.add_argument("--ncyclesperiteration", type=int, default=
|
172 |
-
parser.add_argument("--topn", type=int, default=
|
173 |
-
parser.add_argument("--fractionReplacedHof", type=float, default=
|
174 |
-
parser.add_argument("--fractionReplaced", type=float, default=
|
175 |
parser.add_argument("--migration", type=bool, default=True, help="Whether to migrate")
|
176 |
parser.add_argument("--hofMigration", type=bool, default=True, help="Whether to have hall of fame migration")
|
177 |
parser.add_argument("--shouldOptimizeConstants", type=bool, default=True, help="Whether to use classical optimization on constants before every migration (doesn't impact performance that much)")
|
|
|
5 |
import numpy as np
|
6 |
import pandas as pd
|
7 |
|
8 |
+
# Dumped from hyperparam optimization
|
9 |
+
default_alpha = 2.288229
|
10 |
+
default_annealing = 1.000000
|
11 |
+
default_fractionReplaced = 0.121271
|
12 |
+
default_fractionReplacedHof = 0.065129
|
13 |
+
default_ncyclesperiteration = 15831.000000
|
14 |
+
default_niterations = 11.000000
|
15 |
+
default_npop = 105.000000
|
16 |
+
default_parsimony = 0.000465
|
17 |
+
default_topn = 6.000000
|
18 |
+
default_weightAddNode = 0.454050
|
19 |
+
default_weightDeleteNode = 0.603670
|
20 |
+
default_weightDoNothing = 0.141223
|
21 |
+
default_weightMutateConstant = 3.680211
|
22 |
+
default_weightMutateOperator = 0.660488
|
23 |
+
default_weightRandomize = 6.759691
|
24 |
+
default_weightSimplify = 0.010442
|
25 |
+
default_result = 0.687007
|
26 |
+
|
27 |
+
def eureqa(X=None, y=None, threads=4,
|
28 |
+
niterations=20,
|
29 |
+
ncyclesperiteration=int(default_ncyclesperiteration),
|
30 |
binary_operators=["plus", "mult"],
|
31 |
unary_operators=["cos", "exp", "sin"],
|
32 |
+
alpha=default_alpha,
|
33 |
+
annealing=True,
|
34 |
+
fractionReplaced=default_fractionReplaced,
|
35 |
+
fractionReplacedHof=default_fractionReplacedHof,
|
36 |
+
npop=int(default_npop),
|
37 |
+
parsimony=default_parsimony,
|
38 |
+
migration=True,
|
39 |
+
hofMigration=True,
|
40 |
+
shouldOptimizeConstants=True,
|
41 |
+
topn=int(default_topn),
|
42 |
+
weightAddNode=default_weightAddNode,
|
43 |
+
weightDeleteNode=default_weightDeleteNode,
|
44 |
+
weightDoNothing=default_weightDoNothing,
|
45 |
+
weightMutateConstant=default_weightMutateConstant,
|
46 |
+
weightMutateOperator=default_weightMutateOperator,
|
47 |
+
weightRandomize=default_weightRandomize,
|
48 |
+
weightSimplify=default_weightSimplify,
|
49 |
timeout=None,
|
50 |
+
equation_file='hall_of_fame.csv',
|
51 |
+
test='simple1',
|
52 |
+
maxsize=20,
|
53 |
):
|
54 |
""" Runs symbolic regression in Julia, to fit y given X.
|
55 |
Either provide a 2D numpy array for X, 1D array for y, or declare a test to run.
|
|
|
190 |
parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
|
191 |
|
192 |
parser.add_argument("--threads", type=int, default=4, help="Number of threads")
|
193 |
+
parser.add_argument("--parsimony", type=float, default=default_parsimony, help="How much to punish complexity")
|
194 |
+
parser.add_argument("--alpha", type=float, default=default_alpha, help="Scaling of temperature")
|
195 |
parser.add_argument("--maxsize", type=int, default=20, help="Max size of equation")
|
196 |
parser.add_argument("--niterations", type=int, default=20, help="Number of total migration periods")
|
197 |
+
parser.add_argument("--npop", type=int, default=int(default_npop), help="Number of members per population")
|
198 |
+
parser.add_argument("--ncyclesperiteration", type=int, default=int(default_ncyclesperiteration), help="Number of evolutionary cycles per migration")
|
199 |
+
parser.add_argument("--topn", type=int, default=int(default_topn), help="How many best species to distribute from each population")
|
200 |
+
parser.add_argument("--fractionReplacedHof", type=float, default=default_fractionReplacedHof, help="Fraction of population to replace with hall of fame")
|
201 |
+
parser.add_argument("--fractionReplaced", type=float, default=default_fractionReplaced, help="Fraction of population to replace with best from other populations")
|
202 |
parser.add_argument("--migration", type=bool, default=True, help="Whether to migrate")
|
203 |
parser.add_argument("--hofMigration", type=bool, default=True, help="Whether to have hall of fame migration")
|
204 |
parser.add_argument("--shouldOptimizeConstants", type=bool, default=True, help="Whether to use classical optimization on constants before every migration (doesn't impact performance that much)")
|