MilesCranmer commited on
Commit
2c6b73d
1 Parent(s): 6aa3e92

Add more operators, and list them

Browse files
Files changed (2) hide show
  1. README.md +44 -1
  2. julia/operators.jl +34 -1
README.md CHANGED
@@ -70,7 +70,7 @@ 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
@@ -152,9 +152,52 @@ pd.DataFrame, Results dataframe, giving complexity, MSE, and equations
152
  (as strings).
153
 
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  # TODO
156
 
157
  - [ ] Why don't the constants continually change? It should optimize them every time the equation appears.
 
158
  - [ ] Add several common unary and binary operators; list these.
159
  - [ ] Calculate feature importances of future mutations, by looking at correlation between residual of model, and the features.
160
  - Store feature importances of future, and periodically update it.
 
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. You can see a list of available operators below.
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
 
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
198
 
199
  - [ ] Why don't the constants continually change? It should optimize them every time the equation appears.
200
+ - [ ] Add ability to save and state from python
201
  - [ ] Add several common unary and binary operators; list these.
202
  - [ ] Calculate feature importances of future mutations, by looking at correlation between residual of model, and the features.
203
  - Store feature importances of future, and periodically update it.
julia/operators.jl CHANGED
@@ -1,6 +1,39 @@
 
 
1
  # Define allowed operators. Any julia operator can also be used.
2
  plus(x::Float32, y::Float32)::Float32 = x+y #Do not change the name of this operator.
3
  mult(x::Float32, y::Float32)::Float32 = x*y #Do not change the name of this operator.
4
  pow(x::Float32, y::Float32)::Float32 = sign(x)*abs(x)^y
5
  div(x::Float32, y::Float32)::Float32 = x/y
6
- loga(x::Float32)::Float32 = log(abs(x) + 1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import SpecialFunctions: gamma, lgamma, erf, erfc, beta
2
+
3
  # Define allowed operators. Any julia operator can also be used.
4
  plus(x::Float32, y::Float32)::Float32 = x+y #Do not change the name of this operator.
5
  mult(x::Float32, y::Float32)::Float32 = x*y #Do not change the name of this operator.
6
  pow(x::Float32, y::Float32)::Float32 = sign(x)*abs(x)^y
7
  div(x::Float32, y::Float32)::Float32 = x/y
8
+ logm(x::Float32)::Float32 = log(abs(x) + 1f-8)
9
+ logm2(x::Float32)::Float32 = log2(abs(x) + 1f-8)
10
+ logm10(x::Float32)::Float32 = log10(abs(x) + 1f-8)
11
+ neg(x::Float32)::Float32 = -x
12
+ function greater(x::Float32, y::Float32)::Float32
13
+ if x > y
14
+ return 1f0
15
+ end
16
+ return 0f0
17
+ end
18
+
19
+ function relu(x::Float32)::Float32
20
+ if x > 0f0
21
+ return x
22
+ end
23
+ return 0f0
24
+ end
25
+
26
+ function logical_or(x::Float32, y::Float32)::Float32
27
+ if x > 0f0 || y > 0f0
28
+ return 1f0
29
+ end
30
+ return 0f0
31
+ end
32
+
33
+ # (Just use multiplication normally)
34
+ function logical_and(x::Float32, y::Float32)::Float32
35
+ if x > 0f0 && y > 0f0
36
+ return 1f0
37
+ end
38
+ return 0f0
39
+ end