Now, let's take a look at generating our classification report using PyTorch, so this might seem a
bit trickier and a bit more difficult than it's done with Keros, and that's mainly because when we
get our predictions out of it, it's basically in a PyTorch tensor.
So we have to convert it back to an umpire so that we can use it with Skillings confusion matrix.
So to do that, we have to create some blank tenses here.
So we created by doing it touched on zeros so that zero here.
And we just said the type.
And we also said we could setting it, sending it to the CPU.
That's because we want to convert it to an umpire afterward.
So this is fine.
This is the labels.
And so this is a prediction list and this is to leave a list here.
And the reason why we want boards is because we want to get the ground truth tables here and prediction
labels here.
So this should be standard.
Now, if you if you should be familiar with this, we take our test loader, we loop through it, we
get the inputs, we get the classes, send it to the device.
I call this previously images and labels previously.
So just remember that then passage to the network, get the outputs, get to Preds here and then this
list here.
What we do, we basically we use tau shortcut.
That's a concatenated.
That's how we append the results inside of this loop.
And we just use Preds Dot View minus one is in brackets here to the CPU, and this is how we converted
to that non-priority.
And basically, we can extract it here.
Well, it's not an emperor yet, but it's just in a format that can be converted to an umpire quite
easily.
So we just use towards Starkman Cat to a touch to a cat.
Sorry to concatenate our results here.
And then when we want to use it into the confusion matrix, we can just simply apply the display to
extensive file here.
Tottenham pay to convert it into an umpire to generate our results.
So let's take a look at this and do we do we get a cool confusion matrix here that we did previously
with Cass?
No.
Just in case you forgot, this is how you analyze the confusion matrix.
So you can interpret the results better.
And again, similarly, we have a fancy plot for a confusion matrix where we didn't go through this
could.
But I'll go through the results here so you can see we have target names, which is zero to nine.
We have a confusion matrix that we got from the output previously and target names, and we just actually
we didn't run the function above.
So remember to run the function above here and now we can run this block of good loops to generate our
nice, nicely plotted, colorful confusion matrix here.
And also, we can look at output class accuracy using exactly the same thing, but we did previously
with Keros.
That's that's mainly because we're using the output of the confusion matrix here.
And so we can run this and get the accuracy for each class.
And you can see this model is performing quite well, much better than our Keros model that we trained
before.
And now we can take a look at over classification report, which is again quite simple as well.
We just load it imported from ASCII with Matrix here, the classification report.
We take the labels to ground truth labels converted to Nampai.
Take the prediction list with the NumPy, and that's basically it, and we can run that code and get
the results right here so we could get a precision or recall o f one o support, which is a total number
of classes or overall accuracy, as well as a macro average and a weighted average as well, which isn't
really that important to look at.
I didn't mention this previously.
However, it gets me to look at accuracy right here.
OK.
And this is a summary of how you interpret the recall.
The precision, as well as some notes on what I recall with precision means and what low recall and
high precision means as well.
So that's it for this lesson, and I hope you enjoyed this analysis with pathos and Keros and the next
lessons, we're going to take a look at overfitting and generalization.
This should help you understand what we look for when we train neural networks.
So thank you and I'll see you in the next lesson.
But.