简体   繁体   English

LinAlgError:SVD 未在线性最小二乘 np.linalg.lstsq 中收敛

[英]LinAlgError: SVD did not converge in Linear Least Squares np.linalg.lstsq

I get the aforementioned error although I check that I have no missing or infinite values when trying to do linear regression with np.linalg.lstsq...Any thoughts?尽管我在尝试使用 np.linalg.lstsq 进行线性回归时检查是否没有缺失值或无限值,但我得到了上述错误......有什么想法吗? I do these regressions recursively and I printed the shape of X and Y and are always same but it raises the error in a specific iteration我递归地进行这些回归,我打印了 X 和 Y 的形状,并且总是相同,但它会在特定迭代中引发错误

---> 17             betas = np.linalg.lstsq(X,Y,rcond=None)[0]
     18 
     19             res = Y - X.dot(betas)

<__array_function__ internals> in lstsq(*args, **kwargs)

~\anaconda3\lib\site-packages\numpy\linalg\linalg.py in lstsq(a, b, rcond)
   2257         # lapack can't handle n_rhs = 0 - so allocate the array one larger in that axis
   2258         b = zeros(b.shape[:-2] + (m, n_rhs + 1), dtype=b.dtype)
-> 2259     x, resids, rank, s = gufunc(a, b, rcond, signature=signature, extobj=extobj)
   2260     if m == 0:
   2261         x[...] = 0

~\anaconda3\lib\site-packages\numpy\linalg\linalg.py in _raise_linalgerror_lstsq(err, flag)
    107 
    108 def _raise_linalgerror_lstsq(err, flag):
--> 109     raise LinAlgError("SVD did not converge in Linear Least Squares")
    110 
    111 def get_linalg_error_extobj(callback):

LinAlgError: SVD did not converge in Linear Least Squares

There are two most common reasons for this error.此错误有两个最常见的原因。 One is when you have infinity or NaNs present in your data.一种是当您的数据中存在无穷大或 NaN 时。 You say you check for those but do you check on each iteration or only in the original data?你说你检查那些但你检查每次迭代还是只检查原始数据?

If that is not the issue then the other possible problem is that a set of linear equations can have 1 solution (think like a point between two intersecting lines), but it can also have no solutions (for example, parallel lines) or infinite number of solutions (two lines on top of each other).如果这不是问题,那么另一个可能的问题是一组线性方程可以有一个解(就像两条相交线之间的一个点),但它也可以没有解(例如,平行线)或无限数解决方案(两条线相互重叠)。 The latter two situations should also trigger this error since the function cannot come up with a definitive answer.后两种情况也应该触发此错误,因为 function 无法得出明确的答案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 numpy.linalg.LinAlgError:SVD 仅在第一次运行时未收敛于线性最小二乘法 - numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares on first run only LinAlgError:尝试 polyfit 时 SVD 未在线性最小二乘中收敛 - LinAlgError: SVD did not converge in Linear Least Squares when trying polyfit Python - LinAlgError:SVD 没有收敛于线性最小二乘法 - 数据中没有 Nans 或 infs - Python - LinAlgError: SVD did not converge in Linear Least Squares - no Nans or infs in data Python statsmodels ARIMA LinAlgError:SVD 没有收敛 - Python statsmodels ARIMA LinAlgError: SVD did not converge LinAlgError:SVD未在matplotlib PCA中收敛 - LinAlgError: SVD did not converge in matplotlib PCA 为什么 torch.lstsq 的输出与 np.linalg.lstsq 截然不同? - Why is the output of torch.lstsq drastically different than np.linalg.lstsq? raise LinAlgError(&quot;SVD没有收敛&quot;) LinAlgError: SVD没有在matplotlib pca确定中收敛 - raise LinAlgError("SVD did not converge") LinAlgError: SVD did not converge in matplotlib pca determination np.linalg.lstsq(X,Y)[0] - TypeError: No loop match the specified signature and cast was found for ufunc lstsq_n - np.linalg.lstsq(X,Y)[0] - TypeError: No loop matching the specified signature and casting was found for ufunc lstsq_n 为什么interp1d抛出LinAlgError(“ SVD未收敛”)? - Why does interp1d throw LinAlgError(“SVD did not converge”)? 当张量流导入到 Keras 脚本时出现 LinAlgError(“SVD 没有收敛”) - Getting LinAlgError("SVD did not converge") when tensorflow imported to Keras skript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM