2
$\begingroup$

Is there a way to carry out polynomial regression $x + x^2$ in H2O (Python)? What I have found about this is "interactions" option in GLM. However, I am not sure if this option yields polynomial regression as given here (link).

$\endgroup$

1 Answer 1

4
$\begingroup$

If you are willing to manually do the basis expansion, any package supports linear regression will support polynomial expansion.

When I say manual basis expansion I mean to create additional columns to your data. Suppose you have three data points are $x_1,x_2,x_3$, and the design matrix is

$$ \begin{bmatrix} 1&\ x_1 & x_1^2 \\ 1& x_2 & x_2^2\\ 1 &\ x_3 &x_3^2\end{bmatrix} $$

You can find more examples of the basis expansion here.

What's wrong to fit periodic data with polynomials?

PS: what I suggested is called raw polynomials, which is not a good idea from numerical stability view. Orthogonal polynomial would be much better, and details can be found in my answer here

$\endgroup$
1
  • 4
    $\begingroup$ Obligatory mention of natural cubic splines! $\endgroup$ Commented Jan 11, 2018 at 15:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.