Skip to content

A priori functional form with repeated functions #528

Answered by MilesCranmer
AhanDatta asked this question in Q&A
Discussion options

You must be logged in to vote

Oh, if f is the same for all three, it might be easier to just use the original tree passed and simply evaluate with different inputs each time?

For example:

function objective_function(tree, dataset::Dataset{T,L}, options) where {T,L} 
    # Want base tree to have x1 as only feature; any other feature node will return early:
    if any(node -> node.degree == 0 && !node.constant && node.feature != 1, tree)
        return L(1e9)
    end

    # Evaluate once with only the feature passed
    # which is like you are setting x1=x1, then x1=x2, then x1=x3.
    f_x1, flag = eval_tree_array(tree, (@view dataset.X[[1], :]), options)  # Or just `dataset.X` is good too as it will take the first col …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AhanDatta
Comment options

Answer selected by AhanDatta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
PySR PySR-related discussion SymbolicRegression.jl SymbolicRegression.jl-related discussion
2 participants