使用RBF

时间:2018-05-11 19:19:43

标签: arrays python-3.x numpy

 #1-d interpolation  

        import numpy as np  
        from scipy import interpolate  
        import pylab as py  
        import pandas as pd  

        #Read the Dataset from Excel File  
        def func(x1):  
            return x1*np.exp(-5.0*x1**2)  
        dataset=pd.read_excel('Messwerte_FIBRE1.xlsx')  
        dataset=dataset.drop([0])  
        index=[1]    
        index2=[9]  
        x=dataset.iloc[:, index]    
        y=dataset.iloc[:, index2]  
        x1=np.array(x,dtype=float)  
        y1=np.array(y,dtype=float)  
        fvals=func(x1)   
        xnew=np.linespace(430,490,800)   
        for kind in ['multiquadric','inverse multiquadric','gaussian',  
                     'linear','cubic','quintic','thin-plate']:  
        newfunc=interpolate.Rbf(x1,fvals,function=kind)    
        fnew=newfunc(xnew)  

我收到错误:
IndentationError:预期缩进块**
any1可以帮我固定吗?我试图从excel文件读取变量并使用RBF插值技术进行预测估计 我的excel文件如下所示,请点击它

Messwerte_FIBRE1.xlsx

1 个答案:

答案 0 :(得分:1)

就在这里,for循环要求代码在块中。

xnew=np.linespace(430,490,800)   
for kind in ['multiquadric','inverse multiquadric','gaussian',  
             'linear','cubic','quintic','thin-plate']: 
    #SOMETHING WOULD GO HERE    
newfunc=interpolate.Rbf(x1,fvals,function=kind)    
fnew=newfunc(xnew)