Skip to content
Discussion options

You must be logged in to vote

Hi @pw0908,

Just a quick note: if you are doing this for dimensional analysis checks (?), there is a built-in way to enforce that.

If you are doing this more generally, you could do this with a custom loss function. For example:

function my_loss(tree, dataset::Dataset{T,L}, options) where {T,L}
    idx_of_log = 1  # CHANGE ME
    num_bad_nodes = 0
    for node in tree  # Default iteration is depth-first traversal
        if node.degree == 1 && node.op == idx_of_log  # is log()
            for subnode in node.l  # Traverse children of this node
                if subnode.degree == 0 && !subnode.constant && subnode.feature == 2  # is x2
                    num_bad_nodes += 1
                e…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pw0908
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #926 on May 16, 2025 19:32.