Spaces:
Running
Running
Commit
·
17f6afe
1
Parent(s):
2c6b73d
Improve readme
Browse files
README.md
CHANGED
|
@@ -47,7 +47,9 @@ X = 2*np.random.randn(100, 5)
|
|
| 47 |
y = 2*np.cos(X[:, 3]) + X[:, 0]**2 - 2
|
| 48 |
|
| 49 |
# Learn equations
|
| 50 |
-
equations = pysr(X, y, niterations=5
|
|
|
|
|
|
|
| 51 |
|
| 52 |
...
|
| 53 |
|
|
@@ -63,14 +65,57 @@ which gives:
|
|
| 63 |
2 11 0.000000 plus(plus(mult(x0, x0), cos(x3)), plus(-2.0, cos(x3)))
|
| 64 |
```
|
| 65 |
|
| 66 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
What follows is the API reference for running the numpy interface.
|
| 69 |
You likely don't need to tune the hyperparameters yourself,
|
| 70 |
but if you would like, you can use `hyperopt.py` as an example.
|
| 71 |
However, you should adjust `threads`, `niterations`,
|
| 72 |
`binary_operators`, `unary_operators`, and `maxsize`
|
| 73 |
-
to your requirements.
|
| 74 |
|
| 75 |
The program will output a pandas DataFrame containing the equations,
|
| 76 |
mean square error, and complexity. It will also dump to a csv
|
|
@@ -78,12 +123,6 @@ at the end of every iteration,
|
|
| 78 |
which is `hall_of_fame.csv` by default. It also prints the
|
| 79 |
equations to stdout.
|
| 80 |
|
| 81 |
-
You can add more operators in `operators.jl`, or use default
|
| 82 |
-
Julia ones. Make sure all operators are defined for scalar `Float32`.
|
| 83 |
-
Then just specify the operator names in your call, as above.
|
| 84 |
-
You can also change the dataset learned on by passing in `X` and `y` as
|
| 85 |
-
numpy arrays to `pysr(...)`.
|
| 86 |
-
|
| 87 |
```python
|
| 88 |
pysr(X=None, y=None, threads=4, niterations=20,
|
| 89 |
ncyclesperiteration=int(default_ncyclesperiteration),
|
|
@@ -152,46 +191,6 @@ pd.DataFrame, Results dataframe, giving complexity, MSE, and equations
|
|
| 152 |
(as strings).
|
| 153 |
|
| 154 |
|
| 155 |
-
# Operators
|
| 156 |
-
|
| 157 |
-
All Base julia operators that take 1 or 2 float32 as input,
|
| 158 |
-
and output a float32 as output, are available. A selection
|
| 159 |
-
of these and other valid operators are given below:
|
| 160 |
-
|
| 161 |
-
## Binary
|
| 162 |
-
|
| 163 |
-
`plus`, `mult`, `pow`, `div`, `greater`, `mod`, `beta`, `logical_or`,
|
| 164 |
-
`logical_and`
|
| 165 |
-
|
| 166 |
-
## Unary:
|
| 167 |
-
|
| 168 |
-
`neg`,
|
| 169 |
-
`exp`,
|
| 170 |
-
`abs`,
|
| 171 |
-
`logm` (=log(abs(x) + 1e-8)),
|
| 172 |
-
`logm10` (=log10(abs(x) + 1e-8)),
|
| 173 |
-
`logm2` (=log2(abs(x) + 1e-8)),
|
| 174 |
-
`log1p`,
|
| 175 |
-
`sin`,
|
| 176 |
-
`cos`,
|
| 177 |
-
`tan`,
|
| 178 |
-
`sinh`,
|
| 179 |
-
`cosh`,
|
| 180 |
-
`tanh`,
|
| 181 |
-
`asin`,
|
| 182 |
-
`acos`,
|
| 183 |
-
`atan`,
|
| 184 |
-
`asinh`,
|
| 185 |
-
`acosh`,
|
| 186 |
-
`atanh`,
|
| 187 |
-
`erf`,
|
| 188 |
-
`erfc`,
|
| 189 |
-
`gamma`,
|
| 190 |
-
`relu`,
|
| 191 |
-
`round`,
|
| 192 |
-
`floor`,
|
| 193 |
-
`ceil`,
|
| 194 |
-
`round`.
|
| 195 |
|
| 196 |
|
| 197 |
# TODO
|
|
|
|
| 47 |
y = 2*np.cos(X[:, 3]) + X[:, 0]**2 - 2
|
| 48 |
|
| 49 |
# Learn equations
|
| 50 |
+
equations = pysr(X, y, niterations=5,
|
| 51 |
+
binary_operators=["plus", "mult"],
|
| 52 |
+
unary_operators=["cos", "exp", "sin"])
|
| 53 |
|
| 54 |
...
|
| 55 |
|
|
|
|
| 65 |
2 11 0.000000 plus(plus(mult(x0, x0), cos(x3)), plus(-2.0, cos(x3)))
|
| 66 |
```
|
| 67 |
|
| 68 |
+
### Operators
|
| 69 |
+
|
| 70 |
+
All Base julia operators that take 1 or 2 float32 as input,
|
| 71 |
+
and output a float32 as output, are available. A selection
|
| 72 |
+
of these and other valid operators are stated below. You can also
|
| 73 |
+
define your own in `operators.jl`, and pass the function
|
| 74 |
+
name as a string.
|
| 75 |
+
|
| 76 |
+
**Binary**
|
| 77 |
+
|
| 78 |
+
`plus`, `mult`, `pow`, `div`, `greater`, `mod`, `beta`, `logical_or`,
|
| 79 |
+
`logical_and`
|
| 80 |
+
|
| 81 |
+
**Unary**
|
| 82 |
+
|
| 83 |
+
`neg`,
|
| 84 |
+
`exp`,
|
| 85 |
+
`abs`,
|
| 86 |
+
`logm` (=log(abs(x) + 1e-8)),
|
| 87 |
+
`logm10` (=log10(abs(x) + 1e-8)),
|
| 88 |
+
`logm2` (=log2(abs(x) + 1e-8)),
|
| 89 |
+
`log1p`,
|
| 90 |
+
`sin`,
|
| 91 |
+
`cos`,
|
| 92 |
+
`tan`,
|
| 93 |
+
`sinh`,
|
| 94 |
+
`cosh`,
|
| 95 |
+
`tanh`,
|
| 96 |
+
`asin`,
|
| 97 |
+
`acos`,
|
| 98 |
+
`atan`,
|
| 99 |
+
`asinh`,
|
| 100 |
+
`acosh`,
|
| 101 |
+
`atanh`,
|
| 102 |
+
`erf`,
|
| 103 |
+
`erfc`,
|
| 104 |
+
`gamma`,
|
| 105 |
+
`relu`,
|
| 106 |
+
`round`,
|
| 107 |
+
`floor`,
|
| 108 |
+
`ceil`,
|
| 109 |
+
`round`.
|
| 110 |
+
|
| 111 |
+
### Full API
|
| 112 |
|
| 113 |
What follows is the API reference for running the numpy interface.
|
| 114 |
You likely don't need to tune the hyperparameters yourself,
|
| 115 |
but if you would like, you can use `hyperopt.py` as an example.
|
| 116 |
However, you should adjust `threads`, `niterations`,
|
| 117 |
`binary_operators`, `unary_operators`, and `maxsize`
|
| 118 |
+
to your requirements.
|
| 119 |
|
| 120 |
The program will output a pandas DataFrame containing the equations,
|
| 121 |
mean square error, and complexity. It will also dump to a csv
|
|
|
|
| 123 |
which is `hall_of_fame.csv` by default. It also prints the
|
| 124 |
equations to stdout.
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
```python
|
| 127 |
pysr(X=None, y=None, threads=4, niterations=20,
|
| 128 |
ncyclesperiteration=int(default_ncyclesperiteration),
|
|
|
|
| 191 |
(as strings).
|
| 192 |
|
| 193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
|
| 196 |
# TODO
|