title: How do perform polynomial features and linear regression on 3 dimensional data (x,y,z)?
body: <p>I need help performing polynomial features on 3 dimensional data and performing linear regression to create a line of best fit on the 3 dimensional polynomial.</p>
  <p>I have a random dataframe with x, y, and z as the columns that forms a polynomial scatterplot.
  X and Y are similar values while z is vastly different.
  Example:</p>
  <pre><code>X=(-3,9,-20,-8,-14)
  Y=(-2,8,-19,-8,-13)
  Z=(-960,110,4867,-149,1493)
  </code></pre>
  <p>I have done this for 2 dimensional data but not 3d.</p>
  <pre><code>poly=PolynomialFeatures(degree=2,include_bias=False)
  X_poly=poly.fit_transform(X.reshape(-1,1)) 
  X_poly[0]
  </code></pre>
  <p>However, how do I handle the data when I have x, y, and z? Do I need to perform poly.fit_transform x and y?</p>
  <p>Next I did linear regression</p>
  <pre><code>from sklearn.linear_model import LinearRegression
  
  LinReg = LinearRegression()
  LinReg.fit(X_poly,z)
  </code></pre>
  <p>Then when I create test data for x and y and perform the predict method on z, the resulting line is linear instead of a polynomial.</p>
  <p>Any help would be much appreciated.</p>