Hello, all so in our previous session, we have gained some of the basic knowledge of what is a logistic
regression basics, why we don't have to use linear regression for the classification problem just because
of the drawbacks.
And these are exactly my both the drawbacks navigated by outliers.
And what if my probability will be greater than one and less than zero?
So in such case, I have to use this logistic regression.
So in the session we are going to discuss our four major cases and then I'm going to show you how you
can apply sigmoid on your linear regression best fit line to achieve your goal.
So let's say this is exactly my very first case.
And here these acts are my positive data points to hear.
My wife will be plus one for positive data points and the circle will be my negative returns.
And for this, my wife will be negative.
So in such case, if I were to consider all the data points out of this plane, I have a positive distance
and below this plane I have a negative distance.
That's what we have asserted in our previous session.
So we know it is the plane, if I have to consider next to this data point.
So we know this data point is above the plane.
So in such case, I have a positive way and in such case my distance, which is nothing but the blue
transpose.
Two x one, and it is also positive because it is above the plane, so if I'm going to do product of
both, which is nothing but why do W transport excellent.
So this will also be positive.
So whenever I have a case as where my Y is also positive, where my distance is also positive and the
product of both was also positive.
So in such case, my classification has happened correctly.
So it means this X data point has classified correctly by this a straight line.
So this is my correctly classified data point.
So I'm going to assume another case over here.
So this is my very first case and assuming I have a case to and in case to assume I am going to consider
this data point, which is exactly my negative point so far, this I have Y equals to minus one and
my distance is also negative because it is below the plane.
And if I am going to do multiplication or both, which is nothing but minus one into some negative number,
so it will also give me some positive value.
So since Y and distance, both are negative, but when I'm going to do multiplication of both.
So in such case my data point gets classified correctly.
So it means the circle data point is also gets correctly classified by this straight line.
So let me discuss my case number three in which I'm going to consider a negative data point.
Assume this one so far this my wife will be negative or I can say minus one, but my distance, which
is W transpose X will be positive because it is the plane.
So if I'm going to do multiplication of board, it will give me a negative value, which will directly
refers to it is incorrectly.
Classified data point, so that's what we have to deal with that in a similar case as you made, I have
a case number for over here.
So what exactly can be my case number four?
Suppose this is my data point.
Suppose this is actually my data point.
So for this, my life will be pleasant, but my distance will be negative because it is below the plane.
And if I want to do multiplication of board, it will give me a negative value, which will directly
refers to incorrectly classified data.
So anyhow, we have to deal with both of these cases.
The third one and the fourth one.
So if I have to define my cost function, I can see my cost function is nothing bad, but just a summation
of I close to one to end because I have any number of data points and that is nothing but a product
of this why which is assigned to each and every data point and nothing, just a distance of each and
every data point to its plane.
So that's nothing but DeBlois I could transport into exile.
Similarly, I have no idea why.
So this is nothing but my entire existence and this is a Y value which is assigned to each of the data
point.
So this is exactly my cost function, which I can say this is my optimizer.
So it should be as maximum as possible, so we have to make it as maximum.
So if I have to create a straight line or a best fit line, which linearly separate to this data point,
I have to make sure that the summation of all the points along with the distance should be maximum.
That's what we have to make sure.
So from this cost function, you will analyze this.
Why I will be constant and this axi which is nothing.
My data point is also constant.
So what exactly is waiting over here.
This.
Transpose this w I transport, which is officially assigned to my line, which is coefficient assigned
to my best foot line, so that is varying, which is actually a coefficient.
So it means I have to update this coefficient or I can say I have to update this rate in such a way
that it will maximize this summation.
And when I'm getting my maximum summation, then that line that will be termed as best fit line that
linearly classifies our classes.
So this is how my entire logic regression actually works.
So assuming I have this data points, so I have to draw a best fit line for my best line and let's say
this one or let's say this one as well.
And let's take this one as well so I can have here multiple best foodline, so what can be my best Quitline
actually?
So my best foot line will be that line, which is a maximum value of my optimizer.
And what exactly was optimizer?
That is nothing but I equals to one, two.
And this why I into w I transpose into exile so which our best client has this maximum value, that
best fit line will get selected for my prediction purpose.
So the optimizer that we have written over here is still there.
I have to update it assumed I have it in this much number of data points and if I have to draw a best
fit line, that is nothing but this one.
So this is that best fit line that can linearly separable both of these data points, both of the different
different classes.
But what if I have an outlier?
What do you suppose my outlier like to add here?
So what can be my best Quitline if I have outlined over here?
So let's say if I am going to consider the previous best fit line, which is this one, and if I am
going to consider, let's say, the distance between this one and distance between this one.
So this will be exactly where negative distance y because this data point will that close to my negative
data point and this cross data point will therefore do my positive data point.
And here my way is going to be negative one and here my view will be positive one.
So here in all the cases I have minus two and here in all the cases I have plus two.
So assume I'm going to assume as the distance between the straight line and data point is.
So here my tool will reward.
That is nothing but W transpose D into X.
So here if I'm going to consider this one distance, assuming if I'm going to consider this one, this
test, it will somewhere give me one hundred.
I'm just assuming.
So if you are going to do a summation of all these stuffs, you will see I have had minus eight so I'm
going to say minus it and here I have plus eight and here I have this one hundred.
So this will get cancer and this will give me one hundred.
So that's hundred.
Will, just on account of this outlier, this data point, which is exactly my outlier.
And if I am going to consider previous case in this case, this will be one minus eight and this will
be exactly where plus eight to in this case I have this one at zero.
So if I'm going to consider this one here, you will see I have highest fluctuation in data.
You will see this is just an account of that outlier that has presented over here, assuming I'm going
to consider the best flat line.
Let's this time I have this one best fit line.
So in such case, you can observe these all data points.
These circle data points will give me my negative distance and all these will give me my boster distance.
So these all will get canceled.
So this will be my exact distance, which is nothing but a negative distance.
So you will see whenever I'm going to change my best route line, how much fluctuation we are going
to observe using this best foot line.
So anyhow, we have to overcome this fluctuation, which is going to happen over here.
The simple answer is by just applying a function on this optimizer to what optimize that I was previously,
that is nothing but why I into this w transpose X and if I have multiple data points, I can do a summation
as well.
So this is exactly what means optimize it.
So I have to apply a function over here.
So what exactly was a function?
This function is nothing, but this is exactly my sigmoid function.
So we have to apply this sigmoid function on each of these value.
So after applying this function, it will convert this entire value.
You will see, let's say I'm going to assume it is Z, so whatever data point I have over here, so
any data point will give me my value in this form.
So whatever value it will return, I'm just going to send this value to my sigmoid function and what
this sigmoid will do.
It will.
What this exit is higher and let's say the value that it Willetton, let's say one hundred sixty Segway
will convert this Hyundai into a range of 021.
So that's what my segment will do.
And as I have very much fluctuation in the cost function value so we can prevent this using this signal.
So how exactly this sigma will prevent the sigmoid function is nothing but one up on one plus E to the
power mindset.
And this is exactly why that.
So we have to parse this, that here and this will convert this entire value between zero to one.
That's what my sigmoid will do.
So what segment will do?
Basically it will remove the effect of this outlier by just converting Heidelberg.
Let's say this high number one hundred into some range between zero to one.
So that's basically a task of this sigmoid function.
What we are going to use in my life is regression.
So our previous use case was.
Yeah, this one.
Yeah.
So in this case, you can observe this was exactly hundred.
So what we have to do very first, we have to parse this one hundred to my sigmoid function so I can
see over here.
So this will exactly give me some value between zero to one and my problem is solved.
That's what we are trying to achieve, using logistic regression.
That's what my sigmoid will do.
It will remove the impact of this outlier.
That's what I want to achieve.
So how exactly we achieve this as goal, which is mine, does take regression or whatever input or I
can say whatever output this linear regression will give.
Suppose it gives me one hundred.
So I'm just going to apply a sigmoid over this one hundred.
So once I will apply this sigmoid over this hundred using this formula, it will give me this kind of
code.
That's what logistic regression works internally.
So hope you love this in that induction of logistic regression.
Thank you.
Have a nice day.
Keep learning.
Keep going.
Keep practicing.