# Confused about polynomial regression with multiple variables

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:

y=B0+B1*x0+...Bn*xn

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.

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
$$y=b_0+b_1*x_0^2+b_2*x_1^2+...b_n*x_n^2$$

If we want to add feature interaction,
$$y=b_0+b_1*x_0^2+b_2*x_1^2+b_3*x_0*x_1....$$

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

• Thanks, this is very helpful! Would you mind explaining what feature interaction is? Dec 8, 2020 at 17:20
• 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. Dec 9, 2020 at 10:30
• 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> ? Dec 9, 2020 at 11:55