{"id":319,"date":"2024-03-08T20:23:55","date_gmt":"2024-03-08T12:23:55","guid":{"rendered":"https:\/\/byecampus.com\/?p=319"},"modified":"2024-03-08T20:23:56","modified_gmt":"2024-03-08T12:23:56","slug":"%e5%85%b3%e8%81%94%e8%a7%84%e5%88%99","status":"publish","type":"post","link":"https:\/\/byecampus.com\/index.php\/2024\/03\/08\/%e5%85%b3%e8%81%94%e8%a7%84%e5%88%99\/","title":{"rendered":"\u5173\u8054\u89c4\u5219"},"content":{"rendered":"\n<!DOCTYPE html>\n\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n\n<head>\n\n<meta charset=\"utf-8\" \/>\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/>\n<meta name=\"generator\" content=\"pandoc\" \/>\n\n\n\n\n<title>\u5173\u8054\u89c4\u5219<\/title>\n\n<script src=\"1-apriori_files\/jquery-1.11.3\/jquery.min.js\"><\/script>\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" \/>\n<link href=\"1-apriori_files\/bootstrap-3.3.5\/css\/united.min.css\" rel=\"stylesheet\" \/>\n<script src=\"1-apriori_files\/bootstrap-3.3.5\/js\/bootstrap.min.js\"><\/script>\n<script src=\"1-apriori_files\/bootstrap-3.3.5\/shim\/html5shiv.min.js\"><\/script>\n<script src=\"1-apriori_files\/bootstrap-3.3.5\/shim\/respond.min.js\"><\/script>\n<script src=\"1-apriori_files\/jqueryui-1.11.4\/jquery-ui.min.js\"><\/script>\n<link href=\"1-apriori_files\/tocify-1.9.1\/jquery.tocify.css\" rel=\"stylesheet\" \/>\n<script src=\"1-apriori_files\/tocify-1.9.1\/jquery.tocify.js\"><\/script>\n<script src=\"1-apriori_files\/navigation-1.1\/tabsets.js\"><\/script>\n<script src=\"1-apriori_files\/navigation-1.1\/codefolding.js\"><\/script>\n\n\n<style type=\"text\/css\">code{white-space: pre;}<\/style>\n<style type=\"text\/css\">\ndiv.sourceCode { overflow-x: auto; }\ntable.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {\n  margin: 0; padding: 0; vertical-align: baseline; border: none; }\ntable.sourceCode { width: 100%; line-height: 100%; background-color: #f8f8f8; }\ntd.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }\ntd.sourceCode { padding-left: 5px; }\npre, code { background-color: #f8f8f8; }\ncode > span.kw { color: #204a87; font-weight: bold; } \/* Keyword *\/\ncode > span.dt { color: #204a87; } \/* DataType *\/\ncode > span.dv { color: #0000cf; } \/* DecVal *\/\ncode > span.bn { color: #0000cf; } \/* BaseN *\/\ncode > span.fl { color: #0000cf; } \/* Float *\/\ncode > span.ch { color: #4e9a06; } \/* Char *\/\ncode > span.st { color: #4e9a06; } \/* String *\/\ncode > span.co { color: #8f5902; font-style: italic; } \/* Comment *\/\ncode > span.ot { color: #8f5902; } \/* Other *\/\ncode > span.al { color: #ef2929; } \/* Alert *\/\ncode > span.fu { color: #000000; } \/* Function *\/\ncode > span.er { color: #a40000; font-weight: bold; } \/* Error *\/\ncode > span.wa { color: #8f5902; font-weight: bold; font-style: italic; } \/* Warning *\/\ncode > span.cn { color: #000000; } \/* Constant *\/\ncode > span.sc { color: #000000; } \/* SpecialChar *\/\ncode > span.vs { color: #4e9a06; } \/* VerbatimString *\/\ncode > span.ss { color: #4e9a06; } \/* SpecialString *\/\ncode > span.im { } \/* Import *\/\ncode > span.va { color: #000000; } \/* Variable *\/\ncode > span.cf { color: #204a87; font-weight: bold; } \/* ControlFlow *\/\ncode > span.op { color: #ce5c00; font-weight: bold; } \/* Operator *\/\ncode > span.pp { color: #8f5902; font-style: italic; } \/* Preprocessor *\/\ncode > span.ex { } \/* Extension *\/\ncode > span.at { color: #c4a000; } \/* Attribute *\/\ncode > span.do { color: #8f5902; font-weight: bold; font-style: italic; } \/* Documentation *\/\ncode > span.an { color: #8f5902; font-weight: bold; font-style: italic; } \/* Annotation *\/\ncode > span.cv { color: #8f5902; font-weight: bold; font-style: italic; } \/* CommentVar *\/\ncode > span.in { color: #8f5902; font-weight: bold; font-style: italic; } \/* Information *\/\ndiv.sourceCode {\n  overflow-x: visible;\n}\n<\/style>\n<style type=\"text\/css\">\n  pre:not([class]) {\n    background-color: white;\n  }\n<\/style>\n\n\n<style type=\"text\/css\">\nh1 {\n  font-size: 34px;\n}\nh1.title {\n  font-size: 38px;\n}\nh2 {\n  font-size: 30px;\n}\nh3 {\n  font-size: 24px;\n}\nh4 {\n  font-size: 18px;\n}\nh5 {\n  font-size: 16px;\n}\nh6 {\n  font-size: 12px;\n}\n.table th:not([align]) {\n  text-align: left;\n}\n<\/style>\n\n\n<\/head>\n\n<body>\n\n<style type = \"text\/css\">\n.main-container {\n  max-width: 940px;\n  margin-left: auto;\n  margin-right: auto;\n}\ncode {\n  color: inherit;\n  background-color: rgba(0, 0, 0, 0.04);\n}\nimg {\n  max-width:100%;\n  height: auto;\n}\n.tabbed-pane {\n  padding-top: 12px;\n}\n.html-widget {\n  margin-bottom: 20px;\n}\nbutton.code-folding-btn:focus {\n  outline: none;\n}\n<\/style>\n\n\n\n<div class=\"container-fluid main-container\">\n\n<!-- tabsets -->\n<script>\n$(document).ready(function () {\n  window.buildTabsets(\"TOC\");\n});\n<\/script>\n\n<!-- code folding -->\n<style type=\"text\/css\">\n.code-folding-btn { margin-bottom: 4px; }\n<\/style>\n<script>\n$(document).ready(function () {\n  window.initializeCodeFolding(\"show\" === \"show\");\n});\n<\/script>\n\n\n\n\n<script>\n$(document).ready(function ()  {\n\n    \/\/ move toc-ignore selectors from section div to header\n    $('div.section.toc-ignore')\n        .removeClass('toc-ignore')\n        .children('h1,h2,h3,h4,h5').addClass('toc-ignore');\n\n    \/\/ establish options\n    var options = {\n      selectors: \"h1,h2,h3\",\n      theme: \"bootstrap3\",\n      context: '.toc-content',\n      hashGenerator: function (text) {\n        return text.replace(\/[.\\\\\/?&!#<>]\/g, '').replace(\/\\s\/g, '_').toLowerCase();\n      },\n      ignoreSelector: \".toc-ignore\",\n      scrollTo: 0\n    };\n    options.showAndHide = true;\n    options.smoothScroll = true;\n\n    \/\/ tocify\n    var toc = $(\"#TOC\").tocify(options).data(\"toc-tocify\");\n});\n<\/script>\n\n<style type=\"text\/css\">\n\n#TOC {\n  margin: 25px 0px 20px 0px;\n}\n@media (max-width: 768px) {\n#TOC {\n  position: relative;\n  width: 100%;\n}\n}\n\n\n.toc-content {\n  padding-left: 30px;\n  padding-right: 40px;\n}\n\ndiv.main-container {\n  max-width: 1200px;\n}\n\ndiv.tocify {\n  width: 20%;\n  max-width: 260px;\n  max-height: 85%;\n}\n\n@media (min-width: 768px) and (max-width: 991px) {\n  div.tocify {\n    width: 25%;\n  }\n}\n\n@media (max-width: 767px) {\n  div.tocify {\n    width: 100%;\n    max-width: none;\n  }\n}\n\n.tocify ul, .tocify li {\n  line-height: 20px;\n}\n\n.tocify-subheader .tocify-item {\n  font-size: 0.90em;\n  padding-left: 25px;\n  text-indent: 0;\n}\n\n.tocify .list-group-item {\n  border-radius: 0px;\n}\n\n\n<\/style>\n\n<!-- setup 3col\/9col grid for toc_float and main content  -->\n<div class=\"row-fluid\">\n<div class=\"col-xs-12 col-sm-4 col-md-3\">\n<div id=\"TOC\" class=\"tocify\">\n<\/div>\n<\/div>\n\n<div class=\"toc-content col-xs-12 col-sm-8 col-md-9\">\n\n\n\n\n<div class=\"fluid-row\" id=\"header\">\n\n<div class=\"btn-group pull-right\">\n<button type=\"button\" class=\"btn btn-default btn-xs dropdown-toggle\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span>Code<\/span> <span class=\"caret\"><\/span><\/button>\n<ul class=\"dropdown-menu\" style=\"min-width: 50px;\">\n<li><a id=\"rmd-show-all-code\" href=\"#\">Show All Code<\/a><\/li>\n<li><a id=\"rmd-hide-all-code\" href=\"#\">Hide All Code<\/a><\/li>\n<\/ul>\n<\/div>\n\n\n\n<h1 class=\"title toc-ignore\">\u5173\u8054\u89c4\u5219<\/h1>\n\n<\/div>\n\n\n<div class=\"section level1\">\n<h1><span class=\"header-section-number\">1<\/span> \u5173\u8054\u89c4\u5219\u7b80\u4ecb<\/h1>\n<p><font size=4 face=\"\u5fae\u8f6f\u96c5\u9ed1\"><\/p>\n<hr \/>\n<p>\u2003\u2003\u5173\u8054\u89c4\u5219\u7b97\u6cd5\u662f\u6570\u636e\u6316\u6398\u4e2d\u7684\u4e00\u7c7b\u91cd\u8981\u7684\u7b97\u6cd5\uff0c1993\u5e74\uff0cR.Agrawal\u548cR.Srikant\u7b49\u4eba\u9996\u5148\u63d0\u51fa\u5173\u8054\u89c4\u5219\u6982\u5ff5\uff0c\u540c\u65f6\u7ed9\u51fa\u4e86\u76f8\u5e94\u7684\u6316\u6398\u7b97\u6cd5AIS\uff0c\u4f46\u662f\u6027\u80fd\u8f83\u5dee\u30021994\u5e74\uff0c\u4ed6\u4eec\u5efa\u7acb\u4e86\u9879\u76ee\u96c6\u683c\u7a7a\u95f4\u7406\u8bba\uff0c\u5e76\u4f9d\u636e\u4e0a\u8ff0\u4e24\u4e2a\u5b9a\u7406\uff0c\u63d0\u51fa\u4e86\u8457\u540d\u7684Apriori\u7b97\u6cd5\uff0c\u81f3\u4ecaApriori\u4ecd\u7136\u4f5c\u4e3a\u5173\u8054\u89c4\u5219\u6316\u6398\u7684\u7ecf\u5178\u7b97\u6cd5\u88ab\u5e7f\u6cdb\u5e94\u7528\u3002<\/p>\n<p>\u2003\u2003Apriori\u7b97\u6cd5\u4e4b\u6240\u4ee5\u6027\u80fd\u8f83\u9ad8\uff0c\u662f\u56e0\u4e3a\u5176\u5b9e\u73b0\u4e86\u4e00\u4e2a\u89c4\u5219\uff1a<strong>\u4e00\u4e2a\u9879\u96c6\u5982\u679c\u4e0d\u662f\u9891\u7e41\u9879\u96c6\uff0c\u5176\u8d85\u9879\u96c6\u4e5f\u4e00\u5b9a\u4e0d\u662f\u9891\u7e41\u9879\u96c6<\/strong>\uff0c\u8fd9\u4e2a\u89c4\u5219\u7684\u9650\u5236\u4f1a\u5e2e\u52a9\u7b97\u6cd5\u5927\u5927\u51cf\u5c11\u5bf9\u6570\u636e\u7684\u904d\u5386\u6b21\u6570\u3002<\/p>\n<p>\u2003\u2003\u5173\u8054\u89c4\u5219\u662f\u5c55\u73b0\u9879\u96c6\u95f4\u5173\u8054\u4e0e\u76f8\u5173\u6027\u7684\u89c4\u5219\u3002\u5173\u4e8e\u8fd9\u4e2a\u7b97\u6cd5\u6709\u4e00\u4e2a\u975e\u5e38\u6709\u540d\u7684\u6545\u4e8b\uff1a\u201c\u5c3f\u5e03\u548c\u5564\u9152\u201d\u3002\u6545\u4e8b\u662f\u8fd9\u6837\u7684\uff1a\u7f8e\u56fd\u7684\u5987\u5973\u4eec\u7ecf\u5e38\u4f1a\u5631\u5490\u5979\u4eec\u7684\u4e08\u592b\u4e0b\u73ed\u540e\u4e3a\u5b69\u5b50\u4e70\u5c3f\u5e03\uff0c\u800c\u4e08\u592b\u5728\u4e70\u5b8c\u5c3f\u5e03\u540e\u53c8\u8981\u987a\u624b\u4e70\u56de\u81ea\u5df1\u7231\u559d\u7684\u5564\u9152\uff0c\u56e0\u6b64\u5564\u9152\u548c\u5c3f\u5e03\u5728\u4e00\u8d77\u88ab\u8d2d\u4e70\u7684\u673a\u4f1a\u5f88\u591a\u3002\u8fd9\u4e2a\u4e3e\u63aa\u4f7f\u5c3f\u5e03\u548c\u5564\u9152\u7684\u9500\u91cf\u53cc\u53cc\u589e\u52a0\uff0c\u5e76\u4e00\u76f4\u4e3a\u4f17\u5546\u5bb6\u6240\u6d25\u6d25\u4e50\u9053\u3002<\/p>\n<p>\u2003\u2003\u7ed9\u5927\u5bb6\u5c55\u793a\u4e00\u4e2a\u5178\u578b\u7684\u89c4\u5219\u8868\u8fbe\u5f0f\uff1a<strong>{\u5564\u9152\uff0c\u767d\u9152}-&gt;{\u8001\u918b\u82b1\u751f}<\/strong><\/p>\n<p>\u2003\u2003\u4e0a\u9762\u7684\u8868\u8fbe\u5f0f\u5f88\u597d\u7406\u89e3\uff0c\u5373\u5982\u679c\u67d0\u4eba\u8d2d\u4e70\u4e86\u5564\u9152\u548c\u767d\u9152\uff0c\u90a3\u4e48\u5176\u5f88\u6709\u53ef\u80fd\u53bb\u8d2d\u4e70\u8001\u918b\u82b1\u751f\u3002\u6839\u636e\u8fd9\u6761\u89c4\u5219\uff0c\u90a3\u4e48\u8d85\u5e02\u5c31\u53ef\u4ee5\u628a\u8001\u918b\u82b1\u751f\u653e\u5230\u5564\u9152\u548c\u767d\u9152\u9644\u8fd1\u7684\u8d2d\u7269\u67b6\u4e0a\uff0c\u4fc3\u8fdb\u9500\u91cf\u3002<\/p>\n<\/div>\n<div class=\"section level1\">\n<h1><span class=\"header-section-number\">2<\/span> \u5173\u8054\u89c4\u5219\u7684\u7406\u89e3<\/h1>\n<hr \/>\n<p>\u2003\u2003\u4e0a\u9762\u7b80\u5355\u7684\u4ecb\u7ecd\u4e86\u4e00\u4e0b\u5173\u8054\u89c4\u5219\uff0c\u5982\u679c\u5f7b\u5e95\u7406\u89e3\u5173\u8054\u89c4\u5219\u5219\u9700\u8981\u660e\u767d8\u4e2a\u6982\u5ff5\u3002\u90a3\u4e48\u4e0b\u9762\u6211\u5c31\u7ed9\u5927\u5bb6\u7528\u7406\u8bba\u52a0\u5b9e\u9645\u53bb\u8bb2\u89e3\u8fd98\u4e2a\u6982\u5ff5\uff1a<\/p>\n<p>\u2003\u2003\u9996\u5148\u5462\uff0c\u6211\u4eec\u5148\u6a21\u62df\u4e00\u4e2a\u7b80\u5355\u7684\u4ea4\u6613\u6570\u636e\u5e93\uff0c\u5982\u4e0b\u8868\u6240\u793a:<\/p>\n<table>\n<thead>\n<tr class=\"header\">\n<th align=\"center\">\u4ea4\u6613\u53f7<\/th>\n<th align=\"left\">\u8d2d\u7269\u6e05\u5355<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr class=\"odd\">\n<td align=\"center\">1<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u767d\u9152\uff0c\u9999\u70df\uff0c\u8001\u918b\u82b1\u751f}<\/td>\n<\/tr>\n<tr class=\"even\">\n<td align=\"center\">2<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u767d\u9152\uff0c\u8001\u918b\u82b1\u751f}<\/td>\n<\/tr>\n<tr class=\"odd\">\n<td align=\"center\">3<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u767d\u9152\uff0c\u9999\u70df}<\/td>\n<\/tr>\n<tr class=\"even\">\n<td align=\"center\">4<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u9999\u70df}<\/td>\n<\/tr>\n<tr class=\"odd\">\n<td align=\"center\">5<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u7259\u818f}<\/td>\n<\/tr>\n<tr class=\"even\">\n<td align=\"center\">6<\/td>\n<td align=\"left\">{\u767d\u9152\uff0c\u6696\u58f6}<\/td>\n<\/tr>\n<tr class=\"odd\">\n<td align=\"center\">7<\/td>\n<td align=\"left\">{\u767d\u9152\uff0c\u7eb8\u5dfe}<\/td>\n<\/tr>\n<tr class=\"even\">\n<td align=\"center\">8<\/td>\n<td align=\"left\">{\u5473\u7cbe\uff0c\u98df\u7528\u76d0}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u9879\u96c6\uff1a<\/strong><\/p>\n<ul>\n<li>\u6982\u5ff5\uff1a\u5305\u542b0\u4e2a\u6216\u591a\u4e2a\u9879\u7684\u96c6\u5408\u88ab\u79f0\u4e3a\u9879\u96c6\u3002<\/li>\n<li>\u901a\u4fd7\u7406\u89e3\uff1a\u4e00\u6b21\u6027\u8d2d\u4e70\u5546\u54c1\u7684\u96c6\u5408\u3002<\/li>\n<li>\u5b9e\u4f8b\uff1a{\u5564\u9152\uff0c\u767d\u9152\uff0c\u8001\u918b\u82b1\u751f}<\/li>\n<\/ul>\n<p><strong>\u5173\u8054\u89c4\u5219\uff1a<\/strong><\/p>\n<ul>\n<li>\u6982\u5ff5\uff1a\u5f62\u5982X\u2192Y\u7684\u8574\u6db5\u5f0f\u3002<\/li>\n<li>\u901a\u4fd7\u7406\u89e3\uff1aX\u4e0eY\u7684\u5173\u7cfb\u8868\u8fbe\u5f0f\u3002<\/li>\n<li>\u5b9e\u4f8b\uff1a{\u5564\u9152\uff0c\u767d\u9152} \u2014&gt; {\u8001\u918b\u82b1\u751f}<\/li>\n<\/ul>\n<p><strong>\u652f\u6301\u5ea6\uff1a<\/strong><\/p>\n<ul>\n<li>\u6982\u5ff5\uff1a\u4efb\u4f55\u9879\u96c6\u7684\u7ec4\u5408\u5728\u6240\u6709\u9879\u96c6\u4e2d\u51fa\u73b0\u7684\u9891\u7387\uff0c\u901a\u5e38\u7528\u6765\u5220\u53bb\u65e0\u610f\u4e49\u7684\u89c4\u5219\u3002<\/li>\n<li>\u901a\u4fd7\u7406\u89e3\uff1a\u540c\u65f6\u8d2d\u4e70X\u548cY\u7684\u53ef\u80fd\u6027\u3002<\/li>\n<li>\u5b9e\u4f8b\uff1a<strong>{\u5564\u9152}{\u767d\u9152}<\/strong>\u5728\u6240\u6709\u7684\u9879\u96c6\u4e2d\u4e00\u5171\u51fa\u73b0\u4e863\u6b21\uff0c\u6240\u4ee5<strong>{\u5564\u9152}-&gt;{\u767d\u9152}<\/strong>\u7684\u652f\u6301\u5ea6\u4e3a<strong>3\/9\u224833.3%<\/strong>\u3002<\/li>\n<li>\u6570\u5b66\u8868\u8fbe\u5f0f\u4e3a\uff1a<span class=\"math inline\">\\(support(X)=\\frac{count(X)}{N}\\)<\/span><\/li>\n<\/ul>\n<p><strong>\u7f6e\u4fe1\u5ea6\uff1a<\/strong><\/p>\n<ul>\n<li>\u6982\u5ff5\uff1aY\u5728\u5305\u542bX\u7684\u4e8b\u52a1\u4e2d\u51fa\u73b0\u7684\u9891\u7e41\u7a0b\u5ea6\uff0c\u89c4\u5219\u7684\u9884\u6d4b\u80fd\u529b\u7684\u5ea6\u91cf\u3002<\/li>\n<li>\u901a\u4fd7\u7406\u89e3\uff1a\u53d1\u751fX\u7684\u524d\u63d0\u4e0b\u4e5f\u53d1\u751f\u4e86Y\u7684\u6982\u7387\u3002<\/li>\n<li>\u5b9e\u4f8b\uff1a<strong>{\u5564\u9152}<\/strong>\u51fa\u73b0\u4e865\u6b21\uff0c<strong>{\u5564\u9152}<\/strong>\u548c<strong>{\u767d\u9152}<\/strong>\u540c\u65f6\u51fa\u73b0\u4e863\u6b21\uff0c\u6240\u4ee5<strong>{\u5564\u9152}-&gt;{\u767d\u9152}<\/strong>\u7684\u7f6e\u4fe1\u5ea6\u4e3a<strong>3\/5=60%<\/strong>\u3002<\/li>\n<li>\u6570\u5b66\u8868\u8fbe\u5f0f\uff1a<span class=\"math inline\">\\(confidence(X \\to Y)=\\frac{support(X,Y)}{support(X)}\\)<\/span><\/li>\n<\/ul>\n<p><strong>\u63d0\u5347\u5ea6\uff1a<\/strong><\/p>\n<ul>\n<li>\u6982\u5ff5\uff1a\u7f6e\u4fe1\u5ea6\u4e0e\u652f\u6301\u5ea6\u7684\u6bd4\u503c\u3002\u662f\u7f6e\u4fe1\u5ea6\u7684\u8865\u5145\uff0c\u63d0\u5347\u5ea6\u7b49\u4e8e1\u65f6\uff0cX\u4e0eY\u662f\u72ec\u7acb\u7684\uff1b\u5927\u4e8e1\u65f6\uff0c\u8d8a\u5927\u8bf4\u660eX\u5bf9Y\u7684\u5f71\u54cd\u8d8a\u5927\uff0c\u5373\u5173\u8054\u6027\u8d8a\u5f3a\u3002<\/li>\n<li>\u901a\u4fd7\u7406\u89e3\uff1a\u51fa\u73b0X\u7684\u6761\u4ef6\u4e0b\u540c\u65f6\u51fa\u73b0Y\u7684\u53ef\u80fd\u6027\u4e0e\u6ca1\u6709\u4efb\u4f55\u6761\u4ef6\u4e0b\u51fa\u73b0Y\u7684\u53ef\u80fd\u6027\u4e4b\u6bd4\u3002<\/li>\n<li>\u5b9e\u4f8b\uff1a<strong>{\u5564\u9152}<\/strong>\u548c<strong>{\u767d\u9152}<\/strong>\u7684\u63d0\u5347\u5ea6\u4e3a<strong>(3\/5) \/ (3\/9)=1.8<\/strong>\u3002<\/li>\n<li>\u6570\u5b66\u8868\u8fbe\u5f0f\u4e3a\uff1a<span class=\"math inline\">\\(lift(X \\to Y)=\\frac{confidence(X \\to Y)}{support(X)}\\)<\/span><\/li>\n<\/ul>\n<p>\u2003\u2003\u7531\u4e8e\u4e0a\u9762\u7684\u90a3\u4e2a\u6a21\u62df\u4ea4\u6613\u6570\u636e\u5e93\u4e0d\u9002\u5408\u8bb2\u89e3\u4e0b\u9762\u7684\u4e09\u4e2a\u6982\u5ff5\uff0c\u6240\u4ee5\u91cd\u65b0\u6a21\u62df\u4e00\u4e2a\u4ea4\u6613\u6570\u636e\u5e93\uff1a<\/p>\n<table>\n<thead>\n<tr class=\"header\">\n<th align=\"center\">\u4ea4\u6613\u53f7<\/th>\n<th align=\"left\">\u8d2d\u7269\u6e05\u5355<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr class=\"odd\">\n<td align=\"center\">1<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u767d\u9152\uff0c\u9999\u70df\uff0c\u8001\u918b\u82b1\u751f}<\/td>\n<\/tr>\n<tr class=\"even\">\n<td align=\"center\">2<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u767d\u9152\uff0c\u9999\u70df}<\/td>\n<\/tr>\n<tr class=\"odd\">\n<td align=\"center\">3<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u767d\u9152\uff0c\u9999\u70df}<\/td>\n<\/tr>\n<tr class=\"even\">\n<td align=\"center\">4<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u9999\u70df\uff0c\u8001\u918b\u82b1\u751f}<\/td>\n<\/tr>\n<tr class=\"odd\">\n<td align=\"center\">5<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u767d\u9152}<\/td>\n<\/tr>\n<tr class=\"even\">\n<td align=\"center\">6<\/td>\n<td align=\"left\">{\u5564\u9152\uff0c\u9999\u70df}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u9891\u7e41\u9879\u96c6\uff1a<\/strong><\/p>\n<ul>\n<li>\u6982\u5ff5\uff1a\u652f\u6301\u5ea6\u5927\u4e8e\u6700\u5c0f\u652f\u6301\u5ea6\u9608\u503c\u7684\u9879\u96c6<\/li>\n<li>\u5b9e\u4f8b\uff1a\u5047\u8bbe\u652f\u6301\u5ea6\u4e3a2\uff0c\u56e0\u4e3a<strong>{\u5564\u9152\uff0c\u9999\u70df}<\/strong>\u51fa\u73b0\u4e863\u6b21\uff0c\u6240\u4ee5\u5176\u662f\u9891\u7e41\u9879\u96c6\u3002<\/li>\n<\/ul>\n<p><strong>\u95ed\u9891\u7e41\u9879\u96c6\uff1a<\/strong><\/p>\n<ul>\n<li>\u6982\u5ff5\uff1a\u9996\u5148\u9879\u96c6X\u4e3a\u9891\u7e41\u9879\u96c6\uff0c\u5176\u6b21\u9879\u96c6X\u4e0e\u5176\u8d85\u9879\u96c6Y\uff08X\u662fY\u7684\u771f\u5b50\u96c6\uff09\u4e0d\u5177\u6709\u76f8\u540c\u7684\u652f\u6301\u5ea6\u3002<\/li>\n<li><p>\u5b9e\u4f8b\uff1a<strong>{\u5564\u9152\uff0c\u9999\u70df}<\/strong>\u7684\u8d85\u9879\u96c6\u6709<strong>{\u5564\u9152\uff0c\u767d\u9152\uff0c\u9999\u70df}<\/strong>\u3001<strong>{\u5564\u9152\uff0c\u9999\u70df\uff0c\u8001\u918b\u82b1\u751f}<\/strong>\u548c<strong>{\u5564\u9152\uff0c\u767d\u9152\uff0c\u9999\u70df\uff0c\u8001\u918b\u82b1\u751f}<\/strong>\uff0c\u5b83\u4eec\u5206\u522b\u51fa\u73b0\u4e862\u6b21\u30011\u6b21\u548c1\u6b21\uff0c\u6240\u4ee5X\u4e0eY\u6ca1\u6709\u76f8\u540c\u7684\u652f\u6301\u5ea6\uff0c\u5373<strong>{\u5564\u9152\uff0c\u9999\u70df}<\/strong>\u662f\u95ed\u9891\u7e41\u9879\u96c6\u3002<\/p><\/li>\n<li><p><strong>\u6700\u5927\u9891\u7e41\u9879\u96c6\uff1a<\/strong><\/p><\/li>\n<li>\u6982\u5ff5\uff1a\u5404\u9891\u7e41k-\u9879\u96c6\u4e2d\u7b26\u5408\u65e0\u8d85\u96c6\u6761\u4ef6\u7684\u9891\u7e41\u9879\u96c6\u3002<\/li>\n<li><p>\u5b9e\u4f8b\uff1a<strong>{\u5564\u9152\uff0c\u767d\u9152\uff0c\u9999\u70df}<\/strong>\u51fa\u73b0\u4e863\u6b21\uff0c\u5c5e\u4e8e\u9891\u7e41\u9879\u96c6\uff0c\u5176\u8d85\u9879\u96c6<strong>{\u5564\u9152\uff0c\u767d\u9152\uff0c\u9999\u70df\uff0c\u8001\u918b\u82b1\u751f}<\/strong>\u51fa\u73b0\u4e861\u6b21\uff0c\u6545\u4e0d\u662f\u9891\u7e41\u9879\u96c6\uff0c\u6240\u4ee5\u9879\u96c6<strong>{\u5564\u9152\uff0c\u767d\u9152\uff0c\u9999\u70df}<\/strong>\u5c31\u662f\u4e00\u4e2a\u6700\u5927\u9891\u7e41\u9879\u96c6\u3002<\/p><\/li>\n<\/ul>\n<p>\u2003\u2003\u5230\u8fd9\u91cc\u4e5f\u5c31\u628a\u8fd98\u4e2a\u6982\u5ff5\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u5b8c\u4e86\uff0c\u4e0b\u9762\u5c31\u5f00\u59cb\u6211\u4eec\u7684\u6848\u4f8b\u5b9e\u6218\u90e8\u5206\u4e86\uff0c\u540c\u6837\u6848\u4f8b\u5b9e\u6218\u4e5f\u662f\u4e00\u4e2a\u8d2d\u7269\u7bee\u7684\u5173\u8054\u89c4\u5219\uff1a<\/p>\n<\/div>\n<div class=\"section level1\">\n<h1><span class=\"header-section-number\">3<\/span> \u6848\u4f8b\u5b9e\u6218<\/h1>\n<hr \/>\n<p>\u2003\u2003\u672c\u6848\u4f8b\u7684\u4e3b\u8981\u5185\u5bb9\u662f\u5229\u75281000\u591a\u6761\u7684\u8d85\u5e02\u7684\u6d88\u8d39\u6570\u636e\u53bb\u63a2\u7d22\u6f5c\u5728\u7684\u5173\u8054\u89c4\u5219\uff0c\u4ece\u800c\u4e3a\u8d85\u5e02\u5546\u54c1\u7684\u6446\u653e\u63d0\u4f9b\u4e00\u4e9b\u53c2\u8003\u610f\u89c1\u3002<\/p>\n<p>\u2003\u2003\u5728R\u4e2d\u5e38\u7528arules\u548carulesViz\u4e24\u4e2a\u7a0b\u5e8f\u5305\u53bb\u5b9e\u73b0\u5173\u8054\u89c4\u5219\uff0c\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\u5305\u63d0\u4f9b\u4e86\u5b9e\u73b0Apriori\u7b97\u6cd5\u7684\u51fd\u6570\uff0c\u7b2c\u4e8c\u4e2a\u7a0b\u5e8f\u5305\u7528\u4e8e\u53ef\u89c6\u5316\u5173\u8054\u89c4\u5219\uff0c\u65b9\u4fbf\u5927\u5bb6\u751f\u52a8\u5f62\u8c61\u7684\u7406\u89e3\u4ea7\u751f\u7684\u89c4\u5219\u3002<\/p>\n<p><strong>apriori<\/strong><\/p>\n<p>apriori(data, parameter = NULL, appearance = NULL, control = NULL)<\/p>\n<ul>\n<li><strong>data\uff1a<\/strong>\u542b\u6709\u4ea4\u6613\u6570\u636e\u7684\u7a00\u758f\u77e9\u9635<\/li>\n<li><strong>parameter\uff1a<\/strong>\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u5b58\u50a8\u6a21\u578b\u6240\u9700\u7684\u652f\u6301\u5ea6\u3001\u7f6e\u4fe1\u5ea6\u3001\u6bcf\u4e2a\u9879\u96c6\u6240\u542b\u9879\u6570\u7684\u6700\u5927\u503c\/\u6700\u5c0f\u503c\u548c\u8f93\u51fa\u7ed3\u679c\u7c7b\u578b\u7b49\u53c2\u6570\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u652f\u6301\u5ea6\u4e3a0.1\uff0c\u7f6e\u4fe1\u5ea6\u4e3a0.8\uff0c\u9879\u96c6\u4e2d\u6700\u5927\u9879\u6570\u4e3a10\uff0c\u6700\u5c0f\u9879\u6570\u4e3a1\uff0c\u8f93\u51fa\u5173\u8054\u89c4\u5219\/\u9891\u7e41\u9879\u96c6\u7c7b\u578b\u7684\u7ed3\u679c\u3002<\/li>\n<li><strong>appearance\uff1a<\/strong>\u53ef\u4e3a\u5148\u51b3\u6761\u4ef6X\u548c\u5173\u8054\u7ed3\u679cY\u6307\u5b9a\u660e\u786e\u7684\u9879\u96c6(\u4e00\u822c\u662f\u5206\u6790\u4eba\u5458\u611f\u5174\u8da3\u7684\u9879\u96c6)\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e0d\u4e3aX\u548cY\u6307\u5b9a\u67d0\u4e9b\u9879\u96c6\u3002<\/li>\n<li><strong>control\uff1a<\/strong>\u7528\u6765\u63a7\u5236\u51fd\u6570\u6027\u80fd\uff0c\u5982\u5bf9\u9879\u96c6\u8fdb\u884c\u5347\u5e8f\u6216\u964d\u5e8f\uff0c\u751f\u6210\u7b97\u6cd5\u8fd0\u884c\u7684\u62a5\u544a\u8fdb\u7a0b\u7b49\u3002<\/li>\n<\/ul>\n<div class=\"section level2\">\n<h2><span class=\"header-section-number\">3.1<\/span> \u83b7\u53d6\u5e76\u63a2\u7d22\u6570\u636e<\/h2>\n<p>\u2003\u2003\u672c\u6b21\u6570\u636e\u8bfb\u53d6\u7684\u65b9\u5f0f\u4e0e\u4e4b\u524d\u6709\u6240\u4e0d\u540c\uff0c\u6211\u4eec\u4f7f\u7528arules\u7a0b\u5e8f\u5305\u4e2d\u7684<strong>read.transaction()<\/strong>\u51fd\u6570\u8bfb\u53d6\u6570\u636e\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u6210\u4e3a<strong>apriori()<\/strong>\u51fd\u6570\u6240\u9700\u8981\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<p>read.transactions(file, sep = \u201c\u201d, \u2026)<\/p>\n<ul>\n<li><strong>file\uff1a<\/strong>\u9700\u8981\u8bfb\u53d6\u7684\u6570\u636e<\/li>\n<li><strong>sep\uff1a<\/strong>\u6307\u5b9a\u8bfb\u53d6\u6570\u636e\u4f7f\u7528\u4ec0\u4e48\u5b57\u7b26\u4e32\u5206\u9694\u5b57\u6bb5\uff0c\u9ed8\u8ba4\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ul>\n<div class=\"sourceCode\"><pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span class=\"co\"># install.packages(&quot;dplyr&quot;)<\/span>\n<span class=\"co\"># install.packages(&quot;DT&quot;)<\/span>\n<span class=\"co\"># install.packages(&quot;arules&quot;)<\/span>\n<span class=\"kw\">library<\/span>(dplyr)\n<span class=\"kw\">library<\/span>(DT)\n<span class=\"kw\">library<\/span>(arules)\n\ngroceries &lt;-<span class=\"st\"> <\/span><span class=\"kw\">read.transactions<\/span>(<span class=\"dt\">file =<\/span> <span class=\"kw\">file.choose<\/span>(), <span class=\"dt\">sep =<\/span> <span class=\"st\">&quot;,&quot;<\/span>) <span class=\"co\"># \u8bfb\u53d6\u6570\u636e<\/span>\n<span class=\"kw\">summary<\/span>(groceries)                                              <span class=\"co\"># \u67e5\u770b\u6570\u636e\u96c6\u4fe1\u606f<\/span><\/code><\/pre><\/div>\n<pre><code>## transactions as itemMatrix in sparse format with\n##  1499 rows (elements\/itemsets\/transactions) and\n##  38 columns (items) and a density of 0.2723746 \n## \n## most frequent items:\n## vegetables    poultry    waffles     bagels lunch meat    (Other) \n##        895        431        418        417        414      12940 \n## \n## element (itemset\/transaction) length distribution:\n## sizes\n##   3   4   5   6   7   8   9  10  11  12  13  14 \n##   8  57  51  51  71  74  95 191 304 321 212  64 \n## \n##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. \n##    3.00    9.00   11.00   10.35   12.00   14.00 \n## \n## includes extended item information - examples:\n##          labels\n## 1  all- purpose\n## 2 aluminum foil\n## 3        bagels<\/code><\/pre>\n<p>\u2003\u2003\u4e0b\u9762\u6211\u4eec\u9996\u5148\u770b\u8fd4\u56de\u4fe1\u606f\u4e2d\u7684\u7b2c\u4e00\u90e8\u5206(\u5982\u4e0b\u6240\u793a)\uff0c\u5176\u63d0\u4f9b\u4e86\u6211\u4eec\u521b\u5efa\u7684\u7a00\u758f\u77e9\u9635\u7684\u6982\u8981\uff1a<\/p>\n<ul>\n<li><strong>1499 rows<\/strong>\u8868\u793a\u6211\u4eec\u7684\u4ea4\u6613\u6570\u636e\u7684\u6570\u91cf<\/li>\n<li><strong>38 columns<\/strong>\u8868\u793a\u4ea4\u6613\u6570\u636e\u4e2d\u4e00\u5171\u51fa\u73b0\u4e8638\u4e2d\u5546\u54c1<\/li>\n<li><strong>density of 0.27<\/strong>\u8868\u793a\u975e\u96f6\u77e9\u9635\u5355\u5143\u683c\u7684\u5360\u6bd4<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"summary_1.png\" \/> <br><\/p>\n<p>\u2003\u2003\u8fd4\u56de\u4fe1\u606f\u7684\u7b2c\u4e8c\u90e8\u5206(\u5982\u4e0b\u6240\u793a)\uff0c\u5176\u63d0\u4f9b\u4e86\u4ea4\u6613\u5546\u54c1\u4e2d\u6700\u5e38\u8d2d\u4e70\u7684\u5546\u54c1\u3002\u6700\u5e38\u8d2d\u4e70\u7684\u5546\u54c1\u662fvegetables\uff0c\u5176\u6b21\u662fpoultry\u2026\u2026<\/p>\n<div class=\"figure\">\n<img decoding=\"async\" src=\"summary_2.png\" \/>\n\n<\/div>\n<p><br><\/p>\n<p>\u2003\u2003\u8fd4\u56de\u4fe1\u606f\u7684\u7b2c\u4e09\u90e8\u5206(\u5982\u4e0b\u6240\u793a)\uff0c\u5176\u63d0\u4f9b\u4e86\u5173\u4e8e\u4ea4\u6613\u89c4\u6a21\u7684\u7edf\u8ba1\u3002\u6bd4\u5982\u7b2c\u4e00\u5217\u7684(3\uff0c8)\u8868\u793a\u5728\u6240\u6709\u7684\u4ea4\u6613\u4e2d\uff0c\u67098\u6b21\u4ea4\u6613\u8d2d\u4e70\u4e863\u7c7b\u5546\u54c1\uff1b\u6700\u540e\u4e00\u5217\u7684(14\uff0c64)\u8868\u793a\u5728\u6240\u6709\u7684\u4ea4\u6613\u4e2d\uff0c\u670964\u6b21\u4ea4\u6613\u8d2d\u4e70\u4e8614\u7c7b\u5546\u54c1\u3002\u4ece\u4e0b\u9762\u7684\u4e3b\u8981\u63cf\u8ff0\u6027\u7edf\u8ba1\u91cf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5feb\u901f\u7684\u770b\u51fa\u5927\u7ea6\u4e00\u534a\u7684\u4ea4\u6613\u5546\u54c1\u6570\u572811\u7c7b\u5de6\u53f3\u3002<\/p>\n<div class=\"figure\">\n<img decoding=\"async\" src=\"summary_2.png\" \/>\n\n<\/div>\n<p><br><\/p>\n<p>\u2003\u2003\u7efc\u4e0a\u6240\u8ff0\uff0c\u6211\u4eec\u901a\u8fc7<strong>summary()<\/strong>\u51fd\u6570\u8fd4\u56de\u7684\u4fe1\u606f\u53ef\u4ee5\u5927\u4f53\u7684\u4e86\u89e3\u4ea4\u6613\u6570\u636e\u7684\u60c5\u51b5\uff0c\u4f46\u662f\u5e76\u4e0d\u80fd\u6e05\u6d17\u7684\u770b\u5230\u6bcf\u4e00\u6761\u4ea4\u6613\u7684\u5177\u4f53\u5185\u5bb9\u3002\u8981\u60f3\u67e5\u770b\u6bcf\u6761\u4ea4\u6613\u7684\u5185\u5bb9\u4e5f\u5f88\u7b80\u5355\uff0c\u5728arules\u7a0b\u5e8f\u5305\u4e2d\u63d0\u4f9b\u4e86<strong>inspect()<\/strong>\u51fd\u6570\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5feb\u901f\u67e5\u770b\u81ea\u5b9a\u4e49\u7684\u4ea4\u6613\u5185\u5bb9\uff1a<\/p>\n<div class=\"sourceCode\"><pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span class=\"kw\">inspect<\/span>(groceries[<span class=\"kw\">c<\/span>(<span class=\"dv\">4<\/span>, <span class=\"dv\">9<\/span>)]) <span class=\"co\"># \u67e5\u770b\u7b2c4\u30019\u6b21\u4ea4\u6613\u7684\u5185\u5bb9<\/span><\/code><\/pre><\/div>\n<pre><code>##     items                                            \n## [1] {all- purpose,juice,lunch meat,soda,toilet paper}\n## [2] {coffee\/tea,dishwashing liquid\/detergent,poultry}<\/code><\/pre>\n<p>\u2003\u2003\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u7684\u7b80\u5355\u7684\u6570\u636e\u63a2\u7d22\u5c31\u7ed3\u675f\u4e86\u3002\u90a3\u4e48\u5c31\u6709\u540c\u5b66\u63d0\u51fa\u610f\u89c1\u4e86\uff0c\u8bf4\u8001\u5e08\u8bf4\u8fc7\u63a2\u7d22\u6570\u636e\u7684\u4f18\u5148\u987a\u5e8f\u4e0d\u662f\u56fe\u3001\u8868\u3001\u6587\u5b57\u5417\uff0c\u90a3\u4e48\u80af\u5b9a\u662f\u7528\u56fe\u624d\u80fd\u751f\u52a8\u5f62\u8c61\u7684\u63cf\u8ff0\u6570\u636e\u554a\u3002\u90a3\u4e48\u63a5\u4e0b\u6765\u6211\u4eec\u5c31\u5bf9\u6570\u636e\u8fdb\u884c\u4e00\u5b9a\u7684\u53ef\u89c6\u5316\uff0c\u53bb\u5e2e\u52a9\u5927\u5bb6\u66f4\u52a0\u5f62\u8c61\u7684\u4e86\u89e3\u6570\u636e\uff1a<\/p>\n<\/div>\n<div class=\"section level2 tabset tabset-fade tabset-pills\">\n<h2><span class=\"header-section-number\">3.2<\/span> \u53ef\u89c6\u5316\u63a2\u7d22<\/h2>\n<div id=\"itemfrequencyplot\" class=\"section level3\">\n<h3><span class=\"header-section-number\">3.2.1<\/span> itemFrequencyPlot()<\/h3>\n<p><font size=4 face=\"\u5fae\u8f6f\u96c5\u9ed1\"><\/p>\n<p>\u2003\u2003\u9996\u5148\u5462\uff0c\u6211\u4eec\u5148\u53bb\u53ef\u89c6\u5316\u4ea4\u6613\u6570\u636e\u4e2d\u5927\u5bb6\u7ecf\u5e38\u8d2d\u4e70\u7684\u5546\u54c1\uff0c\u53bb\u770b\u770b\u5230\u5e95\u90a3\u4e9b\u5546\u54c1\u7ecf\u5e38\u51fa\u73b0\u5728\u5927\u5bb6\u7684\u8d2d\u7269\u6e05\u5355\u4e2d\uff0c\u8fd9\u6837\u4e5f\u53ef\u4ee5\u95f4\u63a5\u7684\u8bf4\u660e\u8d85\u5e02\u7684\u8fd9\u4e9b\u5546\u54c1\u6700\u597d\u4e0d\u8981\u7f3a\u8d27\u3002\u5728\u53ef\u89c6\u5316\u5546\u54c1\u4ea4\u6613\u9891\u7387\u65f6\uff0c\u6211\u4eec\u4f7f\u7528\u7684\u662farules\u7a0b\u5e8f\u5305\u4e2d\u63d0\u4f9b\u7684<strong>itemFrequencyPlot()<\/strong>\u51fd\u6570\u3002<\/p>\n<div class=\"sourceCode\"><pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span class=\"co\"># \u7ed8\u5236\u652f\u6301\u5ea6\u6700\u9ad8\u7684\u524d\u5341\u7c7b\u5546\u54c1\uff0c\u5e76\u6309\u964d\u5e8f\u6392\u5217<\/span>\n<span class=\"kw\">itemFrequencyPlot<\/span>(groceries, <span class=\"dt\">topN =<\/span> <span class=\"dv\">10<\/span>)<\/code><\/pre><\/div>\n<p><img decoding=\"async\" src=\"1-apriori_files\/figure-html\/unnamed-chunk-3-1.png\" width=\"672\" \/><\/p>\n<\/div>\n<div id=\"image\" class=\"section level3\">\n<h3><span class=\"header-section-number\">3.2.2<\/span> image()<\/h3>\n<p><font size=4 face=\"\u5fae\u8f6f\u96c5\u9ed1\"><\/p>\n<p>\u2003\u2003\u5982\u679c\u4f60\u60f3\u53ef\u89c6\u5316\u4ea4\u6613\u6570\u636e\u7684\u7a00\u758f\u77e9\u9635\uff0c\u53ef\u4ee5\u4f7f\u7528arules\u7a0b\u5e8f\u5305\u4e2d\u63d0\u4f9b\u7684<strong>image()<\/strong>\u51fd\u6570\u3002\u8be5\u51fd\u6570\u4f1a\u8fd4\u56de\u4e00\u4e2a\u77e9\u9635\u56fe\uff0c\u8be5\u56fe\u4e2d\u7684\u9ed1\u70b9\u8868\u660e\u5b58\u5728\u4ea4\u6613\u7684\u8bb0\u5f55(\u5373\u8be5\u5546\u54c1\u5728\u6b64\u4ea4\u6613\u4e2d\u88ab\u8d2d\u4e70\u4e86)\uff0c\u7a7a\u767d\u7684\u4f4d\u7f6e\u5373\u6ca1\u6709\u4ea4\u6613\u7684\u8bb0\u5f55\u3002<\/p>\n<div class=\"sourceCode\"><pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span class=\"kw\">image<\/span>(groceries[<span class=\"dv\">1<\/span>:<span class=\"dv\">10<\/span>, ]) <span class=\"co\"># \u53ef\u89c6\u5316\u4ea4\u6613\u6570\u636e\u7684\u7a00\u758f\u77e9\u9635<\/span><\/code><\/pre><\/div>\n<p><img decoding=\"async\" src=\"1-apriori_files\/figure-html\/unnamed-chunk-4-1.png\" width=\"672\" \/><\/p>\n<\/div>\n<\/div>\n<div class=\"section level2\">\n<h2><span class=\"header-section-number\">3.3<\/span> \u8bad\u7ec3\u6a21\u578b<\/h2>\n<p>\u2003\u2003\u73b0\u5728\u5df2\u7ecf\u628a\u6570\u636e\u6574\u7406\u4e3a\u4e86\u9002\u7528\u4e8eapriori\u7b97\u6cd5\u7684\u7c7b\u578b\uff0c\u5e76\u4e14\u4e5f\u5bf9\u6570\u636e\u6709\u4e86\u7b80\u7b54\u7684\u4e86\u89e3\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u5c31\u5f00\u59cb\u63a2\u5bfb\u8d2d\u7269\u8f66\u4e2d\u5546\u54c1\u4e4b\u95f4\u7684\u5173\u8054\uff1a<\/p>\n<div class=\"sourceCode\"><pre class=\"sourceCode r\"><code class=\"sourceCode r\">rules &lt;-<span class=\"st\"> <\/span><span class=\"kw\">apriori<\/span>(groceries, \n                 <span class=\"dt\">parameter =<\/span> <span class=\"kw\">list<\/span>(<span class=\"dt\">minlen =<\/span> <span class=\"dv\">2<\/span>,  <span class=\"co\"># \u89c4\u5219\u7684\u6700\u4f4e\u9891\u6570\u4e3a2<\/span>\n                                  <span class=\"dt\">maxlen =<\/span> <span class=\"dv\">4<\/span>,  <span class=\"co\"># \u89c4\u5219\u7684\u6700\u9ad8\u9891\u6570\u4e3a4<\/span>\n                                  <span class=\"dt\">supp =<\/span> <span class=\"fl\">0.01<\/span>, <span class=\"co\"># \u652f\u6301\u5ea6\u8bbe\u7f6e\u4e3a0.001<\/span>\n                                  <span class=\"dt\">conf =<\/span> <span class=\"fl\">0.5<\/span>)) <span class=\"co\"># \u7f6e\u4fe1\u5ea6\u8bbe\u7f6e\u4e3a0.001<\/span><\/code><\/pre><\/div>\n<pre><code>## Apriori\n## \n## Parameter specification:\n##  confidence minval smax arem  aval originalSupport maxtime support minlen\n##         0.5    0.1    1 none FALSE            TRUE       5    0.01      2\n##  maxlen target   ext\n##       4  rules FALSE\n## \n## Algorithmic control:\n##  filter tree heap memopt load sort verbose\n##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE\n## \n## Absolute minimum support count: 14 \n## \n## set item appearances ...[0 item(s)] done [0.00s].\n## set transactions ...[38 item(s), 1499 transaction(s)] done [0.00s].\n## sorting and recoding items ... [38 item(s)] done [0.00s].\n## creating transaction tree ... done [0.00s].\n## checking subsets of size 1 2 3 4 done [0.01s].\n## writing ... [4910 rule(s)] done [0.00s].\n## creating S4 object  ... done [0.00s].<\/code><\/pre>\n<div class=\"sourceCode\"><pre class=\"sourceCode r\"><code class=\"sourceCode r\">rules<\/code><\/pre><\/div>\n<pre><code>## set of 4910 rules<\/code><\/pre>\n<p>\u2003\u2003\u6211\u4eec\u6839\u636e\u8bbe\u7f6e\u597d\u7684\u53c2\u6570\u5bf9\u6570\u636e\u6784\u5efa\u5173\u8054\u89c4\u5219\uff0c\u6700\u540e\u6839\u636e\u8fd4\u56de\u7684\u7ed3\u679c\u5f97\u77e5\u5171\u5efa\u7acb\u4e864910\u6761\u89c4\u5219\u3002\u4e0b\u9762\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u53bb\u7b5b\u9009\u6709\u7528\u7684\u89c4\u5219\u3002<\/p>\n<p><strong>\u4e00\u822c\u6709\u4e09\u4e2a\u9700\u6c42\uff1a<\/strong><\/p>\n<ul>\n<li>\u66f4\u5173\u6ce8\u5173\u8054\u9879\u96c6\u5728\u603b\u4f53\u4e2d\u6240\u5360\u6bd4\u91cd[\u6839\u636e\u652f\u6301\u5ea6\u5bf9\u89c4\u5219\u8fdb\u884c\u964d\u5e8f\u6392\u5217]<\/li>\n<li>\u66f4\u6ce8\u91cd\u89c4\u5219\u672c\u8eab\u7684\u53ef\u9760\u6027[\u6839\u636e\u7f6e\u4fe1\u5ea6\u5bf9\u89c4\u5219\u8fdb\u884c\u964d\u5e8f\u6392\u5217]<\/li>\n<li>\u66f4\u5173\u6ce8\u5173\u8054\u89c4\u5219\u7684\u53ef\u9760\u6027[\u6839\u636e\u63d0\u5347\u5ea6\u5bf9\u89c4\u5219\u8fdb\u884c\u964d\u5e8f\u6392\u5217]<\/li>\n<\/ul>\n<p>\u2003\u2003\u6211\u4eec\u9996\u5148\u89c2\u67e5\u4e00\u4e0b\u524d3\u4e2a\u89c4\u5219\uff0c\u7136\u540e\u5047\u8bbe\u6211\u4eec\u66f4\u5173\u6ce8\u5173\u8054\u89c4\u5219\u7684\u53ef\u9760\u6027\uff0c\u90a3\u4e48\u6211\u4eec\u6309\u7167\u63d0\u5347\u5ea6\u5bf9\u89c4\u5219\u8fdb\u884c\u964d\u5e8f\u6392\u5217\uff1a<\/p>\n<div class=\"sourceCode\"><pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span class=\"kw\">inspect<\/span>(rules[<span class=\"dv\">1<\/span>:<span class=\"dv\">3<\/span>]) <span class=\"co\"># \u89c2\u5bdf\u524d\u4e09\u4e2a\u89c4\u5219<\/span><\/code><\/pre><\/div>\n<pre><code>##     lhs            rhs          support   confidence lift     \n## [1] {hand soap} =&gt; {vegetables} 0.1407605 0.5926966  0.9926841\n## [2] {tortillas} =&gt; {vegetables} 0.1460974 0.5983607  1.0021705\n## [3] {shampoo}   =&gt; {vegetables} 0.1454303 0.5860215  0.9815042<\/code><\/pre>\n<div class=\"sourceCode\"><pre class=\"sourceCode r\"><code class=\"sourceCode r\">rules2 &lt;-<span class=\"st\"> <\/span><span class=\"kw\">sort<\/span>(rules, <span class=\"dt\">by =<\/span> <span class=\"st\">&quot;lift&quot;<\/span>, <span class=\"dt\">decreasing =<\/span> T) <span class=\"co\"># \u6309\u7167\u63d0\u5347\u5ea6\u5bf9\u89c4\u5219\u8fdb\u884c\u964d\u5e8f\u6392\u5217<\/span>\n<span class=\"kw\">inspect<\/span>(rules2[<span class=\"dv\">1<\/span>:<span class=\"dv\">5<\/span>])                               <span class=\"co\"># \u89c2\u5bdf\u524d\u4e94\u4e2a\u89c4\u5219<\/span><\/code><\/pre><\/div>\n<pre><code>##     lhs                                     rhs               support   \n## [1] {hand soap,individual meals,waffles} =&gt; {cheeses}         0.01000667\n## [2] {aluminum foil,milk,sandwich loaves} =&gt; {tortillas}       0.01000667\n## [3] {ice cream,paper towels,soda}        =&gt; {aluminum foil}   0.01000667\n## [4] {paper towels,shampoo,soap}          =&gt; {sandwich loaves} 0.01000667\n## [5] {bagels,beef,pasta}                  =&gt; {milk}            0.01000667\n##     confidence lift    \n## [1] 0.6250000  2.402244\n## [2] 0.5555556  2.275349\n## [3] 0.6000000  2.271212\n## [4] 0.5555556  2.232648\n## [5] 0.6000000  2.215271<\/code><\/pre>\n<p>\u2003\u2003\u8fd4\u56de\u7ed3\u679c\u7684lhs\u548crhs\u6240\u5bf9\u5e94\u7684\u5217\u5206\u522b\u662f\u89c4\u5219\u7684\u524d\u9879(\u89e6\u53d1\u89c4\u5219\u9700\u8981\u7684\u6761\u4ef6)\u548c\u540e\u9879(\u6ee1\u8db3\u89e6\u53d1\u6761\u4ef6\u7684\u9884\u671f\u7ed3\u679c)\u3002<\/p>\n<p>\u2003\u2003\u6bd4\u5982\u89c4\u5219\u7684\u7b2c\u4e94\u6761\uff0c\u7528\u901a\u4fd7\u7684\u8bed\u8a00\u6765\u8bb2\u5c31\u662f\uff1a\u201c\u5982\u679c\u67d0\u987e\u5ba2\u8d2d\u4e70\u4e86\u767e\u5409\u997c\u3001\u725b\u8089\u548c\u610f\u5927\u5229\u9762\uff0c\u90a3\u4e48\u4ed6\u8fd8\u53ef\u80fd\u8d2d\u4e70\u725b\u5976\u3002\u201d<\/p>\n<ul>\n<li>\u8fd9\u6761\u89c4\u5219\u7684\u652f\u6301\u5ea6\u4e3a0.01\uff0c\u5373\u6b64\u79cd\u4ea4\u6613\u73b0\u8c61\u5728\u6240\u6709\u7684\u4ea4\u6613\u4e2d\u51fa\u73b0\u7684\u5360\u6bd4\u5927\u7ea6\u4e3a1%<\/li>\n<li>\u7f6e\u4fe1\u5ea6\u4e3a0.6\uff0c\u5373\u524d\u9879\u51fa\u73b0\u7684\u60c5\u51b5\u4e0b\uff0c\u540e\u9879\u4e5f\u53d1\u751f\u7684\u6982\u7387\u4e3a60%<\/li>\n<li>\u63d0\u5347\u5ea6\u4e3a2.4\uff0c\u63d0\u5347\u5ea6\u5927\u4e8e1\uff0c\u5373\u6b64\u89c4\u5219\u7684\u53ef\u9760\u6027\u4e0d\u9519<\/li>\n<\/ul>\n<p>\u2003\u2003\u4e0a\u8ff0\u89c4\u5219\u770b\u8d77\u6765\u8fd8\u662f\u633a\u548c\u8c10\u7684\uff0c\u4f46\u662f\u54b1\u4eec\u518d\u770b\u770b\u7b2c\u4e00\u6761\u89c4\u5219\uff1a\u201c\u5982\u679c\u67d0\u987e\u5ba2\u8d2d\u4e70\u4e86\u9999\u7682\u3001\u5355\u4eba\u9910\u548c\u534e\u592b\u997c\uff0c\u90a3\u4e48\u4ed6\u8fd8\u53ef\u80fd\u8d2d\u4e70\u5976\u916a\u3002\u201d\u8fd9\u6837\u7684\u89c4\u5219\u770b\u8d77\u6765\u5c31\u4ee4\u4eba\u8d39\u89e3\u4e86\uff0c\u8fd9\u6837\u7684\u89c4\u5219\u8c8c\u4f3c\u6ca1\u6709\u4e00\u4e2a\u5408\u7406\u7684\u903b\u8f91\u53bb\u89e3\u91ca\uff0c\u4f46\u662f\u6570\u636e\u53c8\u4e3a\u89c4\u5219\u63d0\u4f9b\u4e86\u4e00\u5b9a\u7684\u4f9d\u636e\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u4e00\u822c\u4f1a\u628a\u4ea7\u751f\u7684\u89c4\u5219\u5206\u4e3a3\u7c7b\uff1a<\/p>\n<ul>\n<li>\u53ef\u884c\u7684\u89c4\u5219[\u76f4\u63a5\u5e94\u7528\u4e8e\u5e02\u573a]<\/li>\n<li>\u5e73\u51e1\u7684\u89c4\u5219[\u65e0\u9700\u7406\u4f1a]<\/li>\n<li>\u4e0d\u660e\u7684\u89c4\u5219[\u4e0d\u91c7\u7528\u6216\u8005\u4f5c\u4e3a\u5c1d\u8bd5]<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"section level1\">\n<h1><span class=\"header-section-number\">4<\/span> \u603b\u7ed3<\/h1>\n<hr \/>\n<p>\u2003\u2003\u5173\u8054\u89c4\u5219\u662f\u89e3\u51b3\u5927\u6570\u636e\u95ee\u9898\u7684\u4e00\u79cd\u65e0\u76d1\u7763\u5b66\u4e60\u7684\u7b97\u6cd5\uff0c\u5b83\u53ef\u4ee5\u4ece\u4efb\u4f55\u5173\u4e8e\u6a21\u5f0f\u7684\u5148\u9a8c\u77e5\u8bc6\u7684\u5927\u578b\u6570\u636e\u5e93\u4e2d\u63d0\u53d6\u77e5\u8bc6\u3002\u6bcf\u4e2d\u4e0d\u8db3\u7684\u662f\uff0c\u5c06\u5927\u91cf\u7684\u4fe1\u606f\u7f29\u51cf\u6210\u66f4\u5c0f\u3001\u66f4\u5bb9\u6613\u4e8e\u7ba1\u7406\u7684\u7ed3\u679c\u96c6\u9700\u8981\u4e00\u4e9b\u52aa\u529b\u3002\u672c\u8282\u7814\u7a76\u7684Apriori\u7b97\u6cd5\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u5174\u8da3\u5ea6\u7684\u6700\u5c0f\u9608\u503c\u548c\u53ea\u5448\u73b0\u6ee1\u8db3\u8fd9\u4e9b\u51c6\u5219\u7684\u5173\u8054\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<p>\u2003\u2003\u8fd8\u6709\u4e00\u70b9\u5c31\u662f\u73b0\u5b9e\u4e2d\u7684\u6570\u636e\u662f\u5e9e\u5927\u7684\uff0c\u5f88\u5bb9\u6613\u4ea7\u751f\u4e0a\u4ebf\u7684\u89c4\u5219\uff0c\u8fd9\u4e2a\u89c4\u5219\u7684\u8bc4\u4f30\u548c\u68c0\u9a8c\u4f9d\u65e7\u662f\u4e00\u4e2a\u5f88\u96be\u89e3\u51b3\u7684\u95ee\u9898\u3002<\/p>\n<\/div>\n<div class=\"section level1\">\n<h1><span class=\"header-section-number\">5<\/span> \u53c2\u8003\u6587\u732e<\/h1>\n<hr \/>\n<p>[1] BrettLantz. \u673a\u5668\u5b66\u4e60\u4e0eR\u8bed\u8a00[M]. \u673a\u68b0\u5de5\u4e1a\u51fa\u7248\u793e, 2015.<br> [2] \u5173\u8054\u89c4\u5219\u6316\u6398\u7b97\u6cd5\u4e4bApriori\u7b97\u6cd5.<a href=\"https:\/\/www.cnblogs.com\/nxld\/p\/6380417.html\" class=\"uri\">https:\/\/www.cnblogs.com\/nxld\/p\/6380417.html<\/a>. 2017.<br> [3] \u57fa\u4e8eR\u8bed\u8a00\u7684\u5173\u8054\u89c4\u5219\u5b9e\u73b0.<a href=\"https:\/\/mp.weixin.qq.com\/s?__biz=MzIxNjA2ODUzNg\" class=\"uri\">https:\/\/mp.weixin.qq.com\/s?__biz=MzIxNjA2ODUzNg<\/a>==&amp;mid=400031158&amp;idx=1&amp;sn=2653f5711ab71d4a89be4287e60ba32e&amp;mpshare=1&amp;scene=23&amp;srcid=0618mZy2UVsGWjtV0vkqpYE5#rd.2015<\/p>\n<p><\/font><\/p>\n<\/div>\n\n\n\n<\/div>\n<\/div>\n\n<\/div>\n\n<script>\n\n\/\/ add bootstrap table styles to pandoc tables\nfunction bootstrapStylePandocTables() {\n  $('tr.header').parent('thead').parent('table').addClass('table table-condensed');\n}\n$(document).ready(function () {\n  bootstrapStylePandocTables();\n});\n\n\n<\/script>\n\n<!-- dynamically load mathjax for compatibility with self-contained -->\n<script>\n  (function () {\n    var script = document.createElement(\"script\");\n    script.type = \"text\/javascript\";\n    script.src  = \"https:\/\/mathjax.rstudio.com\/latest\/MathJax.js?config=TeX-AMS-MML_HTMLorMML\";\n    document.getElementsByTagName(\"head\")[0].appendChild(script);\n  })();\n<\/script>\n\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u8054\u89c4\u5219 Code Show All C [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"full-width-container","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[7],"tags":[8,12,10],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry","category-7","tag-r","tag-12","tag-10"],"acf":[],"jetpack_featured_media_url":"","uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"wtxiong","author_link":"https:\/\/byecampus.com\/index.php\/author\/wtxiong\/"},"uagb_comment_info":0,"uagb_excerpt":"\u5173\u8054\u89c4\u5219 Code Show All C [&hellip;]","_links":{"self":[{"href":"https:\/\/byecampus.com\/index.php\/wp-json\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/byecampus.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/byecampus.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/byecampus.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/byecampus.com\/index.php\/wp-json\/wp\/v2\/comments?post=319"}],"version-history":[{"count":1,"href":"https:\/\/byecampus.com\/index.php\/wp-json\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":320,"href":"https:\/\/byecampus.com\/index.php\/wp-json\/wp\/v2\/posts\/319\/revisions\/320"}],"wp:attachment":[{"href":"https:\/\/byecampus.com\/index.php\/wp-json\/wp\/v2\/media?parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/byecampus.com\/index.php\/wp-json\/wp\/v2\/categories?post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/byecampus.com\/index.php\/wp-json\/wp\/v2\/tags?post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}