LinAlgError:绘制趋势线时,SVD 没有以线性最小二乘法收敛?

发布于 2025-01-19 01:42:14 字数 481 浏览 3 评论 0原文

在使用下面的代码时,我尝试创建趋势线。散点图可以工作,但不断收到错误:“LinAlgError:SVD 没有在线性最小二乘中收敛”当我尝试使用趋势线时。我做错了什么?

代码:

import numpy as np

import matplotlib.pyplot as plt

from numpy import genfromtxt

data = genfromtxt("som.csv", delimiter=",")

tijd=data[:, 0]

afstand=data[:, 1]

plt.分散(tijd,afstand)

z = np.polyfit(tijd,afstand,2)

p = np.poly1d(z)

plt.plot(tijd,p(tijd),"r--")

我使用了以前使用过的类似数据的方法,但虽然它过去有效,但似乎不再有效。

While using the code below, im trying to create a trendline. The scattergraph works but is keep getting the error:"LinAlgError: SVD did not converge in Linear Least Squares" when i try to work with the trendline. What am i doing wrong?

code:

import numpy as np

import matplotlib.pyplot as plt

from numpy import genfromtxt

data = genfromtxt("som.csv", delimiter=",")

tijd=data[:, 0]

afstand=data[:, 1]

plt.scatter(tijd, afstand)

z = np.polyfit(tijd, afstand, 2)

p = np.poly1d(z)

plt.plot(tijd,p(tijd),"r--")

i used a method that i have used before with similar data, but while it worked in the past it no longer seems to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文