用三次样条插值实现运行时警告

2024-09-27 09:23:35 发布

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

我必须开发一个数据监听函数,在这个函数中,我把熊猫数据帧中的数据集分成更小的部分,然后在那里插值一个三次样条曲线(在我的例子中是Z值)。为此,我使用了scipy中的interpolate.interp2d函数,然后从估计值中减去给定的高度值,得到残差,在这里我可以应用一个3西格玛阈值,并删除具有最高离群值的行。在

为了更好地理解,这里有一个带有离群值的数据集的3D图: enter image description here

但当我运行代码时,我会收到以下警告:

/home/mattes/anaconda3/lib/python3.6/site-packages/scipy/interpolate
/_fitpack_impl.py:976: RuntimeWarning: The maximal number of iterations 
(20) allowed for finding smoothing
spline with fp=s has been reached. Probable cause: s too small.
(abs(fp-s)/s>0.001)
    kx,ky=3,3 nx,ny=18,21 m=915 fp=221.198171 s=0.000000
 warnings.warn(RuntimeWarning(_iermess2[ierm][0] + _mess))

/home/mattes/anaconda3/lib/python3.6/site-packages/scipy/interpolate
/_fitpack_impl.py:976: RuntimeWarning: A theoretically impossible result 
when finding a smoothing spline
with fp = s. Probable causes: s too small or badly chosen eps.
(abs(fp-s)/s>0.001)
    kx,ky=3,3 nx,ny=19,22 m=914 fp=209.480429 s=0.000000
warnings.warn(RuntimeWarning(_iermess2[ierm][0] + _mess))

/home/mattes/anaconda3/lib/python3.6/site-packages/scipy/interpolate
/_fitpack_impl.py:976: RuntimeWarning: No more knots can be added because 
the number of B-spline
coefficients already exceeds the number of data points m.
Probable causes: either s or m too small. (fp>s)
    kx,ky=3,3 nx,ny=26,46 m=911 fp=158.754387 s=0.000000
warnings.warn(RuntimeWarning(_iermess2[ierm][0] + _mess))

这是我创建的代码:

^{pr2}$

我用sigme_size 3和step_size=50计算样条曲线时有足够的数据点。此外,除了消除了数据点之外,使用函数后,异常值仍然存在。在

有人知道如何解决这个问题吗?在

非常感谢!在


Tags: 数据函数pyhomelibpackagessitescipy

热门问题