Spaces:
Running
Running
Commit
·
e926635
1
Parent(s):
295c6bd
Clean up helper functions
Browse files
eureqa.jl
CHANGED
|
@@ -1,13 +1,12 @@
|
|
| 1 |
# Define allowed operators
|
| 2 |
-
plus(x::Float32, y::Float32)
|
| 3 |
-
mult(x::Float32, y::Float32)
|
| 4 |
-
pow(x::Float32, y::Float32)::Float32 = sign(x)*abs(x)^y
|
| 5 |
|
| 6 |
##########################
|
| 7 |
# # Allowed operators
|
| 8 |
# (Apparently using const for globals helps speed)
|
| 9 |
-
const binops = [plus, mult
|
| 10 |
-
const unaops = [sin, cos]
|
| 11 |
##########################
|
| 12 |
|
| 13 |
# How many equations to search when replacing
|
|
@@ -18,7 +17,7 @@ const ns=10;
|
|
| 18 |
##########################
|
| 19 |
# # Dataset to learn
|
| 20 |
const X = convert(Array{Float32, 2}, randn(100, 5)*2)
|
| 21 |
-
const y = convert(Array{Float32, 1}, ((cx,)->
|
| 22 |
##########################
|
| 23 |
|
| 24 |
##################
|
|
|
|
| 1 |
# Define allowed operators
|
| 2 |
+
plus(x::Float32, y::Float32) = x+y
|
| 3 |
+
mult(x::Float32, y::Float32) = x*y;
|
|
|
|
| 4 |
|
| 5 |
##########################
|
| 6 |
# # Allowed operators
|
| 7 |
# (Apparently using const for globals helps speed)
|
| 8 |
+
const binops = [plus, mult]
|
| 9 |
+
const unaops = [sin, cos, exp]
|
| 10 |
##########################
|
| 11 |
|
| 12 |
# How many equations to search when replacing
|
|
|
|
| 17 |
##########################
|
| 18 |
# # Dataset to learn
|
| 19 |
const X = convert(Array{Float32, 2}, randn(100, 5)*2)
|
| 20 |
+
const y = convert(Array{Float32, 1}, ((cx,)->cx^2).(X[:, 2]) + cos.(X[:, 3]))
|
| 21 |
##########################
|
| 22 |
|
| 23 |
##################
|