Python:在UnivariateSplin中重新定义maxit

2024-03-28 11:42:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着用SciPy的平滑一元样条曲线

from scipy.interpolate import UnivariateSpline
spl = UnivariateSpline(x, y)

我得到了这个错误信息。在

/usr/lib/python3.5/site-packages/scipy/interpolate/fitpack2.py:222: UserWarning: The maximal number of iterations maxit (set to 20 by the program) allowed for finding a smoothing spline with fp=s has been reached: s too small. There is an approximation returned but the corresponding weighted sum of squared residuals does not satisfy the condition abs(fp-s)/s < tol. warnings.warn(message)

如何重新定义maxit参数?我在SciPy手册中找不到任何东西,除了它是类中的关键字scipy.odr.odr公司. 不过我运气不太好。在


Tags: ofthefromimportusrscipyspl曲线
1条回答
网友
1楼 · 发布于 2024-03-28 11:42:01

您不能更改此参数,它在FITPACK代码中已被修复:

https://github.com/scipy/scipy/blob/master/scipy/interpolate/fitpack/curfit.f#L220

原则上,您可以修改Fortran源代码并重新编译scipy,但这几乎肯定不是您想要的。相反,您可以使用单变量pline(或sprep)的s参数来查看给定数据xy是否有用。在

顺便说一句,ODR与此无关。在

相关问题 更多 >