Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
439159c
1
Parent(s):
aadb328
Additional examples in quick start
Browse files
README.md
CHANGED
@@ -69,6 +69,38 @@ which gives:
|
|
69 |
2 11 0.000000 plus(plus(mult(x0, x0), cos(x3)), plus(-2.0, cos(x3)))
|
70 |
```
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
# Operators
|
73 |
|
74 |
All Base julia operators that take 1 or 2 float32 as input,
|
|
|
69 |
2 11 0.000000 plus(plus(mult(x0, x0), cos(x3)), plus(-2.0, cos(x3)))
|
70 |
```
|
71 |
|
72 |
+
**Custom operators:**
|
73 |
+
|
74 |
+
One can define custom operators in Julia by passing a string:
|
75 |
+
```python
|
76 |
+
equations = pysr.pysr(X, y, niterations=100,
|
77 |
+
binary_operators=["mult", "plus", "special(x, y) = x^2 + y"],
|
78 |
+
unary_operators=["cos"])
|
79 |
+
```
|
80 |
+
|
81 |
+
Now, the symbolic regression code can search using this `special` function
|
82 |
+
that squares its left argument and adds it to its right. Make sure
|
83 |
+
all passed functions are valid Julia code, and take one (unary)
|
84 |
+
or two (binary) float32 scalars as input, and output a float32. Operators
|
85 |
+
are automatically vectorized.
|
86 |
+
|
87 |
+
One can also edit `operators.jl`. See below for more options.
|
88 |
+
|
89 |
+
**Weighted data**
|
90 |
+
|
91 |
+
Here, we assign weights to each row of data
|
92 |
+
using inverse uncertainty squared. We also use 10 threads
|
93 |
+
instead of the usual 4, which creates more population
|
94 |
+
(one population per thread).
|
95 |
+
```python
|
96 |
+
sigma = ...
|
97 |
+
weights = 1/sigma**2
|
98 |
+
|
99 |
+
equations = pysr.pysr(X, y, weights=weights, threads=10)
|
100 |
+
```
|
101 |
+
|
102 |
+
|
103 |
+
|
104 |
# Operators
|
105 |
|
106 |
All Base julia operators that take 1 or 2 float32 as input,
|