Is there any way that we could get the Hessian matrix (so as to calculate the standard error) after getting the optimization result through scipy.minimize function?
The parameter of hessian in the minimize function seems to be input instead of an output.
from scipy import minimize
opt = minimize(logitfn, args=df, x0=x_start, method='Nelder-Mead')
Use 'L-BFGS-B' method, and then:
opt.hess_inv.todense()
Given a function f and initial point x0, and assuming we use L-BFGS-B, then the following code works:
opt = minimize(f, x0=x0, method='L-BFGS-B')
B = opt.hess_inv # LinearOperator object
B = B * np.identity(B.shape[1]) # numpy array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With