0

I have velocity data (mf) for a fluid at 5 axial locations (x) for 14 different combinations of two parameters of the fluid (Re, k). The velocity data is dependent on Re, k and x.

I would like to use sklearn to do polynomial regression of my data as in this post, but I am facing some problems:

  1. How should I build the X matrix (the matrix of the independent variables)? It seems to me that there are 3 independent variables here (Re, k and x) but I have 14 values of Re, 14 values of k and only 5 values for x.
  2. Would it be possible to regress with degree=1 w.r.t. Re and k and degree=3 w.r.t. x?

Any help is appreciated. Thanks!

Community
  • 1
  • 1
Zeno
  • 3
  • 1

1 Answers1

0

If you have three 2d array-like objects Re, k, and x, you can create polynomial features of degree=3 on just x, by applying the PolynomialFeatures transformer to just x before stacking the features into a single matrix.

poly_x = PolynomialFeatures(3)
X = np.hstack([Re, k, poly_x.fit_transform(x)])
David Maust
  • 8,080
  • 3
  • 32
  • 36