Polynomial Linear Regression

y=b0+b1.x1+b2.x12+....+bn.x1n

Example Use of Polynomial Regression: Can be used to describe how pandemics and epidemics spread across territory or across population.

Linear Term is still used. This is because, linear is not in terms of the power of the IVs. Linear here is used to define if we can define y in a linear combination of the co-efficients.

Importing the libraries

Importing the dataset

If I am a manager at Level 4, and I have been working as a manager for 4 years, then my salary will be higher than the base manager salary and lower than the country manager salary (Level 5). It will be something like Level 4.5. To get the salary for position 4.5, we will need a polynomial regression, because the salary won't increase linearly.

Training the Linear Regression model on the whole dataset

Training the Polynomial Regression model on the whole dataset

We will create a new matrix, with the polynomial x1 terms and then apply Multiple Linear Regression to it.

Visualising the Linear Regression results

Visualising the Polynomial Regression results

Visualising the Polynomial Regression results (for higher resolution and smoother curve)

n = 3

n = 4

For smoother plot

Predicting a new result with Linear Regression

Predicting a new result with Polynomial Regression