docs: warning about ill conditioned hessian more detailed.

This commit is contained in:
Fabian Joswig 2022-05-25 15:20:31 +01:00
parent 967ddb0ecd
commit 48636fedb2

View file

@ -269,7 +269,8 @@ def total_least_squares(x, y, func, silent=False, **kwargs):
raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None
condn = np.linalg.cond(hess) condn = np.linalg.cond(hess)
if condn > 1e8: if condn > 1e8:
warnings.warn("Hessian matrix might be ill-conditioned ({0:1.2e}), error propagation might be unreliable.".format(condn), RuntimeWarning) warnings.warn("Hessian matrix might be ill-conditioned ({0:1.2e}), error propagation might be unreliable.\n \
Maybe try rescaling the problem such that all parameters are of O(1).".format(condn), RuntimeWarning)
try: try:
hess_inv = np.linalg.inv(hess) hess_inv = np.linalg.inv(hess)
except np.linalg.LinAlgError: except np.linalg.LinAlgError:
@ -556,7 +557,8 @@ def _standard_fit(x, y, func, silent=False, **kwargs):
raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None
condn = np.linalg.cond(hess) condn = np.linalg.cond(hess)
if condn > 1e8: if condn > 1e8:
warnings.warn("Hessian matrix might be ill-conditioned ({0:1.2e}), error propagation might be unreliable.".format(condn), RuntimeWarning) warnings.warn("Hessian matrix might be ill-conditioned ({0:1.2e}), error propagation might be unreliable.\n \
Maybe try rescaling the problem such that all parameters are of O(1).".format(condn), RuntimeWarning)
try: try:
hess_inv = np.linalg.inv(hess) hess_inv = np.linalg.inv(hess)
except np.linalg.LinAlgError: except np.linalg.LinAlgError: