forked from astroautomata/SymbolicRegression.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.jl
More file actions
29 lines (20 loc) · 739 Bytes
/
example.jl
File metadata and controls
29 lines (20 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using SymbolicRegression
X = randn(Float32, 5, 100)
y = 2 * cos.(X[4, :]) + X[1, :] .^ 2 .- 2
options = SymbolicRegression.Options(;
binary_operators=[+, *, /, -], unary_operators=[cos, exp], populations=20
)
hall_of_fame = equation_search(
X, y; niterations=40, options=options, parallelism=:multithreading
)
dominating = calculate_pareto_frontier(hall_of_fame)
trees = [member.tree for member in dominating]
tree = trees[end]
output, did_succeed = eval_tree_array(tree, X, options)
println("Complexity\tMSE\tEquation")
for member in dominating
complexity = compute_complexity(member, options)
loss = member.loss
string = string_tree(member.tree, options)
println("$(complexity)\t$(loss)\t$(string)")
end