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 z should product of dimensions of x , y.

having said that:

  • if have little knowledge of process, , use spline interpolation, use 1 of scipy.interpolate's spline-fitters, e.g., rectbivariatespline

  • if know shape of fitted function, don't know parameters, use scipy.optimize optimize parameters, using numpy.linalg.norm building 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

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -