n-dim python插值非线性

时间:2013-12-15 13:29:30

标签: python scipy interpolation

我得到了5个变量Fx(s,m,p,h,l)

的函数
import numpy as np
s= np.arange(0,135,15)/10
m= np.array([150,180,195,210,240,255,270,285,300])
p=np.array([-1.5,-1,-0.5,0,0.5,1,1.5])
h=np.array([0,3,6,9,12])
l=np.array([0,0.5,1,1.5,2,2.5,3,4])

和csv文件中函数的180个值。 我想通过插值在所有点计算缺失值 并使用径向基函数thin_plate将很好。可能吗? 我在这里找到的信息 Python 4D linear interpolation on a rectangular grid InterpolatingFunction 但如果我将数据数组中的某些值替换为None,则此时f(点)给出'nan'。而且我不想使用线性插值,因为对于一组4个变量,我得到了2个带有值的点。 非常感谢帮助LL

1 个答案:

答案 0 :(得分:0)

尝试scikit-learn的SVR来解决您的问题:

from sklearn.svm import SVR # it uses RBF as default kernel
import numpy as np

n_samples, n_features = 180, 5

y = np.random.randn(n_samples)  #function values
X = np.random.randn(n_samples, n_features)   #points
clf = SVR(C=1.0, epsilon=0.2)
clf.fit(X, y)

#Get value at a new point:

clf.predict([0,150,-1.5,0,0]) 

由于len(s)* len(m)* len(p)* len(h)* len(l)是22680且函数值仅在180分中已知,因此您的函数信息很差。 ..

相关问题