gpt4 book ai didi

Python:在 UnivariateSpline 中重新定义 maxit

转载 作者:行者123 更新时间:2023-12-01 03:36:02 28 4
gpt4 key购买 nike

我尝试使用 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.odr.ODR 类中的关键字之外,我在 SciPy 手册中找不到任何内容。不过我运气不太好。

最佳答案

您无法更改此参数,它已在 FITPACK 代码深处修复:

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

原则上,您可以修改 Fortran 源代码并重新编译 scipy,但这几乎肯定不是您想要做的。相反,您可以使用 UnivariateSpline(或 splrep)的 s 参数来查看在给定数据 x 的情况下是否获得有用的信息y.

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

关于Python:在 UnivariateSpline 中重新定义 maxit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40385040/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com