I'm trying to create a multivariable polynomial regression model from scratch but I'm getting kind of confused by how to structure it.

So, I have an array of feature vectors such that each vector can be displayed like so:

[height, weight, age]

I know with multivariable linear regression I would create an algorithm like so:


Where x0 would be the first element of each in the feature vector.

So for multiple variable polynomial regression would it go something like this:

y = B0+B1*x0+B2*x1**2+...Bn*Xn**d

Where d is the degree of the polynomial. Apologies if this is painstakingly obvious and formatted badly, I'm just a small bit lost.


1 Answer 1


Not exactly,
Polynomial regression means that the dataset is not linear and we have to transform it to a specific polynomial degree based on the dataset, so that we may map the Linear model

Decide a polynomial degree first, let's say 2

If we want to add feature interaction,

Basically, you have to implement this Class of Scikit-Learn

  • $\begingroup$ Thanks, this is very helpful! Would you mind explaining what feature interaction is? $\endgroup$ Commented Dec 8, 2020 at 17:20
  • $\begingroup$ I believe that the first order terms should also be included, e.g. for a polynomial of order $d=2$, assuming $p$ features and no interactions we need $2p$ terms. $\endgroup$ Commented Dec 9, 2020 at 10:30
  • $\begingroup$ With feature interactions, would this be the case of every possible permutation of the features multiplied together? Like in your example, you have the first two variables multiplied together, would you also have to include x<sub>0</sub> *x<sub>1</sub>*<sub>2</sub> ? $\endgroup$ Commented Dec 9, 2020 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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