Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
9b49654
1
Parent(s):
3dd70cc
Fix example code
Browse files- example.py +7 -3
example.py
CHANGED
@@ -6,16 +6,20 @@ y = 2.5382 * np.cos(X[:, 3]) + X[:, 0] ** 2 - 0.5
|
|
6 |
from pysr import PySRRegressor
|
7 |
|
8 |
model = PySRRegressor(
|
|
|
9 |
niterations=40,
|
10 |
binary_operators=["+", "*"],
|
11 |
unary_operators=[
|
12 |
"cos",
|
13 |
"exp",
|
14 |
"sin",
|
15 |
-
"inv(x) = 1/x",
|
|
|
16 |
],
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
)
|
20 |
|
21 |
model.fit(X, y)
|
|
|
6 |
from pysr import PySRRegressor
|
7 |
|
8 |
model = PySRRegressor(
|
9 |
+
model_selection="best", # Result is mix of simplicity+accuracy
|
10 |
niterations=40,
|
11 |
binary_operators=["+", "*"],
|
12 |
unary_operators=[
|
13 |
"cos",
|
14 |
"exp",
|
15 |
"sin",
|
16 |
+
"inv(x) = 1/x",
|
17 |
+
# ^ Custom operator (julia syntax)
|
18 |
],
|
19 |
+
extra_sympy_mappings={"inv": lambda x: 1 / x},
|
20 |
+
# ^ Define operator for SymPy as well
|
21 |
+
loss="loss(x, y) = (x - y)^2",
|
22 |
+
# ^ Custom loss function (julia syntax)
|
23 |
)
|
24 |
|
25 |
model.fit(X, y)
|