{"id":1924,"date":"2019-05-25T12:00:00","date_gmt":"2019-05-25T10:00:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/basics-of-receiver-operating-characteristics-roc-curve\/"},"modified":"2026-07-05T03:23:33","modified_gmt":"2026-07-05T01:23:33","slug":"basics-of-receiver-operating-characteristics-roc-curve","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/basics-of-receiver-operating-characteristics-roc-curve\/","title":{"rendered":"Basics of Receiver Operating Characteristics (ROC) Curve"},"content":{"rendered":"<p>A Receiver Operating Characteristics (ROC) Curve is used to describe the trade-off between correct classifications and wrong classifications.<\/p>\n<p>The ROC curve displays a plot of the True Positive (TP) against the False Positive (FP).<\/p>\n<p>The performance of a classifier is represented as a point in the curve.<\/p>\n<p>The total performance of a classifier is summarized over all possible threshold in the curve. The overall performance is given by area under the curve (AUC).<\/p>\n<p>A high-performing model will have an ROC that will pass close to the upper left side of the curve and provide a large area under it. This is shown in Figure 1.<\/p>\n<figure id=\"attachment_925\" aria-describedby=\"caption-attachment-925\" style=\"width: 530px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-925\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/ROC-Curve.jpg\" alt=\"ROC Curve\" width=\"530\" height=\"361\" \/><figcaption id=\"caption-attachment-925\" class=\"wp-caption-text\">Figure 1: ROC Curve<\/figcaption><\/figure>\n<p>So we can see that the larger the AUC, the better the classifier will be.<\/p>\n<p>For the classifier in Figure 1, the AUC is about 0.85 which is close to 1 and therefore would be considered to be a very good classifier.<\/p>\n<p>A classifier with an AUC of 0.5(the blue line in Figure 1) is considered to be a &#8216;no-information&#8217; or probabilistic classifier.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Specificity and Sensitivity<\/strong><\/p>\n<p>Adjusting the classifier threshold also changes the true positive rate (TPR) and the false positive rate (FPR). The true positive rate is known as the <strong>sensitivity<\/strong> of the classifier. It measures the proportion of times the classifier correctly classified the positive classes.<\/p>\n<p>One minus the Sensitivity (1-sensitivity) is known as the Specificity. This is the same as the True Negative Rate. It is a measure of how many time the classifier correctly classified a negative class.<\/p>\n<p>We would now take an example.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>How to Construct an ROC Curve<\/strong><\/p>\n<p>We would use a classifier that classifies 10 observations as either positive or negative.\u00a0 This is shown in Table 1.<\/p>\n<p>It performs the classification by producing the posterior probability of the class (+ or -) given the observation. That is\u00a0 P(+ | A) where A is the observation.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_926\" aria-describedby=\"caption-attachment-926\" style=\"width: 266px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-926 size-medium\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/ROC-Table-266x300.jpg\" alt=\"ROC Table\" width=\"266\" height=\"300\" \/><figcaption id=\"caption-attachment-926\" class=\"wp-caption-text\">Table 1: ROC Output for 10 Observations<\/figcaption><\/figure>\n<p><em>From Table 1:<\/em><\/p>\n<p>For observation 1, the P(+|A) is 0.95. This means the classifier correctly classifies it. Same for observation 2. But for observation 3, the classifier wrongly classifier it as it classified it as + with P(+|A) of 0.85. Same with observation 4 and 5 and so on.<\/p>\n<p>Now for observation 10, it give a P(+|A) of 0.25, hence it correctly classifies it.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Steps in construction an ROC curve<\/strong><\/p>\n<ul>\n<li>Begin with a classifier that gives the posterior probability for each observation P(+|A)<\/li>\n<li>Sort the observations in descending order of their P(+|A)<\/li>\n<li>Apply some threshold at each unique value of P(+|A)<\/li>\n<li>Count the number of TP, FP, TN and FN at each threshold<\/li>\n<li>Calculate the True Positive Rate TPR = TP\/(TP+FN)<\/li>\n<li>Calculate the False Positive Rate FPR = FP\/(FP + TN)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A Receiver Operating Characteristics (ROC) Curve is used to describe the trade-off between correct classifications and wrong classifications. The ROC curve displays a plot of &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[414],"tags":[],"class_list":["post-1924","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1924","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=1924"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1924\/revisions"}],"predecessor-version":[{"id":2092,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1924\/revisions\/2092"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=1924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=1924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=1924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}