Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
d01ec4b
1
Parent(s):
a8bb4b5
Change PySR defaults; fixes #99
Browse files- README.md +0 -1
- docs/examples.md +1 -12
- docs/options.md +2 -2
- example.py +0 -1
- pysr/sr.py +6 -6
README.md
CHANGED
@@ -94,7 +94,6 @@ PySR's main interface is in the style of scikit-learn:
|
|
94 |
from pysr import PySRRegressor
|
95 |
model = PySRRegressor(
|
96 |
niterations=5,
|
97 |
-
populations=8,
|
98 |
binary_operators=["+", "*"],
|
99 |
unary_operators=[
|
100 |
"cos",
|
|
|
94 |
from pysr import PySRRegressor
|
95 |
model = PySRRegressor(
|
96 |
niterations=5,
|
|
|
97 |
binary_operators=["+", "*"],
|
98 |
unary_operators=[
|
99 |
"cos",
|
docs/examples.md
CHANGED
@@ -7,13 +7,6 @@ import numpy as np
|
|
7 |
from pysr import *
|
8 |
```
|
9 |
|
10 |
-
We'll also set up some default options that will
|
11 |
-
make these simple searches go faster (but are less optimal
|
12 |
-
for more complex searches).
|
13 |
-
|
14 |
-
```python
|
15 |
-
kwargs = dict(populations=5, niterations=5, annealing=True)
|
16 |
-
```
|
17 |
|
18 |
## 1. Simple search
|
19 |
|
@@ -23,7 +16,7 @@ find the expression `2 cos(x3) + x0^2 - 2`.
|
|
23 |
```python
|
24 |
X = 2 * np.random.randn(100, 5)
|
25 |
y = 2 * np.cos(X[:, 3]) + X[:, 0] ** 2 - 2
|
26 |
-
model = PySRRegressor(binary_operators=["+", "-", "*", "/"]
|
27 |
model.fit(X, y)
|
28 |
print(model)
|
29 |
```
|
@@ -38,7 +31,6 @@ y = 1 / X[:, 0]
|
|
38 |
model = PySRRegressor(
|
39 |
binary_operators=["plus", "mult"],
|
40 |
unary_operators=["inv(x) = 1/x"],
|
41 |
-
**kwargs
|
42 |
)
|
43 |
model.fit(X, y)
|
44 |
print(model)
|
@@ -54,7 +46,6 @@ y = 1 / X[:, [0, 1, 2]]
|
|
54 |
model = PySRRegressor(
|
55 |
binary_operators=["plus", "mult"],
|
56 |
unary_operators=["inv(x) = 1/x"],
|
57 |
-
**kwargs
|
58 |
)
|
59 |
model.fit(X, y)
|
60 |
```
|
@@ -124,7 +115,6 @@ model = PySRRegressor(
|
|
124 |
binary_operators=["+", "-", "*", "/"],
|
125 |
unary_operators=["exp"],
|
126 |
select_k_features=5,
|
127 |
-
**kwargs
|
128 |
)
|
129 |
```
|
130 |
Now let's fit this:
|
@@ -174,7 +164,6 @@ model = PySRRegressor(
|
|
174 |
binary_operators=["+", "-", "*", "/"],
|
175 |
unary_operators=["exp"],
|
176 |
denoise=True,
|
177 |
-
**kwargs
|
178 |
)
|
179 |
model.fit(X, y)
|
180 |
print(model)
|
|
|
7 |
from pysr import *
|
8 |
```
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
## 1. Simple search
|
12 |
|
|
|
16 |
```python
|
17 |
X = 2 * np.random.randn(100, 5)
|
18 |
y = 2 * np.cos(X[:, 3]) + X[:, 0] ** 2 - 2
|
19 |
+
model = PySRRegressor(binary_operators=["+", "-", "*", "/"])
|
20 |
model.fit(X, y)
|
21 |
print(model)
|
22 |
```
|
|
|
31 |
model = PySRRegressor(
|
32 |
binary_operators=["plus", "mult"],
|
33 |
unary_operators=["inv(x) = 1/x"],
|
|
|
34 |
)
|
35 |
model.fit(X, y)
|
36 |
print(model)
|
|
|
46 |
model = PySRRegressor(
|
47 |
binary_operators=["plus", "mult"],
|
48 |
unary_operators=["inv(x) = 1/x"],
|
|
|
49 |
)
|
50 |
model.fit(X, y)
|
51 |
```
|
|
|
115 |
binary_operators=["+", "-", "*", "/"],
|
116 |
unary_operators=["exp"],
|
117 |
select_k_features=5,
|
|
|
118 |
)
|
119 |
```
|
120 |
Now let's fit this:
|
|
|
164 |
binary_operators=["+", "-", "*", "/"],
|
165 |
unary_operators=["exp"],
|
166 |
denoise=True,
|
|
|
167 |
)
|
168 |
model.fit(X, y)
|
169 |
print(model)
|
docs/options.md
CHANGED
@@ -25,7 +25,7 @@ and complexity.
|
|
25 |
|
26 |
It will also dump to a csv
|
27 |
at the end of every iteration,
|
28 |
-
which is
|
29 |
It also prints the equations to stdout.
|
30 |
|
31 |
## Model selection
|
@@ -91,7 +91,7 @@ you want `pysr` to use.
|
|
91 |
|
92 |
## Populations
|
93 |
|
94 |
-
By default, `populations=
|
95 |
number of populations with this option.
|
96 |
More populations may increase
|
97 |
the diversity of equations discovered, though will take longer to train.
|
|
|
25 |
|
26 |
It will also dump to a csv
|
27 |
at the end of every iteration,
|
28 |
+
which is `.hall_of_fame_{date_time}.csv` by default.
|
29 |
It also prints the equations to stdout.
|
30 |
|
31 |
## Model selection
|
|
|
91 |
|
92 |
## Populations
|
93 |
|
94 |
+
By default, `populations=100`, but you can set a different
|
95 |
number of populations with this option.
|
96 |
More populations may increase
|
97 |
the diversity of equations discovered, though will take longer to train.
|
example.py
CHANGED
@@ -7,7 +7,6 @@ from pysr import PySRRegressor
|
|
7 |
|
8 |
model = PySRRegressor(
|
9 |
niterations=5,
|
10 |
-
populations=8,
|
11 |
binary_operators=["+", "*"],
|
12 |
unary_operators=[
|
13 |
"cos",
|
|
|
7 |
|
8 |
model = PySRRegressor(
|
9 |
niterations=5,
|
|
|
10 |
binary_operators=["+", "*"],
|
11 |
unary_operators=[
|
12 |
"cos",
|
pysr/sr.py
CHANGED
@@ -365,14 +365,14 @@ class PySRRegressor(BaseEstimator, RegressorMixin):
|
|
365 |
unary_operators=None,
|
366 |
procs=cpu_count(),
|
367 |
loss="L2DistLoss()",
|
368 |
-
populations=
|
369 |
-
niterations=
|
370 |
-
ncyclesperiteration=
|
371 |
alpha=0.1,
|
372 |
annealing=False,
|
373 |
-
fractionReplaced=0.
|
374 |
-
fractionReplacedHof=0.
|
375 |
-
npop=
|
376 |
parsimony=1e-4,
|
377 |
migration=True,
|
378 |
hofMigration=True,
|
|
|
365 |
unary_operators=None,
|
366 |
procs=cpu_count(),
|
367 |
loss="L2DistLoss()",
|
368 |
+
populations=100,
|
369 |
+
niterations=4,
|
370 |
+
ncyclesperiteration=100,
|
371 |
alpha=0.1,
|
372 |
annealing=False,
|
373 |
+
fractionReplaced=0.01,
|
374 |
+
fractionReplacedHof=0.005,
|
375 |
+
npop=100,
|
376 |
parsimony=1e-4,
|
377 |
migration=True,
|
378 |
hofMigration=True,
|