For a function that maps a named tuple to another named tuple, is it possible to get a named Jacobian?
Either as a named range or a DataFrame with 3 columns: Input_Var, Output_Var, Derivative
I could take the ForwardDiff.jacobian output and do something like
DataFrame( hcat( input_variable_names, Jacobian ), output_variable_names )
but it would be nice to have the names attached automatically.
Maybe see if NamedArrays
works with ForwardDiff?
What I do though is use a custom struct to store what I need for a model, then write functions to convert from struct to vector and back again. All the optimization happens with vectors and I convert back to the struct as quickly as possible.
Thanks Peter. That’s roughly what I’m doing with the line above. Converting the Jacobian Matrix to a more structured DataFrame.
Hope you had a good Christmas and New Years:)
f(x) = 2x[1,1] + 3x[2,2]
d = DataFrame( A = [0.0,0.0], B = [0.0,0.0] )
M = Matrix( d )
FiniteDiff.finite_difference_gradient!( M, f, M )
Given that I can set values in a DataFrame like this d[:,:] = M
Could FiniteDiff be enhanced to allow the output to be taken from and written into the DataFrame? e.g.
FiniteDiff.finite_difference_gradient!( d[:,:], f, d )