## POLYNOMIAL REGRESSION

into it we already know a couple of

types of regressions we know the simple

linear regression which we can see over

here then we've also discussed the

multiple linear regression which is

written out over here and finally we've

got the polynomial linear regression

which is written out here so notice how

it's very similar to the multiple linear

regression but at the same time instead

of the different variables like X 2 X 3

X 4 and so on xn we have the same

variable X 1 but it is in different

powers so instead of X 2 we have X 1

squared instead of X 3 would have X 1

cubed and so instead of xn we would have

X 1 to the power of n so basically we're

using one variable but we're using the

different powers or that variable so

let's have a look at when you use a

polynomial regression where it would

come in handy let's say we've got a

observation as several generations we

show various then the line that fits

this data is obviously as simple linear

regression as you can see it fits fits

it quite well but let's for a change say

that the data set look at something like

this so if we try to use a simple linear

regression here which is expressed like

that you'll see that it doesn't fit

quite well so in the middle you've got

data underneath and then as you go

further the data will be above the line

so how can we correct it well we can try

to correct that by using a polynomial a

regression let's have a look so instead

of the linear regression we're going to

conduct a polynomial regression and that

in this case fits perfectly and what is

the formula well that is a formula for

this particular case y equals B 0 so

that's the constant plus b1x 1 so that's

a simple linear regression part but then

we're adding the B to x1 squared and the

B to x1 squared gives it's that

parabolic effect or that the curve

becomes parabolic and therefore it will

fit this data better

as you can see polynomial regression is

a bit different to simple in your

regression and at the same time it has

its own use case so it's all incomes on

a case by case basis you you have a

problem and then you might try a simple

linear regression a multiple linear

regression if you have many variables or

you might try a polynomial

linear regression and see what happens

and sometimes the polynomial regressions

do work better for example they're used

to describe how diseases spread or

pandemics and epidemics spread across

territory or across population

polynomial linear regressions can be

handy there and they also have other use

cases so it's a matter of what works

best so it's always good to have more

tools in your arsenal and we have one

final question left the question is why

is it called linear still right so we

saw those different powers squared cubed

to the power of n and so on why is it

still called meteor and I'll show you

what I mean if you look on the left here

it says polynomial linear regression so

why is it still called a linear

regression if it's a polynomial

regression well the trick here is that

when we're talking about linear and

nonlinear we're not actually talking

about the X variables right so even

though they're nonlinear here the

relationship between y and X is

nonlinear when you're talking about the

class of a regression you're talking so

whether it's linear or nonlinear you're

talking about the coefficients here so

that's the interesting part so whether

or not this function which we have here

so Y is a function of X right and so the

question is can this function be

expressed as a linear combination of

these coefficients that because

ultimately they are the unknowns right

so is your goal when you're building a

regression is to find these coefficients

find out their actual values so that

then further down the track you can use

those coefficients to then plug in X and

predict Y whether it's a linear and

while I sing a simple linear multiple

linear regression or polynomial in

regression that's your goal to find

these B coefficients and that's why

linear nonlinear refers to the

coefficients so an example of a

nonlinear regression would be if the

equation was y equals B 0 plus B 1 X 1

divided by B 2 plus X 2 or something

that or B 0 divided by B 1 plus X 1 so a

situation where you really cannot

replace the coefficients with other

coefficients to turn the equation into a

linear one in regard

to the coefficients not the x-values so

there you go that's why polynomial

regression is still called a linear

regression that's your fun fact for the

day maybe you can show off to your

colleagues and also because of that the

polynomial linear regression is actually

a special case of the multiple linear

regression so that's just something to

also kind of note that this is a version

of the multiple linear regression rather

than a standalone absolutely new type of

regression so I hope you enjoyed today's

tutorial and I look forward to seeing

you next time until then enjoy machine

learning