Spaces:
Running
Running
Define sympy version of "inv" in README example
Browse files
README.md
CHANGED
|
@@ -89,16 +89,20 @@ PySR's main interface is in the style of scikit-learn:
|
|
| 89 |
```python
|
| 90 |
from pysr import PySRRegressor
|
| 91 |
model = PySRRegressor(
|
|
|
|
| 92 |
niterations=40,
|
| 93 |
binary_operators=["+", "*"],
|
| 94 |
unary_operators=[
|
| 95 |
"cos",
|
| 96 |
"exp",
|
| 97 |
"sin",
|
| 98 |
-
"inv(x) = 1/x",
|
|
|
|
| 99 |
],
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
| 102 |
)
|
| 103 |
```
|
| 104 |
This will set up the model for 40 iterations of the search code, which contains hundreds of thousands of mutations and equation evaluations.
|
|
|
|
| 89 |
```python
|
| 90 |
from pysr import PySRRegressor
|
| 91 |
model = PySRRegressor(
|
| 92 |
+
model_selection="best", # Result is mix of simplicity+accuracy
|
| 93 |
niterations=40,
|
| 94 |
binary_operators=["+", "*"],
|
| 95 |
unary_operators=[
|
| 96 |
"cos",
|
| 97 |
"exp",
|
| 98 |
"sin",
|
| 99 |
+
"inv(x) = 1/x",
|
| 100 |
+
# ^ Custom operator (julia syntax)
|
| 101 |
],
|
| 102 |
+
extra_sympy_mappings={"inv": lambda x: 1 / x},
|
| 103 |
+
# ^ Define operator for SymPy as well
|
| 104 |
+
loss="loss(x, y) = (x - y)^2",
|
| 105 |
+
# ^ Custom loss function (julia syntax)
|
| 106 |
)
|
| 107 |
```
|
| 108 |
This will set up the model for 40 iterations of the search code, which contains hundreds of thousands of mutations and equation evaluations.
|