简体   繁体   中英

n-dim python interpolation nonlinear

i got a function of 5 variables 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])

and 180 values of the function in a csv file. i would like to calculate missing value by interpolation in all points and use radial basis function thin_plate will by great. is it possible? for information i found here Python 4D linear interpolation on a rectangular grid InterpolatingFunction but if i replace some value in data array by None, at this point f(point) give 'nan'. and i don t want to use a linear interpolation because for a set of 4 variables i got 2 points with a value. thanks very much for helping LL

Try SVR from scikit-learn to solve your problem:

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]) 

Because of len(s)*len(m)*len(p)*len(h)*len(l) is 22680 and function values are known only in 180 points, you have poor information about your function....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM