Replies: 3 comments 1 reply
-
|
This unfortunately won't work out-of-the-box with TemplateExpressions as it would have to do autodiff through the template itself, like with Zygote.jl. Maybe it's possible though haven't tried yet. (evidently the error message isn't great for this; it gives the appearance of a bug rather than missing functionality.) Actually I guess one temporary workaround is to attempt conversion to a single binary tree before evaluation: prediction, grad, complete = eval_grad_tree_array(SymbolicRegression.get_tree(tree), X, options; variable=true)Note that this only works for simple templates that use operators contained in the options. Stuff like |
Beta Was this translation helpful? Give feedback.
-
|
Unfortunately I don't think there's an easy way to check for monotonicity for arbitrary symbolic expressions unless you restrict the form to be something like only sums of monotonic functions (which would severely restrict the search space). This is how XGBoost/Catboost are able to enforce this easily—they just restrict the form of individual decision trees to have increasing child nodes w.r.t. input feature. But for arbitrary symbolic expressions it's much harder. I think basically the only option is, as you have done, to numerically evaluate them, otherwise it seems too hard to efficiently figure out that things like |
Beta Was this translation helpful? Give feedback.
-
|
Also, instead of returning any(>(0.0f0), @view grad[1:3, :]) && return L(10^6 * count(>(0.0f0), @view grad[1:3, :]))(Shouldn't this be |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I cannot use eval_grad_tree_array within loss_function_expression. I wasn't sure if this was a bug or intentional so I haven't posted it as an issue.
Version: SR.jl v1.8.0
This results in error:
Rationale: Apply monotonicity constraints via AD on multiple functions and parameters within
@template_specon baseline variables topredictionwithout complicated chain and quotient rules with D(...) within expression_spec. I thought withloss_function_expressionit would be much more straight forward to apply.If this is not possible, it would be a great feature to have. Although with some know-how, it is relatively straightforward to code monotonicity checks in PySR and SR.jl, but it would be cool to be able to input monotonic constraints like is possible with XGBoost, LGBM, Cat Boost etc. I would say it would have saved me a few months of getting my head round it when I first started. It does get very complicated to enforce monotonicity with multiple functions if eval_grad_tree_array is not possible. Any ideas would be welcome!
It could be something like, monotonic_constraints=[-1,-1,-1, 0, 0, 0] and it would automatically perform eval_grad_tree_array and test the variables in grad that correspond to the constraints input, which should be compatible with both a normal run and template_spec.
Beta Was this translation helpful? Give feedback.
All reactions