numpy - using statsmodels in python for data-fitting -
i'm trying generate surface-fit model of 3d data-set.
3d data-set looks like(doesn't represent actual data, analogue):
x=[1.2, 1.3, 1.6, 2.5, 2,3, 2.8] y=[167.0, 180.3, 177.8,160.4,179.6, 154.3] z=[-0.3, -0.8, -0.75, -1.21, -1.65, -0.68] where, z varies randomly based on (x,y).
how can able generate fitted-surface model using statsmodels ?
i'm generating matrices code far:
data = np.c_[x,y,z] mn = np.min(data, axis=0) mx = np.max(data, axis=0) x,y = np.meshgrid(np.linspace(mn[0], mx[0], 20), np.linspace(mn[1], mx[1], 20)) xx = x.flatten() yy = y.flatten() any ideas on how can able achieve surface-fit highly appreciated.
thank you.
some things bit unclear question:
fit model? have idea process originated (say, 2d trigonometric function), don't know specific parameters?
in first example, dimensions don't quite fit, dimension of
zshould product of dimensions ofx,y.
having said that:
if have little knowledge of process, , use spline interpolation, use 1 of
scipy.interpolate's spline-fitters, e.g.,rectbivariatesplineif know shape of fitted function, don't know parameters, use
scipy.optimizeoptimize parameters, usingnumpy.linalg.normbuilding objective function minimize.that is, if think function of form *z = * x^3 - b x^2 + c*, optimize on vector [a, b, c]; @ each point of optimization, check *||z - (a * x^3 - b x^2 + c)||*.
Comments
Post a Comment