ndim python插值nonlin

2024-05-17 18:02:09 发布

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

我得到了一个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个值。 我想通过插值计算所有点的缺失值 而采用径向基函数的薄板将大受欢迎。有可能吗? 我在这里找到的信息 Python 4D linear interpolation on a rectangular grid 插值函数 但如果我用None替换数据数组中的某个值,此时f(point)给出“nan”。我不想使用线性插值,因为对于一组4个变量,我得到了2个有值的点。 非常感谢你帮助我


Tags: 文件csv函数importnumpyasnparray
1条回答
网友
1楼 · 发布于 2024-05-17 18:02:09

请尝试来自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个点已知,所以您对函数的信息很差。。。。在

相关问题 更多 >