What is going on everybody and welcome to part 7 of our machine learning with [python] tutorial series in this video?
We're going to be beginning to break down
linear Regression and
Begin to build it back up in pure python code from Scratch [Ourselves] before we get started
We have to kind of break down linear regression theoretically before we actually know what to to program by the time
We're [done] here you'll start to at least understand one
How linear regression can be threaded but also most importantly why it works with what's known as?
continuous Data this isn't
just a happenstance is just fundamental to how this linear regression actually works, so let's go ahead and
Cover a couple examples, so for let's say you've got a dataset
expert visualization by centex like this
Okay, so when you look at these data points. Do you see any sort of correlation?
well, probably you know you see a line that goes something like that, okay, and
Let's consider another Data set and this data set will do
Something like this not not the most professional
Dots, but you get the point right?
[so] you can see how you might draw a line through this
Right no problem and in theory this should be a straight line okay, but then what [about] a data set that looked like
Maybe a data set that looks like this
ignoring this ugly plot over here
right
This day set does it have a [best-fit] line?
Yes, does have correlation not
I mean it probably has some sort of correlation if anything that looks looks like it has a slight negative correlation, but
For the most part [I] mean you could draw a best-fit line, but would it be a good fit line?
Right any answer of course is is is no, okay?
so we can see right away that you know is there a relationship between
in our case x and y and
It doesn't look like there is [a] valid
Relationship between them so in the case where you don't have a relationship between x and y?
Doing something [like] linear regression is not going to be very beneficial and also
It's just clearly that like yes x could be in theory kind of continuous and y can be continuous data
But we just see there's no. There's really no [relationship] here okay, so this data just would not work with linear regression
so let's say though you do you've got [a] graph and
Um you've got some data okay, so we've got some data and you decide
Yeah, you sure you sure can do linear regression like like eyeballing it or something. We might say that
Okay, so so we have this line right this pink line. This is our best fit line
Right and it is a we'll assume. It's a straight line
What is the definition like how do you define that line?
well, I will take a journey back to
To middle school where we remember that y equals?
Mx plus
B, right
And obviously [we're] you know you've got your low values next to each other that they're being multiplied
So we know [that] the equation of a line is y equals Mx plus b. So at at any point along x?
right like let's say you've got some x at any point along x
you would just you you just plug x into here and
then you need the values of M and
be and then you will just get the answer for whatever why is
Okay, so with the question of y equals Mx plus
B we know that we'll be able to figure out whatever x is, but we are left trying to figure out
What is m and, what is b? So first let's talk about?
What m is so we know [m] is?
the [slope]
Alright, so [that's] the slope of the line and we know that b is
the
Y-intercePt
Okay, so first let's consider the slope so here
We're going to just address m which is our slope
so the equation for m is
For a best-fit. We're talking about just for a [best-fit] [line] here the way that you figure that out is m equals
[and]
This is going to be the mean of x times the mean of y
So when you have a straight line those are supposed to be straight lines. We have a straight line over the value
that's just that mean so x the mean of all the x's times the mean [of] all the y's
minus
the mean of
all the x's times the y's
[ok] so it's important to understand the difference between those first multiplication. That's [2nd] multiplication then it's all of that over
the mean of
your x's
squared
minus the mean
[of] your x's squared right, so this is the
the mean of all your x's to the power of 2 minus
The mean of x's to the power of 2 right, and that's all of your x's okay now. We're going to be talking about
the [sum]
the Y-intercept or the best-fit
Y-intercept, so [that's] just a
B eeee and
that is your
y-intercept, I'm just going to say why int and
this one is actually a much easier equation, and that is actually just simply [B] equals and
this is going to be the mean [of] the y's
minus M
times the mean of the xs
Right so that m is you know from?
Over there, so that's how you calculate the m and the b. So again the line is simply
Y
equals Mx
plus
B
We have our m here we've got to be here
so now you're ready to go with the the
Calculation of the [best-fit] line given any x's and y's now again. This is simply on you know
[two-dimensional] Data as you as you increase in [your] dimensions in vector space this can get much more complex
[but] yes, whereas this is very simple regression example, so anyways
that's the math that goes behind it it just [basically] boils down to
you know this is the major algorithm that you're using and to find the values you're using this algorithm in this algorithm, and
That can be very simply translated to python code
So that's what we're going to be starting [to] do in the next tutorial is converting these
Actually python code and then applying it to some actual
Some actual data here, so if you have any questions comments concerns
Whatever leave them below otherwise as always thanks for watching thanks [for] all the support and subscriptions and until next time