{"id":2387,"date":"2019-07-22T06:39:09","date_gmt":"2019-07-22T06:39:09","guid":{"rendered":"https:\/\/www.aiproblog.com\/index.php\/2019\/07\/22\/comparing-model-evaluation-techniques-part-2-classification-and-clustering\/"},"modified":"2019-07-22T06:39:09","modified_gmt":"2019-07-22T06:39:09","slug":"comparing-model-evaluation-techniques-part-2-classification-and-clustering","status":"publish","type":"post","link":"https:\/\/www.aiproblog.com\/index.php\/2019\/07\/22\/comparing-model-evaluation-techniques-part-2-classification-and-clustering\/","title":{"rendered":"Comparing Model Evaluation Techniques Part 2: Classification and Clustering"},"content":{"rendered":"<p>Author: Stephanie Glen<\/p>\n<div>\n<p>In\u00a0<a href=\"https:\/\/www.datasciencecentral.com\/profiles\/blogs\/comparing-model-evaluation-techniques\" target=\"_blank\" rel=\"noopener noreferrer\">part 1<\/a>, I compared a few model evaluation techniques that fall under the umbrella of &#8216;general statistical tools and tests&#8217;. Here in Part 2 I compare three of the more popular model evaluation techniques for classification and clustering: <a href=\"https:\/\/www.statisticshowto.datasciencecentral.com\/confusion-matrix\/\" target=\"_blank\" rel=\"noopener noreferrer\">confusion matrix<\/a>, gain and lift chart, and <a href=\"https:\/\/www.statisticshowto.datasciencecentral.com\/receiver-operating-characteristic-roc-curve\/\" target=\"_blank\" rel=\"noopener noreferrer\">ROC curve<\/a>. The main difference between the three techniques is that each focuses on a different type of result:<\/p>\n<ul>\n<li>Confusion matrix:\u00a0false positives, false negatives, true positives and true negatives.<\/li>\n<li>Gain and lift: focus is on true positives.<\/li>\n<li>ROC curve: focus on t<span>rue positives vs. false positives.<\/span><\/li>\n<\/ul>\n<p>That said, you&#8217;ll want to choose a method that gives you the answers you need for the particular field you&#8217;re in. For example, while a confusion matrix can be a great tool for comparing models, it isn&#8217;t much good for marketing decisions (where the gain and lift chart would be a better choice).<\/p>\n<p>Other less popular (but still valid) tools include the <a href=\"https:\/\/www.statisticshowto.datasciencecentral.com\/kolmogorov-smirnov-test\/\" target=\"_blank\" rel=\"noopener noreferrer\">K-S chart<\/a>\u00a0and <a href=\"https:\/\/www.statisticshowto.datasciencecentral.com\/gini-coefficient\/\" target=\"_blank\" rel=\"noopener noreferrer\">Gini Coefficient<\/a>.<\/p>\n<h2>Confusion Matrix<\/h2>\n<p>A confusion matrix, in predictive analytics, shows the rate of false positives, false negatives, true positives and true negatives for a test or predictor. In machine learning, a confusion matrix can be used to show how well a classification model performs on a set of test data. <a href=\"https:\/\/storage.ning.com\/topology\/rest\/1.0\/file\/get\/3368678704?profile=original\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/storage.ning.com\/topology\/rest\/1.0\/file\/get\/3368678704?profile=RESIZE_710x\" class=\"align-full\"><\/a><\/p>\n<p>Correctly assigned values appear in their relative diagonal box:<\/p>\n<ul>\n<li>Negative values are correctly classified as negative (box a)<\/li>\n<li>Positive values are correctly classified as positive (box d)<\/li>\n<\/ul>\n<p>Wrongly assigned observations are labeled as either false positives (box b) or false negatives (box c).<\/p>\n<ul>\n<li>The<span>\u00a0<\/span><strong>false positive rate<\/strong>, or proportion of negative cases (incorrectly) identified as positive, is calculated with the equation\u00a0 fpr = b\/(a + b).<\/li>\n<li>The<span>\u00a0<\/span><strong>false negative rate<\/strong><span>\u00a0<\/span>tells us what proportion of positive cases were incorrectly labeled as negative. The equation is\u00a0fnr = c\/(c + d).<\/li>\n<li>The overall\u00a0<strong><a href=\"https:\/\/www.statisticshowto.datasciencecentral.com\/accuracy-and-precision\/\">accuracy<\/a><\/strong>\u00a0of the prediction or test is defined as (a + d)\/(a + c + d + e).<\/li>\n<\/ul>\n<h2>Gain and Lift Charts<\/h2>\n<p>Confusion matrices can give you a good idea about how effective your model is. It can also help you choose between multiple competing models.But <strong>sometimes you want to know how a particular model does with more data<\/strong>; For example, does a model perform better with 60% of data, compared to 50%? This is where gain and lift charts come in.<\/p>\n<p>The following gains chart, run on a validation set, shows that with 50% of the data, the model contains 90% of targets, Adding more data adds a negligible increase in the percentage of targets included in the model.<\/p>\n<p><a href=\"https:\/\/storage.ning.com\/topology\/rest\/1.0\/file\/get\/3368728184?profile=original\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/storage.ning.com\/topology\/rest\/1.0\/file\/get\/3368728184?profile=RESIZE_710x\" class=\"align-full\"><\/a><\/p>\n<p>A lift chart shows you how much better your model performs, compared to random selection. The &#8220;lift&#8221; is the ratio of results with and without the model; Better models have higher lifts.<\/p>\n<p>While the confusion matrix gives proportions between all negatives and positives, <strong>Gain and lift charts focus on the true positives.<\/strong> One of their most common uses is in marketing, to decide if a prospective client is worth calling.<\/p>\n<p><strong>Gain and lift charts work with a sample<\/strong> (a fraction of the population). In comparison, a\u00a0confusion matrix uses the whole population to evaluate a model.<\/p>\n<h2>ROC Curve<\/h2>\n<p><span>A\u00a0<a href=\"https:\/\/www.statisticshowto.datasciencecentral.com\/receiver-operating-characteristic-roc-curve\/\" target=\"_blank\" rel=\"noopener noreferrer\">Receiver Operating Characteristic (ROC) Curve<\/a> is a way to compare models. It is a plot of the\u00a0<\/span><a href=\"https:\/\/www.statisticshowto.datasciencecentral.com\/sensitivity-vs-specificity-statistics\/#SEN\">true positive rate<\/a><span>\u00a0against the\u00a0<\/span><a href=\"https:\/\/www.statisticshowto.datasciencecentral.com\/false-positive-definition-and-examples\/\">false positive rate<\/a><span>.\u00a0 It&#8217;s similar to the gain and lift chart, but instead\u00a0of just true positives, this time the focus is on a graphical representation of true positives vs. false positives.<\/span><\/p>\n<p><span><a href=\"https:\/\/storage.ning.com\/topology\/rest\/1.0\/file\/get\/3368760528?profile=original\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/storage.ning.com\/topology\/rest\/1.0\/file\/get\/3368760528?profile=RESIZE_710x\" class=\"align-full\"><\/a><\/span><\/p>\n<p><span>In layman&#8217;s terms, the closer the graph is to the top and left borders, the more accurate the model. If you&#8217;e familiar with calculus (specifically, areas under the curve), the ideal model has an area of 1; a random model (with a 50%) chance is shown with the black diagonal on the graph. Also shown on the above example; two models in blue and red. The blue line represents a more accurate model as it is closer to the top and left borders.\u00a0<\/span><\/p>\n<h2>References<\/h2>\n<p><a href=\"https:\/\/www.datasciencecentral.com\/profiles\/blogs\/7-important-model-evaluation-error-metrics-everyone-should-know\" target=\"_blank\" rel=\"noopener noreferrer\">11 Important Model Evaluation Techniques Everyone Should Know<\/a><\/p>\n<p><a href=\"http:\/\/www.simafore.com\/blog\/bid\/57175\/How-to-evaluate-classification-models-for-business-analytics-Part-1\" id=\"hubspot-name\" class=\"link hubspot-editable\" name=\"hubspot-name\"><span id=\"hs_cos_wrapper_name\" class=\"hs_cos_wrapper hs_cos_wrapper_meta_field hs_cos_wrapper_type_text\">How to evaluate classification models for business analytics &#8211; Part 1<\/span><\/a><\/p>\n<p><span class=\"hs_cos_wrapper hs_cos_wrapper_meta_field hs_cos_wrapper_type_text\"><a href=\"https:\/\/towardsdatascience.com\/how-to-determine-the-best-model-6b9c584d0db4\" target=\"_blank\" rel=\"noopener noreferrer\">How to determine the best model?<\/a><\/span><\/p>\n<\/div>\n<p><a href=\"https:\/\/www.datasciencecentral.com\/xn\/detail\/6448529:BlogPost:859317\">Go to Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Author: Stephanie Glen In\u00a0part 1, I compared a few model evaluation techniques that fall under the umbrella of &#8216;general statistical tools and tests&#8217;. Here in [&hellip;] <span class=\"read-more-link\"><a class=\"read-more\" href=\"https:\/\/www.aiproblog.com\/index.php\/2019\/07\/22\/comparing-model-evaluation-techniques-part-2-classification-and-clustering\/\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":470,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[26],"tags":[],"_links":{"self":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2387"}],"collection":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=2387"}],"version-history":[{"count":0,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2387\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media\/462"}],"wp:attachment":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=2387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=2387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=2387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}