For now, we have been showing you this binary accuracy, false positives up to the AUC.
What if we plot out the coefficient matrix and also the Rosie plot?
So we'll impart cycle, learn and seaborne.
Right here we have scikit learn and from scikit learn dot matrix, we are going to impart coefficient
metrics.
And then for Seaborn, we need to import Seaborn and SAS.
So that's it.
So yeah, we are importing I learn and Seaborn, which we'll both use in plotting out this confusion
matrix.
So let's run this and then we'll visualize our conversion metrics.
So we'll have to get the level that's the true values of one of the outputs, and then we'll also get
the predicted values.
So yeah, we want to get the labels and the predicted values.
Now let's start with the labels.
So yeah, we're going to have labels.
We have this list, there we go.
And then for X, Y, or let's say for, for x, Y in the test data set, we're going to take this as
non py iterator.
So for x, Y and this we have the x and the Y, we have that and then we append every output to this
labels.
So here we have labels that append y and we run that.
So that's fine.
We could now print out labels.
What do we get?
There we go.
You see, we have this labels.
Now let's convert it into a simpler form where we just have only this values in here and not this arrays
which we have here.
So in order to get that, we have labels will be equal labels or rather will be equal an array.
And in here we're going to create this list.
So in this list here, for every element of this labels list.
So for here, for I in labels, we are going to do I the zero.
Index.
So we're going to take always this element right here.
So that said, we have that and now we have levels.
Let's print out a levels after doing this transformation.
There we go.
Here is our levels now.
So we have that fine could take that off.
We have this error actually because we tried we've converted this levels already and then we're trying
to re convert them.
So let's command this right here.
We command that and run this and we have all levels.
OC Now we have those levels.
We could move ahead and get the predicted values.
So to get this predicted values, we have our low net model Loonette learned model.
There we go dot predict what are we going to pass in this predict method is our input.
So we have the input and then right here we add this input list and then we do same as we did with the
labels.
So we have input.
Then append X, which is this input here.
Now we run this and then let's add a cell.
So we add this code cell and then we're going to pre process our input.
So from this we're just going to print out the input to see what it gives us, what kind of shape we
are having right here.
Let's put non power array.
Wow, that's loading shape.
Then we run this.
All the cell right here is what we get as shape.
So we have to take this off, this one off here.
And to do that you see we would have the input will select this first index.
So we take that and then for this next we take only one.
So we're going to chop this off and then we have the rest.
So that's it.
Now we run this again and we should have put a shape here, so we run that again.
And there we go.
So this is what we expect.
Now we've gotten the labels and then we are now ready to get the predictions.
So here we have this input or take this and then we pass it in.
Here we pass our input and we get our predictions.
Let's print out the predicted here or yeah, let's print out a predicted and see what we get.
So what we get right here, we could print out a shape to better understand what this is.
And as you could see, we have this.
So how do we take this off or how do we make it look like the labels?
We could simply take this off.
So we have.
We select the first, and then for this one, we take it off.
So we run that again.
And there we go.
So now we could do this, take off the shape, and then it should look like the labels we've had here.
And that's it.
So now we've gotten this.
Our next step is to use the confusion matrix from circle and matrix and produce our conversion matrix.
Now let's comment this sections first so you will pass in the labels with pass in the predicted and
then we'll specifying this threshold.
So what we're seeing here is all the values greater than the threshold considered uninfected and all
values less than or equal.
The threshold is going to be considered as containing the parasite.
And then we're going to have this in this conversion matrix here.
So we run that.
And then as you could see, we have our coefficient matrix, which shows us the number of true positives,
true negatives, false positives and false negatives.
Getting back to our model evaluation, we'll see exactly which of those values are the true positives,
false positives, true negatives or false negatives.
So let's just copy this out.
Your if we take this up and we shall see that below.
So here we have this confusion matrix, which we've just seen here is it right here, confusion matrix
right here.
And then let's paste this out here.
So we have the number of true positives this one matches and then number of true negatives.
1298.
Yeah, this is closer.
So what cyclone gives us is quite similar to what we had with TensorFlow, but they're not exactly the
same.
So this tells us that this is a number of true negatives.
This is the number of no, this is the number of true negatives right here.
So here we have two negatives.
Here we have true positives.
Then here we have false positives and then here we have false negatives.
We'll then see how modifying this threshold will either reduce the false negatives or reduce the false
positives.
So let's have, say, 0.25 right here.
We run that again and there we go.
Let's print this.
So we see that we now have a number of false negatives reduced.
When we reduce this threshold, we now go back and then take this to 0.75.
We run that again.
You see that this is now reduced.
So here we have a reduced or an increased number of false negatives and a reduced number of false positives
when this threshold is increased to 0.75.
So that's it.
Let's now print out.
All right.
Let's now plot out this more elegantly looking figure with the Seaborn Library.
So here we go.
We run that and that's it.
So here we have our same conversion matrix, but more elegantly plotted.
Let's take it back to 0.5 here and have that.
Okay, so that's it.
Now, you notice that when we're trying to say reduce more false negatives or number of false positives,
what we're doing is we are just picking up some values here.
Like we could pick up 0.2 and then we see this effect and we could do the same for 0.25.
You see how this takes us to 58 and there's 230.
We could continue doing this until we get our best results.
But then this isn't very efficient since we just trying out different values.
Now, the way we could do this more efficiently is by working with our C plots where we'll be able to
choose a threshold in a more efficient manner using the plots.
And so we'll be able to reduce the number of false negatives or the number of false positives without
having to try out all this trash values manually.