In this tutorial we will be talking about false positives and false negatives.
As you remember where we were using the logistic regression
function to observe where for random
values of the independent variable will end up in terms of y hat.
So in terms of the predicted value for the dependent variable,
and we agreed that anything below the 50% line
will be projected downwards onto the zero horizontal line, and anything above
the 50% line will be projected upwards onto the 100% horizontal line.
And that allowed us to turn probabilities into actual predictions.
So either yes or no.
Now let's take a step back.
Where did we get these four values from?
So we took four random values of the independent variable.
And we just had a look at what would happen to them.
How we can use how we would use the logistic regression function
to ascertain what's probability
they have and what y hat values they have.
So how about we take another step back and we forget
about these four random values.
And instead of taking four random values
of the independent variable, how about we take four known values.
In fact, let's take four values for the independent variable from our data set.
So let's just pick out four values that we really know that exist in our data set.
And we use them to create this logistic regression.
And let's do the same thing with them.
Let's see where they will end up if we apply the model to them.
And as you can see here, the label of the vertical axis change to Y
because this is the we already know that in red is the actual
value of the dependent variable, because we know the result, those,
the people on the bottom.
So observations number one and number three, they didn't take up the offer
the email offer and the observations.
on the top, people number two and four, they did take up the email offer.
So let's see what happens to them
if we apply our logistic regression model.
So step number one would be to project
these values onto the curve.
Makes sense right.
So we just want to see where they end up on the curve.
That's our blue dots over there.
That's where they have been modeled by the curve.
Now we can from here we can say what the probabilities are.
You just have to project to the left.
And you can see approximately that for observation number one,
it's, about maybe 20%, ten, 15%, maybe let's say 15%.
Observation number two, it's about 40% observation number three,
I would say about 70% observation and before about 85%.
But we're not interested in probabilities per se right now.
What we want to get to is the actual y hat.
We want to see what the predicted value will be.
So we want to say we want to see if the model will tell us,
are these people, going to take up the offer or not?
And why do we want to do this is because we already know the result, right?
We already know what the result will be, or was.
And we just want to see we want to kind of, assess the model.
We want to see how well it's working.
And, if it's going to make any mistakes.
So let's go
ahead and proceed with our logic for getting the y hat.
And what was the logic there?
Well, the same thing that we discussed just a few minutes ago
at the start of this tutorial.
Anything we're using this arbitrary horizontal line 50%.
So anything below this line is going to be projected
onto the horizontal line, which is zero.
So where we're saying that the offer is not going to be taken up
and anything above the 50% line will be projected
onto the horizontal line, which is 1 or 100%, where we're saying that
those people that end up on that line are definitely going to take up the offer.
So let's go ahead and do that.
There we go. In gray.
We have our projections or our predicted value.
So y hat is in gray.
And it's very interesting to see both y and y hat on one chart.
So that means what actually happened is in red.
And what we predicted was going to happen is in gray.
And right away you can see that for observations number one and number four.
So for those people in observation
number one, number four they we predicted correctly.
So we said for the person number one, we predicted that
he won't take up the offer.
And he actually did not take up the offer because the red,
mark is also on the same horizontal line.
Now for observation number four, same thing.
We predicted that
that person will take up the offer, and they did take up the offer.
That's good.
But now let's have a look at observation number two.
And number three you can see that
for observation number two the gray lines at the bottom,
the gray marks at the bottom, meaning that
the model is predicting for this person based on their gender, based on their age.
Well, in this case, just age, because we're doing a single,
variable logistic regression.
So based on their age, this model is saying that this person
is not going to take up the offer because the gray mark is at the bottom.
However, we can see that the red mark is at the top,
meaning that this person did take up the offer and that means
that the logistic regression made an error here.
And same thing for person number three.
The gray mark is at the top.
And that means that the model is predicting that the person will
will take up the offer.
But the red marks at the bottom, meaning that the person didn't actually
take up the offer and therefore the logistic regression made a mistake.
Once again.
And these mistakes, they actually have specific names.
So the top mistake over there is a false positive or a type one error.
What does false positive mean.
Well it means that we said we predicted a positive outcome.
But it was false.
So we were we predicted an effect that did not occur.
And the other mistake you see here has a different name.
It's called a false negative. So we predicted that
there won't be an effect.
But the effect actually did occur.
So our prediction was negative meaning there won't be an effect.
But it was a false negative.
And it's called a type two type of error.
And the way I personally remember them,
it's important also to distinguish between the two.
The way I personally remember them is, I think of type
one as less dangerous than type two.
So type type one is less, for me in my in my mind, although it's not
necessarily the case, but the way that's the way I remember them.
That type one is kind of like a warning.
So that's why there's an orange explanation, Mark.
And it's, it's a false positive.
So basically you said something is going to happen, but it didn't happen.
So you said maybe there'll be an earthquake,
but there wasn't an earthquake.
So, you know, that's not the end of the world.
But false negative is a bit worse in my once again understanding because,
once if you say something, it's not going to happen,
but it actually does happen, then you can't even be prepared for it.
And that's why type two is, false negative.
And that's how I remember them personally.
But once again, it could be absolutely.
they can both be pretty serious errors, especially when you are dealing
with, like medical conclusions and stuff like that.
So those are false positives and false negatives.
we will be using them more when we talk about
the confusion matrix in the next tutorial.
And I look forward to see you next time.
Until then, happy analyzing.