Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
df48549
1
Parent(s):
bfb135a
Need to eval nested_constraints after importing SymbolicRegression
Browse files- pysr/sr.py +12 -11
pysr/sr.py
CHANGED
@@ -1186,17 +1186,6 @@ class PySRRegressor(BaseEstimator, RegressorMixin):
|
|
1186 |
|
1187 |
una_constraints = [constraints[op] for op in unary_operators]
|
1188 |
bin_constraints = [constraints[op] for op in binary_operators]
|
1189 |
-
nested_constraints = self.params["nested_constraints"]
|
1190 |
-
if nested_constraints is not None:
|
1191 |
-
# Parse dict into Julia Dict:
|
1192 |
-
nested_constraints_str = "Dict("
|
1193 |
-
for outer_k, outer_v in nested_constraints.items():
|
1194 |
-
nested_constraints_str += f"({outer_k}) => Dict("
|
1195 |
-
for inner_k, inner_v in outer_v.items():
|
1196 |
-
nested_constraints_str += f"({inner_k}) => {inner_v}, "
|
1197 |
-
nested_constraints_str += "), "
|
1198 |
-
nested_constraints_str += ")"
|
1199 |
-
nested_constraints = Main.eval(nested_constraints_str)
|
1200 |
|
1201 |
if not already_ran:
|
1202 |
Main.eval("using Pkg")
|
@@ -1228,6 +1217,18 @@ class PySRRegressor(BaseEstimator, RegressorMixin):
|
|
1228 |
Main.pow = Main.eval("(^)")
|
1229 |
Main.div = Main.eval("(/)")
|
1230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1231 |
Main.custom_loss = Main.eval(loss)
|
1232 |
|
1233 |
mutationWeights = [
|
|
|
1186 |
|
1187 |
una_constraints = [constraints[op] for op in unary_operators]
|
1188 |
bin_constraints = [constraints[op] for op in binary_operators]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1189 |
|
1190 |
if not already_ran:
|
1191 |
Main.eval("using Pkg")
|
|
|
1217 |
Main.pow = Main.eval("(^)")
|
1218 |
Main.div = Main.eval("(/)")
|
1219 |
|
1220 |
+
nested_constraints = self.params["nested_constraints"]
|
1221 |
+
if nested_constraints is not None:
|
1222 |
+
# Parse dict into Julia Dict:
|
1223 |
+
nested_constraints_str = "Dict("
|
1224 |
+
for outer_k, outer_v in nested_constraints.items():
|
1225 |
+
nested_constraints_str += f"({outer_k}) => Dict("
|
1226 |
+
for inner_k, inner_v in outer_v.items():
|
1227 |
+
nested_constraints_str += f"({inner_k}) => {inner_v}, "
|
1228 |
+
nested_constraints_str += "), "
|
1229 |
+
nested_constraints_str += ")"
|
1230 |
+
nested_constraints = Main.eval(nested_constraints_str)
|
1231 |
+
|
1232 |
Main.custom_loss = Main.eval(loss)
|
1233 |
|
1234 |
mutationWeights = [
|