Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
β’
1bd0408
1
Parent(s):
eb2dca9
Rename example file so it is obviously an example
Browse files- README.md +2 -7
- main.py β example.py +6 -8
README.md
CHANGED
@@ -65,16 +65,11 @@ pip install pysr
|
|
65 |
```
|
66 |
|
67 |
# Quickstart
|
68 |
-
For a simple demo, start by navigating to the root directory and then in a terminal call
|
69 |
-
```
|
70 |
-
>> python main.py
|
71 |
-
```
|
72 |
-
<br>
|
73 |
-
For a more hands on demo you can do the following (also in the root directory)
|
74 |
|
|
|
75 |
```python
|
76 |
import numpy as np
|
77 |
-
from pysr import pysr, best
|
78 |
|
79 |
# Dataset
|
80 |
X = 2*np.random.randn(100, 5)
|
|
|
65 |
```
|
66 |
|
67 |
# Quickstart
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
+
Here is some demo code (also found in `example.py`)
|
70 |
```python
|
71 |
import numpy as np
|
72 |
+
from pysr import pysr, best
|
73 |
|
74 |
# Dataset
|
75 |
X = 2*np.random.randn(100, 5)
|
main.py β example.py
RENAMED
@@ -1,19 +1,17 @@
|
|
1 |
import numpy as np
|
2 |
-
from pysr import pysr, best
|
3 |
-
import time
|
4 |
|
5 |
# Dataset
|
6 |
X = 2*np.random.randn(100, 5)
|
7 |
y = 2*np.cos(X[:, 3]) + X[:, 0]**2 - 2
|
8 |
|
9 |
-
|
10 |
# Learn equations
|
11 |
-
start = time.time()
|
12 |
equations = pysr(X, y, niterations=5,
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
|
16 |
-
|
17 |
|
18 |
print(best(equations))
|
19 |
-
print(f"Took {time.time()-start} seconds")
|
|
|
1 |
import numpy as np
|
2 |
+
from pysr import pysr, best
|
|
|
3 |
|
4 |
# Dataset
|
5 |
X = 2*np.random.randn(100, 5)
|
6 |
y = 2*np.cos(X[:, 3]) + X[:, 0]**2 - 2
|
7 |
|
|
|
8 |
# Learn equations
|
|
|
9 |
equations = pysr(X, y, niterations=5,
|
10 |
+
binary_operators=["plus", "mult"],
|
11 |
+
unary_operators=[
|
12 |
+
"cos", "exp", "sin", #Pre-defined library of operators (see https://pysr.readthedocs.io/en/latest/docs/operators/)
|
13 |
+
"inv(x) = 1/x"]) # Define your own operator! (Julia syntax)
|
14 |
|
15 |
+
...# (you can use ctl-c to exit early)
|
16 |
|
17 |
print(best(equations))
|
|