Skip to content

Compute derivative from fitted model #414

Answered by MilesCranmer
llamm-de asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @llamm-de,

Thanks for the message. This is a bit tricky as MLJ does not have an interface for this, so you will have to use the low-level SymbolicRegression.jl calls directly. The easiest way to do this right now would be as follows:

using MLJ
using SymbolicRegression as SR

...
model = ...
mach = ...
...

# Get the tree:
r = report(mach)
tree = r.equations[r.best_idx]

# Get the transposed X:
X_t, _, _ = SR.MLJInterfaceModule.get_matrix_and_info(X, model.dimensions_type)

# Get options from mach:
options = mach.fitresult.options

# Use:
eval_grad_tree_array(tree, X_t, options; variable=true/false)  # or eval_diff_tree_array

But it would definitely nice if there was a function to pass …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by llamm-de
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
SymbolicRegression.jl SymbolicRegression.jl-related discussion
2 participants