python多自变量拟合函数_如何用两组自变量拟合数据

下面是一个Python3示例,它使用您的函数处理测试数据。这使用scipy.optimize.curve U拟合()进行多元回归,建立了三维数据散点图、拟合函数的三维曲面图和拟合函数的等值线图。注意,我使用默认的scipy初始参数进行曲线拟合。在import numpy, scipy, scipy.optimize

import matplotlib

from mpl_toolkits.mplot3d import Axes3D

from matplotlib import cm # to colormap 3D surfaces from blue to red

import matplotlib.pyplot as plt

graphWidth = 800 # units are pixels

graphHeight = 600 # units are pixels

# 3D contour plot lines

numberOfContourLines = 16

def SurfacePlot(func, data, fittedParameters):

f = plt.figure(figsize=(graphWidth/100.0, graphHeight/100.0), dpi=100)

matplotlib.pyplot.grid(True)

axes = Axes3D(f)

x_data = data[0]

y_data = data[1]

z_data = data[2]

xModel = numpy.linspace(min(x_data), max(x_data), 20)

yModel = numpy.linspace(min(y_dat

你可能感兴趣的:(python多自变量拟合函数)