Suppose we have a deep learning model which takes in chest x-ray images and gets the probability of the image being from a COVID patient. So how do we know and compare the performance of this model with other models which are doing the same thing. For this we have metrics like accuracy, precision, recall and area under the ROC curve. In today's video we will see how an ROC curve is plotted. Suppose we have our trained model which takes in a chest x-ray image and predicts the probability of the patient having COVID. So if we give it 6 chest x-ray images it will produce 6 probability values. And for each of these chest x-ray images we also know the ground truth. Ground truth of one means the image belongs to a COVID patient. While zero means it was a healthy person. But our model is not giving us any labels but only probability values. To convert these probability values to labels we need to have a rule. So while plotting ROC we check the model at multiple thresholds. So for example if the threshold is 0.9 any probability above or equal to 0.9 will be labeled as 1. In this case the first image is labeled 1 and the rest are labeled 0. This is the model's prediction at threshold 0.9. We check this prediction with the ground truth of the images which has been prepared by an experienced radiologist. From this prediction we find the total number of true positives and total number of false positives. So at threshold of 0.9 the model gives us 1 true positive and 0 false positive. Next we check the threshold for 0.84. In this the top 2 images are labeled 1 because their probability is more than or equal to 0.84 and then we find out the true positive and the false positive at this threshold. Similarly at threshold of 0.72 the top 3 images are predicted as label 1. The top 2 images being true positive but the third image is false positive. False positive because the predicted label was 1 while the ground truth was 0. At the threshold of 0.6 the true positive is 3 and false positive is 1. At threshold of 0.55 top 5 images are predicted as 1 and the last image is predicted 0. Again we find TPNFP. Similarly at threshold 0.42 all images are labeled 1 and we find the TPNFP. From the ground truth we also know that actual positives are 3 and actual negatives are 3. We will use these values to calculate the TPR and FPR. So to find TPR we divide the true positives by actual positives where actual positives is 3. For FPR we divide false positives by actual negatives where actual negative is 3. Using this formula we calculate the TPR and FPR of the model at various thresholds. This is all we require to plot an ROC curve. We plot each point 1 by 1 and then join them using straight lines. The area under this curve will give us the area under ROC or AU ROC. This will always be equal to or less than 1 because it lies inside the square of dimension 1 by 1. ROC curve can look like this or this. If it is jagged it has less number of samples. If it is smooth it has more number of samples or thresholds. If we have to compare two models the model which covers more area or whose AU ROC is more is considered better. When we plot ROCs in MATLAB we also get something known as model operating point. This is the threshold point at which the models give the best trade of between TPR and FPR. So I hope you understood the concept. If you have any doubts you can post them in the comments below.