Avoid variables appearing in the exponent position #638
-
How to avoid 0.9735712^x0, where x0 appears at the exponent |
Beta Was this translation helpful? Give feedback.
Answered by
MilesCranmer
Jun 3, 2024
Replies: 2 comments
-
You could do it with function my_loss(tree, dataset::Dataset{T,L}, options)::L where {T,L}
index_of_exp = 1 # if its the first operator in your list etc
has_x_in_exp = any(tree) do node
if node.degree == 1 && node.op == index_of_exp
subnode = node.l
return any(subnode) do n
return n.degree == 0 && !n.constant
end
end
return false
end
has_x_in_exp && return L(10_000_000_000)
prediction, flag = eval_tree_array(tree, dataset.X, options)
if !flag
return L(10_000_000)
end
return sum(i -> (prediction[i] - dataset.y[i]) ^ 2, eachindex(dataset.y)) / dataset.n
end |
Beta Was this translation helpful? Give feedback.
0 replies
-
Also see https://astroautomata.com/PySR/api/#working-with-complexities |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Alexia369
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also see https://astroautomata.com/PySR/api/#working-with-complexities