How to compute the complexity of a function inside the custom objective function? #380
-
This is a question more for the SymbolicRegression julia package than the PySR package. I am using the PySR package, and I am using a custom objective function.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
For example, if we assume that num_exps = count(node -> node.degree == 1 && node.op == 3, tree) Then you can return some large number if num_exps = 0
for node in tree
if node.degree == 1 && node.op == 3
num_exps += 1
end
end |
Beta Was this translation helpful? Give feedback.
compute_complexity(tree, options)
nested_constraints
: https://astroautomata.com/PySR/api/#working-with-complexities. If you mean limiting the total number in the expression, you will have to do that manually in the loss function.For example, if we assume that
exp
is the 3rd operator in the list of unary operators, this would be:Then you can return some large number if
num_exps > 2
. You can also do it like this if this is more readable: