Coevolution with simultaneous function evaluation #527
-
Hello all and thank you for a great SR package! I am trying to use PySR to coevolve two expressions that depend on each other when one of the outputs has too few measurements (or none at all). Essentially I would like to find |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @bengcohen, Thanks and cool idea. I think you could do this with a custom objective that creates that specific structure, like this example: https://astroautomata.com/PySR/examples/#9-custom-objectives. e.g., say that you set the last column of X to be all 0. You can put tree.degree != 2 && return L(1e10)
# Split the tree at the root node
f0 = tree.l
f1 = tree.r
y0, flag0 = eval_tree_array(f0, dataset.X, options)
!flag0 && return L(1e9) # Return a bit lower loss for this breakpoint, because at least it got this far
modified_X = copy(dataset.X)
modified_X[end, :] .= y0 # Set last column to y0
y1, flag1 = eval_tree_array(f1, modified_X, options)
!flag1 && return L(1e8)
# Now you have y0 and y1 and can do your evaluation on them However the one tricky thing is the printed expression (and the one returned to Python) is not really the same thing as the one you are evaluating inside the loss function. So you will need to manually interpret the results afterward. But see the custom objectives example for more discussion about this. Also if you need to fit This is a bit easier on the Julia side as there is the |
Beta Was this translation helpful? Give feedback.
Hi @bengcohen,
Thanks and cool idea. I think you could do this with a custom objective that creates that specific structure, like this example: https://astroautomata.com/PySR/examples/#9-custom-objectives.
e.g., say that you set the last column of X to be all 0. You can put
y0
into that column during the evaluation.