我正在为2D RBF插值编写代码,但面临奇点问题:
`提升LinAlgError('矩阵是单数。')
LinAlgError:Matrix是单数。
我有一个QR分解的想法来解决这个问题,但我不知道我应该在哪个代码处编写QR分解代码?我也删除了重复点!
import numpy as np
from scipy import interpolate
import pandas as pd
import xlsxwriter
#Read the Dataset from Excel File
dataset=pd.read_excel(r'C:\Users\Windows 10\.spyder-py3\Messwerte_FIBRE.xlsx')
dataset=dataset.drop([0])
dataset=dataset.drop_duplicates(subset=['T Heizstation','T GWK','P Presse','Bauteilverzug'])
index1=[1]
index2=[4]
index3=[5]
index4=[9]
x1=dataset.iloc[:, index1]
x2=dataset.iloc[:, index2]
x3=dataset.iloc[:, index3]
y=dataset.iloc[:, index4]
#converting string into array
x1np=np.array(x1,dtype=float)
x2np=np.array(x2,dtype=float)
x3np=np.array(x3,dtype=float)
ynp=np.array(y,dtype=float)
newfunc = interpolate.Rbf(x1np,x2np,x3np,ynp,function='linear')
estimation= newfunc(x1np,x2np,x3np)
estimation=np.array(estimation)
# Write the estimation output in Another Excel file
workbook = xlsxwriter.Workbook(r'C:\Users\Windows 10\.spyder-py3\RBF_Reg.xlsx')
worksheet = workbook.add_worksheet('est_output')
row=2
for outputverzug in enumerate(estimation):
worksheet.write(row,0,outputverzug[1])
row+=1
#for next column
row=2
for outputverzug in enumerate(ynp):
worksheet.write_column(row,1,outputverzug[1])
row+=1
worksheet.write(0,0,"Predicted Angle Values")
worksheet.write(1,0,"°")
worksheet.write(0,1,"Original Angle Values")
worksheet.write(1,1,"°")
worksheet.conditional_format('A2:A202', {'type': '3_color_scale',
'min_color': "#FF0000",
'max_color': "#00FF00"})
worksheet.conditional_format('B2:B202', {'type':'3_color_scale',
'min_color': "#00FF00",
'max_color': "#FF0000"})
workbook.close()
答案 0 :(得分:0)
对于具有重复项(或其他形式的冗余)的经验数据,使用平滑处理(而不是强制通过所有点进行插值)是合适的。 Rbf
有一个smooth
关键字参数,默认情况下为0,1.5对我有用。