{"id":2029,"date":"2017-10-13T11:10:16","date_gmt":"2017-10-13T11:10:16","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2029"},"modified":"2017-10-13T14:05:20","modified_gmt":"2017-10-13T06:05:20","slug":"%e9%9d%a0%e6%8e%92%e7%85%a7%e7%89%87%e5%92%8c%e6%8b%8d%e8%a7%86%e9%a2%91%e5%81%9a%e5%88%b0%e6%9c%88%e5%85%a510%e4%b8%87-8","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2029","title":{"rendered":"Scikit-learn\u4e4b\u51b3\u7b56\u6811"},"content":{"rendered":"<p>\n\t\u51b3\u7b56\u6811\u5728\u5b66\u4e60\u5e94\u7528\u4e2d\u975e\u5e38\u6709\u7528\uff0c\u63a5\u4e0b\u6765\u7ed9\u5927\u5bb6\u5206\u4eab\u4e00\u4e0b\u81ea\u5df1\u6709\u5173\u4e8e\u51b3\u7b56\u6811\u7684\u4e00\u4e9b\u60f3\u6cd5\uff01\n<\/p>\n<h2>\n\t\u51b3\u7b56\u6811\u6982\u8ff0<br \/>\n<\/h2>\n<p>\n\t\u51b3\u7b56\u6811\u662f\u4e00\u4e2a\u975e\u53c2\u6570\u7684\u76d1\u7763\u5f0f\u5b66\u4e60\u65b9\u6cd5\uff0c\u4e3b\u8981\u7528\u4e8e\u5206\u7c7b\u548c\u56de\u5f52\u3002\u7b97\u6cd5\u7684\u76ee\u6807\u662f\u901a\u8fc7\u63a8\u65ad\u6570\u636e\u7279\u5f81\uff0c\u5b66\u4e60\u51b3\u7b56\u89c4\u5219\u4ece\u800c\u521b\u5efa\u4e00\u4e2a\u9884\u6d4b\u76ee\u6807\u53d8\u91cf\u7684\u6a21\u578b\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u51b3\u7b56\u6811\u901a\u8fc7\u4e00\u7cfb\u5217if-then-else \u51b3\u7b56\u89c4\u5219 \u8fd1\u4f3c\u4f30\u8ba1\u4e00\u4e2a\u6b63\u5f26\u66f2\u7ebf\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u51b3\u7b56\u6811\u901a\u8fc7\u4e00\u7cfb\u5217if-then-else \u51b3\u7b56\u89c4\u5219\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201709\/22\/1506073110_142545.png\" style=\"width: 569px;height: 447px\" \/>\n<\/p>\n<h2>\n\t\u51b3\u7b56\u6811\u7684\u4f18\u52bf<br \/>\n<\/h2>\n<ol>\n<li>\n\t\t\u7b80\u5355\u6613\u61c2\uff0c\u539f\u7406\u6e05\u6670\uff0c\u51b3\u7b56\u6811\u53ef\u4ee5\u5b9e\u73b0\u53ef\u89c6\u5316\uff1b\n\t<\/li>\n<li>\n\t\t\u6570\u636e\u51c6\u5907\u7b80\u5355\u3002\u5176\u4ed6\u7684\u65b9\u6cd5\u9700\u8981\u5b9e\u73b0\u6570\u636e\u5f52\u4e00\u5316\uff0c\u521b\u5efa\u865a\u62df\u53d8\u91cf\uff0c\u5220\u9664\u7a7a\u767d\u53d8\u91cf\uff1b\n\t<\/li>\n<li>\n\t\t\u4f7f\u7528\u51b3\u7b56\u6811\u7684\u4ee3\u4ef7\u662f\u6570\u636e\u70b9\u7684\u5bf9\u6570\u7ea7\u522b\uff1b\n\t<\/li>\n<li>\n\t\t\u80fd\u591f\u5904\u7406\u6570\u503c\u548c\u5206\u7c7b\u6570\u636e\uff1b\n\t<\/li>\n<li>\n\t\t\u80fd\u591f\u5904\u7406\u591a\u8def\u8f93\u51fa\u95ee\u9898\uff1b\n\t<\/li>\n<li>\n\t\t\u4f7f\u7528\u767d\u76d2\u5b50\u6a21\u578b(\u5185\u90e8\u7ed3\u6784\u53ef\u4ee5\u76f4\u63a5\u89c2\u6d4b\u7684\u6a21\u578b)\u3002\u4e00\u4e2a\u7ed9\u5b9a\u7684\u60c5\u51b5\u662f\u53ef\u4ee5\u89c2\u6d4b\u7684\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u7528\u5e03\u5c14\u903b\u8f91\u89e3\u91ca\u8fd9\u4e2a\u7ed3\u679c\u3002\u76f8\u53cd\uff0c\u5982\u679c\u5728\u4e00\u4e2a\u9ed1\u76d2\u6a21\u578b(ANN)\uff0c\u7ed3\u679c\u53ef\u80fd\u5f88\u96be\u89e3\u91ca\uff1b\n\t<\/li>\n<li>\n\t\t\u53ef\u4ee5\u901a\u8fc7\u7edf\u8ba1\u5b66\u68c0\u9a8c\u9a8c\u8bc1\u6a21\u578b\u3002\u8fd9\u4e5f\u4f7f\u5f97\u6a21\u578b\u7684\u53ef\u9760\u6027\u8ba1\u7b97\u53d8\u5f97\u53ef\u80fd\uff1b\n\t<\/li>\n<\/ol>\n<h2>\n\t\u51b3\u7b56\u6811\u7684\u52a3\u52bf<br \/>\n<\/h2>\n<ol>\n<li>\n\t\t\u53ef\u80fd\u4f1a\u5efa\u7acb\u8fc7\u4e8e\u590d\u6742\u7684\u89c4\u5219\uff0c\u5373\u8fc7\u62df\u5408\u3002\u4e3a\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff0c\u526a\u679d\u3001\u8bbe\u7f6e\u53f6\u8282\u70b9\u7684\u6700\u5c0f\u6837\u672c\u6570\u91cf\u3001\u8bbe\u7f6e\u51b3\u7b56\u6811\u7684\u6700\u5927\u6df1\u5ea6\u6709\u65f6\u5019\u662f\u5fc5\u8981\u7684\uff1b\n\t<\/li>\n<li>\n\t\t\u51b3\u7b56\u6811\u6709\u65f6\u5019\u662f\u4e0d\u7a33\u5b9a\u7684\uff0c\u56e0\u4e3a\u6570\u636e\u5fae\u5c0f\u7684\u53d8\u52a8\uff0c\u53ef\u80fd\u751f\u6210\u5b8c\u5168\u4e0d\u540c\u7684\u51b3\u7b56\u6811\u3002 \u53ef\u4ee5\u901a\u8fc7\u603b\u4f53\u5e73\u5747(ensemble)\u51cf\u7f13\u8fd9\u4e2a\u95ee\u9898\u3002\u5e94\u8be5\u6307\u7684\u662f\u591a\u6b21\u5b9e\u9a8c\uff1b\n\t<\/li>\n<li>\n\t\t\u5b66\u4e60\u6700\u4f18\u51b3\u7b56\u6811\u662f\u4e00\u4e2aNP\u5b8c\u5168\u95ee\u9898\u3002\u6240\u4ee5\uff0c\u5b9e\u9645\u51b3\u7b56\u6811\u5b66\u4e60\u7b97\u6cd5\u662f\u57fa\u4e8e\u8bd5\u63a2\u6027\u7b97\u6cd5\uff0c\u4f8b\u5982\u5728\u6bcf\u4e2a\u8282\u70b9\u5b9e\u73b0\u5c40\u90e8\u6700\u4f18\u503c\u7684\u8d2a\u5fc3\u7b97\u6cd5\u3002\u8fd9\u6837\u7684\u7b97\u6cd5\u662f\u65e0\u6cd5\u4fdd\u8bc1\u8fd4\u56de\u4e00\u4e2a\u5168\u5c40\u6700\u4f18\u7684\u51b3\u7b56\u6811\u3002\u53ef\u4ee5\u901a\u8fc7\u968f\u673a\u9009\u62e9\u7279\n\t<\/li>\n<li>\n\t\t\u5f81\u548c\u6837\u672c\u8bad\u7ec3\u591a\u4e2a\u51b3\u7b56\u6811\u6765\u7f13\u89e3\u8fd9\u4e2a\u95ee\u9898\uff1b\n\t<\/li>\n<li>\n\t\t\u6709\u4e9b\u95ee\u9898\u5b66\u4e60\u8d77\u6765\u975e\u5e38\u96be\uff0c\u56e0\u4e3a\u51b3\u7b56\u6811\u5f88\u96be\u8868\u8fbe\u3002\u5982\uff1a\u5f02\u6216\u95ee\u9898\u3001\u5947\u5076\u6821\u9a8c\u6216\u591a\u8def\u590d\u7528\u5668\u95ee\u9898\uff1b\n\t<\/li>\n<li>\n\t\t\u5982\u679c\u6709\u4e9b\u56e0\u7d20\u5360\u636e\u652f\u914d\u5730\u4f4d\uff0c\u51b3\u7b56\u6811\u662f\u6709\u504f\u7684\u3002\u56e0\u6b64\u5efa\u8bae\u5728\u62df\u5408\u51b3\u7b56\u6811\u4e4b\u524d\u5148\u5e73\u8861\u6570\u636e\u7684\u5f71\u54cd\u56e0\u5b50\u3002\n\t<\/li>\n<\/ol>\n<h2>\n\t\u51b3\u7b56\u6811\u5206\u7c7b<br \/>\n<\/h2>\n<p>\n\tDecisionTreeClassifier \u80fd\u591f\u5b9e\u73b0\u591a\u7c7b\u522b\u7684\u5206\u7c7b\u3002\u8f93\u5165\u4e24\u4e2a\u5411\u91cf\uff1a\u5411\u91cfX\uff0c\u5927\u5c0f\u4e3a[n_samples,n_features]\uff0c\u7528\u4e8e\u8bb0\u5f55\u8bad\u7ec3\u6837\u672c\uff1b\u5411\u91cfY\uff0c\u5927\u5c0f\u4e3a[n_samples]\uff0c\u7528\u4e8e\u5b58\u50a8\u8bad\u7ec3\u6837\u672c\u7684\u7c7b\u6807\u7b7e\u3002\n<\/p>\n<pre class=\"brush:python;\">\r\n&gt;&gt;&gt; from sklearn import tree\r\n&gt;&gt;&gt; X = [[0,0],[1,1]]\r\n&gt;&gt;&gt; Y = [0,1]\r\n&gt;&gt;&gt; clf = tree.DecisionTreeClassifier()\r\n&gt;&gt;&gt; clf = clf.ift(X,Y)\r\n&gt;&gt;&gt; clf.predict([[2.,2.]])\r\n&gt;&gt;&gt; clf.predict_prodb([[2.,2.]])<\/pre>\n<p>\n\t\u80fd\u591f\u5b9e\u73b0\u4e8c\u8fdb\u5236\u5206\u7c7b\u548c\u591a\u5206\u7c7b\u3002\u4f7f\u7528Isis\u6570\u636e\u96c6\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Isis\u6570\u636e\u96c6\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201709\/22\/1506073518_207542.png\" style=\"width: 555px;height: 295px\" \/>\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u5b89\u88c5Graphviz\u5c06\u5176\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201709\/22\/1506073561_91604.png\" style=\"width: 649px;height: 475px\" \/>\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Scikit-learn\u4e4b\u51b3\u7b56\u6811\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201709\/22\/1506073656_795101.png\" style=\"width: 615px;height: 483px\" \/>\n<\/p>\n<h2>\n\t\u51b3\u7b56\u6811\u56de\u5f52<br \/>\n<\/h2>\n<p>\n\t\u548c\u5206\u7c7b\u4e0d\u540c\u7684\u662f\u5411\u91cfy\u53ef\u4ee5\u662f\u6d6e\u70b9\u6570\uff1a\n<\/p>\n<pre class=\"brush:python;\">\r\n&gt;&gt;&gt; from sklearn import tree\r\n&gt;&gt;&gt; X = [[0,0],[2,2]]\r\n&gt;&gt;&gt; Y = [0.5,2.5]\r\n&gt;&gt;&gt; clf = tree.DecisionTreeClassifier()\r\n&gt;&gt;&gt; clf = clf.ift(X,Y)\r\n&gt;&gt;&gt; clf.predict([[1,1]])<\/pre>\n<p>\n\t\u672c\u6587\u524d\u9762\u63d0\u5230\u7684\u4f8b\u5b50\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u51b3\u7b56\u6811\u4ee3\u7801\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201709\/22\/1506074061_980085.png\" style=\"width: 607px;height: 646px\" \/>\n<\/p>\n<h2>\n\t\u591a\u8f93\u51fa\u95ee\u9898<br \/>\n<\/h2>\n<p>\n\t\u591a\u8f93\u51fa\u95ee\u9898\u65f6\u9700\u8981\u9884\u6d4b\u591a\u4e2a\u8f93\u51fa\u7684\u76d1\u7763\u5f0f\u5b66\u4e60\u95ee\u9898\u3002\u5373Y\u662f\u4e00\u4e2a2d\u7684\u5411\u91cf\uff0c\u5927\u5c0f\u4e3a[n_samples, n_outputs]\u3002\u5f53\u8f93\u51fa\u4e4b\u95f4\u4e0d\u76f8\u5173\u65f6\uff0c\u4e00\u4e2a\u7b80\u5355\u7684\u89e3\u51b3\u529e\u6cd5\u662f\u5efa\u7acbn\u4e2a\u72ec\u7acb\u6a21\u578b\u3002\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u8f93\u51fa\uff0c\u4f7f\u7528\u8fd9\u4e9b\u6a21\u578b\u72ec\u7acb\u9884\u6d4b\u8fd9\u6bcf\u4e2a\u8f93\u51fa\u3002\u7531\u4e8e\u8f93\u51fa\u662f\u548c\u76f8\u540c\u7684\u8f93\u5165\u76f8\u5173\u7684\uff0c\u6240\u4ee5\u4e00\u4e2a\u66f4\u597d\u7684\u529e\u6cd5\u662f\u5efa\u7acb\u4e00\u4e2a\u80fd\u591f\u6301\u7eed\u9884\u6d4b\u6240\u6709\u8f93\u51fa\u7684\u5355\u4e00\u6a21\u578b\u3002\u9996\u5148\uff0c\u7cfb\u7edf\u9700\u8981\u7684\u8bad\u7ec3\u65f6\u95f4\u66f4\u5c11\u4e86\uff0c\u56e0\u4e3a\u53ea\u5efa\u7acb\u4e86\u4e00\u4e2a\u6a21\u578b\u3002\u5176\u6b21\u51c6\u786e\u6027\u4e5f\u4f1a\u5f97\u5230\u63d0\u9ad8\u3002\n<\/p>\n<p>\n\t\u51b3\u7b56\u6811\u7684\u7b56\u7565\u9700\u8981\u4fee\u6539\u4ee5\u652f\u6301\u591a\u5206\u7c7b\u95ee\u9898\uff1a\n<\/p>\n<ol>\n<li>\n\t\t\u53f6\u5b50\u4e0a\u5b58\u50a8n\u4e2a\u8f93\u51fa\u53d8\u91cf\uff1b\n\t<\/li>\n<li>\n\t\t\u4f7f\u7528\u4e0d\u540c\u7684\u6807\u51c6\u8ba1\u7b97\u6240\u6709n\u8f93\u51fa\u7684\u5e73\u5747\u51cf\u5c11\u3002\n\t<\/li>\n<\/ol>\n<p>\n\t\u8fd9\u4e00\u8282\u662f\u5173\u4e8e DecisionTreeClassifier \u548cDecisionTreeRegressor\u7684\u4e00\u4e9b\u77e5\u8bc6\u70b9\u3002\u5982\u679c\u4e00\u4e2a\u51b3\u7b56\u6811\u7684\u8f93\u51fa\u5411\u91cfY\u5927\u5c0f\u4e3a[n_samples, n_outputs]\uff0c\u9884\u6d4b\u91cf\u6709\uff1a\n<\/p>\n<ol>\n<li>\n\t\tpredict\uff1a\u8f93\u51fan\u4e2a\u9884\u6d4b\u503c\n\t<\/li>\n<li>\n\t\tpredict_proba\uff1a\u8f93\u51fa\u6709n\u4e2a\u8f93\u51fa\u7684\u5411\u91cf\u7ec4\u6210\u7684\u5217\u8868\n\t<\/li>\n<\/ol>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2029\">Scikit-learn\u4e4b\u51b3\u7b56\u6811<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u51b3\u7b56\u6811\u5728\u5b66\u4e60\u5e94\u7528\u4e2d\u975e\u5e38\u6709\u7528\uff0c\u63a5\u4e0b\u6765\u7ed9\u5927\u5bb6\u5206\u4eab\u4e00\u4e0b\u81ea\u5df1\u6709\u5173\u4e8e\u51b3\u7b56\u6811\u7684\u4e00\u4e9b\u60f3\u6cd5\uff01 \u51b3\u7b56\u6811\u6982\u8ff0 \u51b3\u7b56\u6811\u662f\u4e00\u4e2a\u975e\u53c2\u6570\u7684 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118,6],"tags":[1210,1524,1525,75],"class_list":["post-2029","post","type-post","status-publish","format-standard","hentry","category-ndisdevelop","category-yyzt","tag-python","tag-scikit-learn","tag-1525","tag-75"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2029"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2029\/revisions"}],"predecessor-version":[{"id":2147,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2029\/revisions\/2147"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}