{"id":2794,"date":"2024-10-07T20:17:46","date_gmt":"2024-10-07T11:17:46","guid":{"rendered":"https:\/\/secondlife.lol\/?p=2794"},"modified":"2024-10-07T18:33:39","modified_gmt":"2024-10-07T09:33:39","slug":"confusion-matrix-visualization-with-ggplot2","status":"publish","type":"post","link":"https:\/\/secondlife.lol\/zh\/confusion-matrix-visualization-with-ggplot2\/","title":{"rendered":"\u5982\u4f55\u7528 ggplot2 \u53ef\u89c6\u5316\u6df7\u6dc6\u77e9\u9635"},"content":{"rendered":"<p class=\"wp-block-paragraph\">\u6570\u636e\u5206\u6790 <strong><a href=\"https:\/\/ailib.secondlife.lol\/understanding-confusion-matrix\/\">\u6df7\u6dc6\u77e9\u9635<\/a><\/strong>\u662f\u8bc4\u4f30\u5206\u7c7b\u6a21\u578b\u6027\u80fd\u7684\u91cd\u8981\u5de5\u5177\u3002 \u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 R \u7684 <a href=\"https:\/\/cran.r-project.org\/package=ggplot2\" target=\"_blank\" rel=\"noopener\"><strong>ggplot2<\/strong> \u5957\u9910<\/a>\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u5c06\u6df7\u6dc6\u77e9\u9635\u53ef\u89c6\u5316\uff0c\u4ee5\u53ca\u5982\u4f55\u5c06\u6df7\u6dc6\u77e9\u9635\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u53ef\u89c6\u5316\uff0c\u4f7f\u5176\u66f4\u5bb9\u6613\u7406\u89e3\u3002<\/p>\n\n\n<style>.kb-image2794_66ca1a-3d .kb-image-has-overlay:after{opacity:0.3;border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;}.kb-image2794_66ca1a-3d img.kb-img, .kb-image2794_66ca1a-3d .kb-img img{border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;box-shadow:0px 0px 14px 0px rgba(0, 0, 0, 0.2);}<\/style>\n<div class=\"wp-block-kadence-image kb-image2794_66ca1a-3d\"><figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"1200\" height=\"649\" src=\"https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/image-17.jpg\" alt=\"\ud63c\ub3d9\ud589\ub82c \uc2dc\uac01\ud654 \uadf8\ub9bc\" class=\"kb-img wp-image-2795\" srcset=\"https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/image-17.jpg 1200w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/image-17-300x162.jpg 300w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/image-17-600x325.jpg 600w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/image-17-768x415.jpg 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><figcaption>(\u7528 ggplot2 \u53ef\u89c6\u5316\u6df7\u6dc6\u77e9\u9635\uff09<\/figcaption><\/figure><\/div>\n\n\n<style>.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-content-wrap{padding-top:var(--global-kb-spacing-sm, 1.5rem);padding-right:var(--global-kb-spacing-sm, 1.5rem);padding-bottom:var(--global-kb-spacing-sm, 1.5rem);padding-left:var(--global-kb-spacing-sm, 1.5rem);border-top:3px solid var(--global-palette2, #2B6CB0);border-right:3px solid var(--global-palette2, #2B6CB0);border-bottom:3px solid var(--global-palette2, #2B6CB0);border-left:3px solid var(--global-palette2, #2B6CB0);border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;box-shadow:0px 0px 14px 0px rgba(0, 0, 0, 0.2);}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-contents-title-wrap{padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-contents-title-wrap{color:var(--global-palette2, #2B6CB0);}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-contents-title{color:var(--global-palette2, #2B6CB0);font-size:28px;font-weight:regular;font-style:normal;}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-content-wrap .kb-table-of-content-list{color:var(--global-palette1, #3182CE);line-height:2em;font-weight:regular;font-style:normal;margin-top:var(--global-kb-spacing-sm, 1.5rem);margin-right:0px;margin-bottom:0px;margin-left:0px;}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-content-wrap .kb-table-of-content-list .kb-table-of-contents__entry:hover{color:var(--global-palette6, #718096);}@media all and (max-width: 1024px){.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-content-wrap{border-top:3px solid var(--global-palette2, #2B6CB0);border-right:3px solid var(--global-palette2, #2B6CB0);border-bottom:3px solid var(--global-palette2, #2B6CB0);border-left:3px solid var(--global-palette2, #2B6CB0);}}@media all and (max-width: 1024px){.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-contents-title{font-size:28px;}}@media all and (max-width: 767px){.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-content-wrap{border-top:3px solid var(--global-palette2, #2B6CB0);border-right:3px solid var(--global-palette2, #2B6CB0);border-bottom:3px solid var(--global-palette2, #2B6CB0);border-left:3px solid var(--global-palette2, #2B6CB0);}.kb-table-of-content-nav.kb-table-of-content-id83_5f28a6-34 .kb-table-of-contents-title{font-size:28px;}}<\/style>\n\n\n<h2 class=\"wp-block-heading\">\u7528 ggplot2 \u53ef\u89c6\u5316\u6df7\u6dc6\u77e9\u9635<\/h2>\n\n\n<style>.kb-image2794_52a69e-df .kb-image-has-overlay:after{opacity:0.3;border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;}.kb-image2794_52a69e-df img.kb-img, .kb-image2794_52a69e-df .kb-img img{border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px;box-shadow:0px 0px 14px 0px rgba(0, 0, 0, 0.2);}<\/style>\n<div class=\"wp-block-kadence-image kb-image2794_52a69e-df\"><figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"1200\" height=\"474\" src=\"https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/image-1-8.jpg\" alt=\"\ud63c\ub3d9\ud589\ub82c \uc2dc\uac01\ud654 \uac1c\uc694 \uadf8\ub9bc\" class=\"kb-img wp-image-2960\" srcset=\"https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/image-1-8.jpg 1200w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/image-1-8-300x119.jpg 300w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/image-1-8-600x237.jpg 600w, https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/image-1-8-768x303.jpg 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><figcaption>(\u6df7\u6dc6\u77e9\u9635\u53ef\u89c6\u5316\u6982\u8ff0\uff09<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u662f <strong>ggplot2<\/strong>\u662f R \u4e2d\u6700\u53d7\u6b22\u8fce\u7684\u53ef\u89c6\u5316\u5e93\u4e4b\u4e00\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u76f4\u89c2\u7684\u65b9\u6cd5\u6765\u8868\u793a\u6df7\u6dc6\u77e9\u9635\u3002\u4e0b\u9762\u7684\u4ee3\u7801\u4ee5\u6570\u636e\u5e27\u7684\u5f62\u5f0f\u521b\u5efa\u4e86\u4e00\u4e2a\u6df7\u6dc6\u77e9\u9635\uff0c\u5e76\u5c06\u5176\u7ed8\u5236\u6210\u4e00\u4e2a <strong>ggplot2<\/strong>\u6765\u9010\u6b65\u5b9e\u73b0\u6df7\u6dc6\u77e9\u9635\u7684\u53ef\u89c6\u5316\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u52a0\u8f7d\u6240\u9700\u7684\u5e93<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u5c06\u6df7\u6dc6\u77e9\u9635\u53ef\u89c6\u5316\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u52a0\u8f7d ggplot2 \u5e93\u3002ggplot2 \u662f R \u4e2d\u8bb8\u591a\u53ef\u89c6\u5316\u5de5\u5177\u7684\u5fc5\u5907\u5de5\u5177\uff0c\u4e5f\u662f\u521b\u5efa\u76f4\u89c2\u3001\u65f6\u5c1a\u56fe\u8868\u7684\u5f3a\u5927\u5de5\u5177\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u52a0\u8f7d # \u5148\u51b3\u6761\u4ef6\u5e93\nlibrary(ggplot2)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u751f\u6210\u6df7\u6dc6\u77e9\u9635\u6570\u636e<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee3\u8868\u6df7\u6dc6\u77e9\u9635\u7684\u6570\u636e\u5b58\u50a8\u5728 <strong>\u6570\u636e\u6846<\/strong>\u6765\u521b\u5efa\u6df7\u6dc6\u77e9\u9635\u3002\u8bbe\u7f6e\u9884\u6d4b\u503c\u548c\u771f\u5b9e\u503c\uff0c\u5e76\u4e3a\u6df7\u6dc6\u77e9\u9635\u4e2d\u7684\u6bcf\u4e2a\u6761\u76ee\u6dfb\u52a0\u6807\u7b7e\uff08TP\u3001FP\u3001FN\u3001TN\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u521b\u5efa\u8868\u793a # \u6df7\u6dc6\u77e9\u9635\u7684\u6570\u636e\u5e27\nconfusion_data &lt;- data.frame(\n  Predicted = factor(c(&quot;Y&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;N&quot;), levels = c(&quot;N&quot;, &quot;Y&quot;)), # Predicted\uff1a\u8bbe\u7f6e N \u548c Y \u6c34\u5e73\uff08N \u5728\u4e0b\uff09\u3002\n  \u5b9e\u9645 = factor(c(&quot;Y&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;), levels = c(&quot;Y&quot;, &quot;N&quot;)), # \u5b9e\u9645\uff1a\u8bbe\u7f6e Y \u548c N \u7684\u6c34\u5e73\uff08Y \u5728\u5de6\u4fa7\uff09\n  \u6807\u7b7e = c(&quot;\u771f\u9633\u6027 (TP)&quot;\u3001&quot;\u5047\u9633\u6027 (FP)&quot;\u3001&quot;\u5047\u9634\u6027 (FN)&quot;\u3001&quot;\u771f\u9634\u6027 (TN)&quot;)  # \u6bcf\u4e2a\u9879\u76ee\u7684\u6807\u7b7e\n)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4ee3\u7801 \u63cf\u8ff0<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u9884\u6d4b<\/strong> \u5217\u662f\u6a21\u578b\u9884\u6d4b\u7684\u503c\u3002\u8fd9\u91cc\u7684 <code>Y<\/code>\u548c <code>N<\/code>\u5176\u4e2d Y \u4e3a\u6b63\u6570\uff0cN \u4e3a\u8d1f\u6570\u3002<\/li>\n\n\n\n<li><strong>\u5b9e\u9645<\/strong> \u5217\u662f\u5b9e\u9645\u503c\uff0c\u800c <code>Y<\/code>\u548c <code>N<\/code>\u4ee5\u4f7f\u7528<\/li>\n\n\n\n<li><strong>\u6807\u7b7e<\/strong>\u662f\u6df7\u6dc6\u77e9\u9635\u4e2d\u6bcf\u4e2a\u6761\u76ee\u5bf9\u5e94\u7684\u6807\u7b7e\uff0c\u5206\u522b\u8868\u793a TP\uff08\u771f\u9633\u6027\uff09\u3001FP\uff08\u5047\u9633\u6027\uff09\u3001FN\uff08\u5047\u9634\u6027\uff09\u3001TN\uff08\u771f\u9634\u6027\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u7528 ggplot2 \u53ef\u89c6\u5316\u6df7\u6dc6\u77e9\u9635<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u4f7f\u7528 ggplot2 \u5c06\u6df7\u6dc6\u77e9\u9635\u53ef\u89c6\u5316\u3002 <strong>geom_<\/strong>\u94fa\u74e6\u7247<strong>()<\/strong>\u5c06\u6bcf\u4e2a\u9879\u76ee\u8868\u793a\u4e3a\u4e00\u5757\u74f7\u7816\uff0c\u5e76\u4e3a\u6bcf\u5757\u74f7\u7816\u6dfb\u52a0\u6587\u672c\u6807\u7b7e\uff08TP\u3001FP\u3001FN\u3001TN\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u4f7f\u7528 ggplot2 \u76f4\u89c2\u663e\u793a\u6df7\u6dc6\u77e9\u9635\nggplot(confusion_data, aes(x = \u5b9e\u9645\u6570\u636e\uff0cy = \u9884\u6d4b\u6570\u636e)) +\n  geom_tile(fill = \"lightblue\", color = \"black\", width = 1, height = 1) + # \u521b\u5efa\u78c1\u8d34\uff0c\u8bbe\u7f6e\u989c\u8272\u548c\u8fb9\u6846\n  geom_text(aes(label = \u6807\u7b7e), size = 5) + # \u4e3a\u78c1\u8d34\u6dfb\u52a0\u6587\u672c\u6807\u7b7e\n  labs(title = \"\u6df7\u6dc6\u77e9\u9635\", subtitle = \"\u5b9e\u9645\uff08\u53c2\u8003\uff09\") + # \u6dfb\u52a0\u6807\u9898\u548c\u526f\u6807\u9898\n  scale_x_discrete(position = \"top\") + # \u5c06 X \u8f74\u6807\u7b7e\u7f6e\u4e8e\u9876\u90e8\n  theme_minimal() + # \u8bbe\u7f6e\u6781\u7b80\u4e3b\u9898\n  \u4e3b\u9898(\n    plot.title = element_text(hjust = 0.5, size = 16, face = \"bold\", margin = margin(b = 10)), # \u8bbe\u7f6e\u6807\u9898\n    plot.subtitle = element_text(hjust = 0.5, size = 12, face = \"bold\", margin = margin(b = 20)), # \u8bbe\u7f6e\u526f\u6807\u9898\n    axis.title.x = element_blank(), # \u79fb\u9664 x \u8f74\u6807\u9898\n    axis.title.y = element_text(size = 12, face = \"bold\", margin = margin(r = 20)), # \u8bbe\u7f6e Y \u8f74\u6807\u9898\n    axis.text.x = element_text(size = 12, face = \"bold\", margin = margin(b = 10)), # \u8bbe\u7f6e x \u8f74\u6807\u7b7e\n    axis.text.y = element_text(size = 12, face = \"bold\"), # \u8bbe\u7f6e Y \u8f74\u6807\u7b7e\n    panel.grid = element_blank()\uff0c# \u5220\u9664\u7f51\u683c\n    axis.ticks = element_blank(), # \u79fb\u9664\u8f74\u523b\u5ea6\u7ebf\n    plot.margin = margin(t = 50, b = 40) # \u8bbe\u7f6e margin\n  )<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4ee3\u7801 \u63cf\u8ff0<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>geom_tile()<\/strong>\u5c06\u6df7\u6dc6\u77e9\u9635\u4e2d\u7684\u6bcf\u4e2a\u6761\u76ee\u7ed8\u5236\u6210\u4e00\u4e2a\u56fe\u5757\u3002\u74e6\u7247\u7684\u989c\u8272\u8bbe\u4e3a\u6d45\u84dd\u8272\uff0c\u8fb9\u6846\u8bbe\u4e3a\u9ed1\u8272\u3002<\/li>\n\n\n\n<li><strong>geom_text()<\/strong>\u663e\u793a\u6df7\u6dc6\u77e9\u9635\u7684\u6807\u7b7e\uff08TP\u3001FP\u3001FN\u3001TN\uff09\u3002<\/li>\n\n\n\n<li><strong>\u5b9e\u9a8c\u5ba4()<\/strong>\u6807\u9898\u548c\u526f\u6807\u9898\uff1a\u8bbe\u7f6e\u6807\u9898\u548c\u526f\u6807\u9898\u3002\u5728\u526f\u6807\u9898\u4e2d\u6dfb\u52a0 \"\u5b9e\u9645\uff08\u53c2\u8003\uff09\"\uff0c\u8868\u793a\u5b9e\u9645\u503c\u662f\u53c2\u8003\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>theme_minimal()<\/strong>\u5c06\u80cc\u666f\u8bbe\u4e3a\u767d\u8272\uff0c\u5e76\u5220\u9664\u4e0d\u5fc5\u8981\u7684\u5143\u7d20\u4ee5\u7b80\u5316\u56fe\u8868\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u5c06\u7ed3\u679c\u53ef\u89c6\u5316\u5e76\u8bbe\u7f6e\u56fe\u8868\u6837\u5f0f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6df7\u6dc6\u77e9\u9635\u7684\u53ef\u89c6\u5316\u6548\u679c\u4e0e\u6587\u7ae0\u5f00\u5934\u7684\u6548\u679c\u7c7b\u4f3c\u3002\u4ee5\u5e73\u94fa\u683c\u5f0f\u663e\u793a\u7684\u6bcf\u4e2a\u6761\u76ee\u90fd\u6709\u4e00\u4e2a <strong>\u771f\u6b63\u7684\u79ef\u6781<\/strong>, <strong>\u5047\u9633\u6027<\/strong>, <strong>\u5047\u9634\u6027<\/strong>, <strong>\u771f\u9634\u6027<\/strong>\u4ee5\u5e2e\u52a9\u60a8\u7406\u89e3\u6df7\u6dc6\u77e9\u9635\u7684\u542b\u4e49\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6700\u7ec8\u5b8c\u6574\u4ee3\u7801<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\u52a0\u8f7d # \u5148\u51b3\u6761\u4ef6\u5e93\nlibrary(ggplot2)\n\n\u521b\u5efa\u8868\u793a # \u6df7\u6dc6\u77e9\u9635\u7684\u6570\u636e\u6846\nconfusion_data &lt;- data.frame(\n  Predicted = factor(c(&quot;Y&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;N&quot;), levels = c(&quot;N&quot;, &quot;Y&quot;)), # predicted: set N and Y levels (N is below)\n  \u5b9e\u9645 = factor(c(&quot;Y&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;), levels = c(&quot;Y&quot;, &quot;N&quot;)), # \u5b9e\u9645\uff1a\u8bbe\u7f6e Y \u548c N \u7684\u6c34\u5e73\uff08Y \u5728\u4e0a\uff09\n  \u6807\u7b7e = c(&quot;\u771f\u9633\u6027 (TP)&quot;\u3001&quot;\u5047\u9633\u6027 (FP)&quot;\u3001&quot;\u5047\u9634\u6027 (FN)&quot;\u3001&quot;\u771f\u9634\u6027 (TN)&quot;)  # \u6bcf\u4e2a\u9879\u76ee\u7684\u6807\u7b7e\n)\n\n# \u4f7f\u7528 ggplot2 \u76f4\u89c2\u663e\u793a\u6df7\u6dc6\u77e9\u9635\nggplot(confusion_data, aes(x = \u5b9e\u9645\u6570\u636e\uff0cy = \u9884\u6d4b\u6570\u636e)) +\n  geom_tile(fill = &quot;lightblue&quot;, color = &quot;black&quot;, width = 1, height = 1) +\n  geom_text(aes(label = \u6807\u7b7e), size = 5) +\n  labs(title = &quot;Confusion Matrix&quot;, subtitle = &quot;Actual (Reference)&quot;) +\n  scale_x_discrete(position = &quot;top&quot;) +\n  theme_minimal() +\n  \u4e3b\u9898(\n    plot.title = element_text(hjust = 0.5, size = 16, face = &quot;bold&quot;, margin = margin(b = 10))\u3001\n    plot.subtitle = element_text(hjust = 0.5, size = 12, face = &quot;bold&quot;, margin = margin(b = 20))\u3001\n    axis.title.x = element_blank()\u3001\n    axis.title.y = element_text\uff08size = 12\uff0cface = &quot;\u9ed1\u4f53&quot;\uff0cmargin = margin(r = 20)\uff09\u3001\n    axis.text.x = element_text(size = 12, face = &quot;bold&quot;, margin = margin(b = 10))\u3001\n    axis.text.y = element_text(size = 12, face = &quot;bold&quot;)\u3001\n    panel.grid = element_blank()\u3001\n    axis.ticks = element_blank()\u3001\n    plot.margin = margin(t = 50, b = 40)\n  )<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u672c\u5e16\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 R \u7684 ggplot2 \u521b\u5efa\u4e00\u4e2a <strong>\u6df7\u6dc6\u77e9\u9635<\/strong> \u60a8\u5df2\u7ecf\u5b66\u4f1a\u4e86\u5982\u4f55\u5c06\u5176\u53ef\u89c6\u5316\u3002\u6df7\u6dc6\u77e9\u9635\u662f\u8bc4\u4f30\u5206\u7c7b\u6a21\u578b\u6027\u80fd\u7684\u91cd\u8981\u5de5\u5177\uff0c\u901a\u8fc7\u76f4\u89c2\u5730\u8868\u793a\u6bcf\u4e2a\u6761\u76ee\u7684\u542b\u4e49\uff08TP\u3001FP\u3001FN\u3001TN\uff09\uff0c\u53ef\u4ee5\u8f7b\u677e\u4e86\u89e3\u6a21\u578b\u7684\u51c6\u786e\u6027\u3002\u8fd9\u79cd\u65b9\u6cd5\u4f7f\u6df7\u6dc6\u77e9\u9635\u7684\u5206\u6790\u66f4\u52a0\u76f4\u89c2\uff0c\u800c\u4e14\u53ef\u4ee5\u5e94\u7528\u4e8e\u5404\u79cd\u6570\u636e\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u7406\u89e3\u6df7\u6dc6\u77e9\u9635\u5728\u5b9e\u8df5\u4e2d\u7684\u610f\u4e49\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528 <a href=\"https:\/\/secondlife.lol\/zh\/r-%eb%8d%b0%ec%9d%b4%ed%84%b0%eb%b6%84%ec%84%9d-%ec%98%88%ec%a0%9c-%eb%b6%93%ea%bd%83-iris-%eb%8d%b0%ec%9d%b4%ed%84%b0%ec%85%8b%ec%9c%bc%eb%a1%9c-%eb%b0%b0%ec%9a%b0%eb%8a%94-%eb%b6%84%eb%a5%98\/\" data-type=\"post\" data-id=\"2785\">R \u6570\u636e\u5206\u6790\u793a\u4f8b\uff1a\u5229\u7528 Iris \u8679\u819c\u6570\u636e\u96c6\u5b66\u4e60\u5206\u7c7b\u548c\u53ef\u89c6\u5316<\/a> \u67e5\u770b\u5e16\u5b50\u3002\u60a8\u5c31\u4f1a\u660e\u767d\u6211\u4eec\u6240\u8bf4\u7684\u68c0\u67e5\u6a21\u578b\u6027\u80fd\u662f\u4ec0\u4e48\u610f\u601d\uff0c\u5305\u62ec\u51c6\u786e\u6027\u3001\u53ec\u56de\u7387\u7b49\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u5728\u6570\u636e\u5206\u6790\u4e2d\uff0c\u6df7\u6dc6\u77e9\u9635\u662f\u8bc4\u4f30\u5206\u7c7b\u6a21\u578b\u6027\u80fd\u7684\u91cd\u8981\u90e8\u5206...<\/p>","protected":false},"author":3,"featured_media":2962,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6],"tags":[328,176,174,327,164,224,209,326,329],"class_list":["post-2794","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r-coding","tag-false-positive","tag-ggplot2","tag-r-","tag-true-positive","tag-164","tag-224","tag-209","tag-326","tag-329"],"taxonomy_info":{"category":[{"value":6,"label":"\uc54c(R)"}],"post_tag":[{"value":328,"label":"False Positive"},{"value":176,"label":"ggplot2"},{"value":174,"label":"R \ud504\ub85c\uadf8\ub798\ubc0d"},{"value":327,"label":"True Positive"},{"value":164,"label":"\ub370\uc774\ud130 \uc2dc\uac01\ud654"},{"value":224,"label":"\uba38\uc2e0\ub7ec\ub2dd"},{"value":209,"label":"\ubd84\ub958 \ubaa8\ub378"},{"value":326,"label":"\ud63c\ub3d9 \ud589\ub82c"},{"value":329,"label":"\ud63c\ub3d9 \ud589\ub82c \uc2dc\uac01\ud654"}]},"featured_image_src_large":["https:\/\/secondlife.lol\/wp-content\/uploads\/2024\/10\/\ud63c\ub3d9\ud589\ub82c-\uc2dc\uac01\ud654-\ud3ec\uc2a4\ud2b8-\uc378\ub124\uc77c-1-600x600.jpg",600,600,true],"author_info":{"display_name":"TERE","author_link":"https:\/\/secondlife.lol\/zh\/author\/tere\/"},"comment_info":0,"category_info":[{"term_id":6,"name":"\uc54c(R)","slug":"r-coding","term_group":0,"term_taxonomy_id":6,"taxonomy":"category","description":"","parent":20,"count":61,"filter":"raw","cat_ID":6,"category_count":61,"category_description":"","cat_name":"\uc54c(R)","category_nicename":"r-coding","category_parent":20}],"tag_info":[{"term_id":328,"name":"False Positive","slug":"false-positive","term_group":0,"term_taxonomy_id":328,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":176,"name":"ggplot2","slug":"ggplot2","term_group":0,"term_taxonomy_id":176,"taxonomy":"post_tag","description":"","parent":0,"count":15,"filter":"raw"},{"term_id":174,"name":"R \ud504\ub85c\uadf8\ub798\ubc0d","slug":"r-%ed%94%84%eb%a1%9c%ea%b7%b8%eb%9e%98%eb%b0%8d","term_group":0,"term_taxonomy_id":174,"taxonomy":"post_tag","description":"","parent":0,"count":15,"filter":"raw"},{"term_id":327,"name":"True Positive","slug":"true-positive","term_group":0,"term_taxonomy_id":327,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":164,"name":"\ub370\uc774\ud130 \uc2dc\uac01\ud654","slug":"%eb%8d%b0%ec%9d%b4%ed%84%b0-%ec%8b%9c%ea%b0%81%ed%99%94","term_group":0,"term_taxonomy_id":164,"taxonomy":"post_tag","description":"","parent":0,"count":52,"filter":"raw"},{"term_id":224,"name":"\uba38\uc2e0\ub7ec\ub2dd","slug":"%eb%a8%b8%ec%8b%a0%eb%9f%ac%eb%8b%9d","term_group":0,"term_taxonomy_id":224,"taxonomy":"post_tag","description":"","parent":0,"count":7,"filter":"raw"},{"term_id":209,"name":"\ubd84\ub958 \ubaa8\ub378","slug":"%eb%b6%84%eb%a5%98-%eb%aa%a8%eb%8d%b8","term_group":0,"term_taxonomy_id":209,"taxonomy":"post_tag","description":"","parent":0,"count":2,"filter":"raw"},{"term_id":326,"name":"\ud63c\ub3d9 \ud589\ub82c","slug":"%ed%98%bc%eb%8f%99-%ed%96%89%eb%a0%ac","term_group":0,"term_taxonomy_id":326,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":329,"name":"\ud63c\ub3d9 \ud589\ub82c \uc2dc\uac01\ud654","slug":"%ed%98%bc%eb%8f%99-%ed%96%89%eb%a0%ac-%ec%8b%9c%ea%b0%81%ed%99%94","term_group":0,"term_taxonomy_id":329,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"}],"_links":{"self":[{"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/posts\/2794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/comments?post=2794"}],"version-history":[{"count":9,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/posts\/2794\/revisions"}],"predecessor-version":[{"id":2963,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/posts\/2794\/revisions\/2963"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/media\/2962"}],"wp:attachment":[{"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/media?parent=2794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/categories?post=2794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/secondlife.lol\/zh\/wp-json\/wp\/v2\/tags?post=2794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}