如何加快scipy插值?

时间:2017-03-21 23:03:29

标签: python performance scipy interpolation

我正在使用scipy interpolate来找到准大数据帧(长度大约为240,000)的不同列的平滑近似值,然后找到间隔中点的斜率,如下所示:

tck = sc.interpolate.splrep(data['Time'], np.array(data[columname]), s=3)    
slope =sc.interpolate.splev(interval_midpoints_array, tck, der=1)

对于某些专栏而言,这种方法运作良好且速度非常快,但对于其他专栏而言,它需要很长一段时间(至少在我放弃前15-20分钟)。

我读到here单变量样条曲线具有NaN值的速度问题,但是我检查了数据框中没有NaN值。我也试过增加s值,但它对时间没有显着影响。

有没有办法加快插值?或者更好的近似这些斜率值的方法更快?我只是不耐烦吗?

有没有办法表征不同方法更快的数据集?

编辑:在

下面添加了一些示例数据
AT.data['Fast'][0:25]
0     0.9531
1     0.9536
2     0.9557
3     0.9578
4     0.9599
5     0.9625
6     0.9538
7     0.9143
8     0.9429
9     0.9773
10    0.9802
11    0.9831
12    0.9846
13    0.9849
14    0.9849
15    0.9826
16    0.9811
17    0.9791
18    0.9780
19    0.9773
20    0.9758
21    0.9752
22    0.9743
23    0.9737
24    0.9742
Name: Fast, dtype: float64

AT.data['Slow'][0:25]
0     105.1
1     105.1
2     105.1
3     105.1
4     105.1
5     105.1
6     105.1
7     105.0
8     105.0
9     105.0
10    105.0
11    105.0
12    105.0
13    105.0
14    104.9
15    104.9
16    104.9
17    104.8
18    104.8
19    104.8
20    104.8
21    104.7
22    104.7
23    104.7
24    104.7
Name: Slow, dtype: float64

0 个答案:

没有答案