{"id":3112,"date":"2022-02-27T11:41:43","date_gmt":"2022-02-27T03:41:43","guid":{"rendered":"https:\/\/egonlin.com\/?p=3112"},"modified":"2022-02-27T11:43:34","modified_gmt":"2022-02-27T03:43:34","slug":"%e7%ac%ac%e4%ba%94%e8%8a%82%ef%bc%9a%e9%9d%9e%e7%ba%bf%e6%80%a7%e6%94%af%e6%8c%81%e5%90%91%e9%87%8f%e6%9c%ba%e9%b8%a2%e5%b0%be%e8%8a%b1%e5%88%86%e7%b1%bb%e8%87%aa%e5%ae%9a%e4%b9%89%e9%9a%8f","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=3112","title":{"rendered":"\u7b2c\u4e94\u8282\uff1a\u975e\u7ebf\u6027\u652f\u6301\u5411\u91cf\u673a(\u9e22\u5c3e\u82b1\u5206\u7c7b)+\u81ea\u5b9a\u4e49\u968f\u673a\u6570\u636e"},"content":{"rendered":"<h1>\u975e\u7ebf\u6027\u652f\u6301\u5411\u91cf\u673a(\u9e22\u5c3e\u82b1\u5206\u7c7b)+\u81ea\u5b9a\u4e49\u968f\u673a\u6570\u636e<\/h1>\n<h1>\u5bfc\u5165\u6a21\u5757<\/h1>\n<pre><code class=\"language-python\">import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom matplotlib.colors import ListedColormap\nfrom matplotlib.font_manager import FontProperties\nfrom sklearn import datasets\nfrom sklearn.svm import SVC\n%matplotlib inline\nfont = FontProperties(fname=&#039;\/Library\/Fonts\/Heiti.ttc&#039;)<\/code><\/pre>\n<h1>\u81ea\u5b9a\u4e49\u6570\u636e\u5206\u7c7b<\/h1>\n<h2>\u81ea\u5b9a\u4e49\u6570\u636e<\/h2>\n<pre><code class=\"language-python\"># \u4fdd\u8bc1\u968f\u673a\u6570\u4e0d\u91cd\u590d\nnp.random.seed(1)\n# \u521b\u5efa100\u4e2a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5373100\u4e2a2\u4e2a\u7279\u5f81\u7684\u6837\u672c\nX_custom = np.random.randn(100, 2)\n# np.logical_xor(bool1, bool2)\uff0c\u5f02\u6216\u903b\u8f91\u8fd0\u7b97\uff0c\u5982\u679cbool1\u548cbool2\u7684\u7ed3\u679c\u76f8\u540c\u5219\u4e3aFalse\uff0c\u5426\u5219\u4e3aTrue\n# ++\u548c--\u4e3a\u4e00\u4e09\u8c61\u9650\uff0c+-\u548c-+\u4e3a\u4e8c\u56db\u8c61\u9650\uff0c\u5982\u6b64\u505a\u5219100\u4e2a\u6837\u672c\u5fc5\u5b9a\u7ebf\u6027\u4e0d\u53ef\u5206\ny_custom = np.logical_xor(X_custom[:, 0] &gt; 0, X_custom[:, 1] &gt; 0)\n# \u4e8c\u56db\u8c61\u9650\u4e3aTrue\uff0c\u5373\u4e3a1\u7c7b\uff1b\u4e00\u4e09\u8c61\u9650\u4e3aFalse\uff0c\u5373\u4e3a-1\u7c7b\ny_custom = np.where(y_custom, 1, -1)<\/code><\/pre>\n<h2>\u6784\u5efa\u51b3\u7b56\u8fb9\u754c<\/h2>\n<pre><code class=\"language-python\">def plot_decision_regions(X, y, classifier=None):\n    marker_list = [&#039;o&#039;, &#039;x&#039;, &#039;s&#039;]\n    color_list = [&#039;r&#039;, &#039;b&#039;, &#039;g&#039;]\n    cmap = ListedColormap(color_list[:len(np.unique(y))])\n\n    x1_min, x1_max = X[:, 0].min()-1, X[:, 0].max()+1\n    x2_min, x2_max = X[:, 1].min()-1, X[:, 1].max()+1\n    t1 = np.linspace(x1_min, x1_max, 666)\n    t2 = np.linspace(x2_min, x2_max, 666)\n\n    x1, x2 = np.meshgrid(t1, t2)\n    y_hat = classifier.predict(np.array([x1.ravel(), x2.ravel()]).T)\n    y_hat = y_hat.reshape(x1.shape)\n    plt.contourf(x1, x2, y_hat, alpha=0.2, cmap=cmap)\n    plt.xlim(x1_min, x1_max)\n    plt.ylim(x2_min, x2_max)\n\n    for ind, clas in enumerate(np.unique(y)):\n        plt.scatter(X[y == clas, 0], X[y == clas, 1], alpha=0.8, s=50,\n                    c=color_list[ind], marker=marker_list[ind], label=clas)<\/code><\/pre>\n<h2>\u8bad\u7ec3\u6a21\u578b<\/h2>\n<p><\/p><div id=\"rml_readmorelogin_placeholder\" style=\"position:relative;\"><div id=\"rml_fade_content\" style=\"position: absolute;\r\ntop:-10em;\r\nwidth:100%;\r\nheight:10em;\r\nbackground: -webkit-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -moz-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -o-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -ms-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\"><\/div><div class=\"wpf-controller aru_rml_from_in_post\" style=\"background-color:#eeeeee;border:5px solid #cce6ff;\" id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><h2 id=\"Header\">\u67e5\u770b\u66f4\u591a<\/h2><div id=\"Message\"><p>\u8054\u7cfb\u7ba1\u7406\u5458\u5fae\u4fe1tutu19192010\uff0c\u6ce8\u518c\u8d26\u53f7<\/p>\n<\/div><div id=\"StatusBarHeader\"><\/div><form id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><input name=\"post_id\" value=\"3112\" type=\"hidden\"\/><input name=\"_init_callback\" value=\"InitLogin\" type=\"hidden\"\/><input name=\"post_id\" value=\"3112\" type=\"hidden\"\/><input name=\"rt_ype\" value=\"1\" type=\"hidden\"\/><input name=\"nonce\" value=\"35048f987f\" type=\"hidden\"\/><input name=\"_wpnonce\" value=\"ee095c8387\" type=\"hidden\"\/><input name=\"_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_proxy_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_view\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginView\" type=\"hidden\"\/><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\" width=\"400px\"><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Username:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"username\" value=\"\" type=\"text\"\/><\/td><\/tr><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Password:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"password\" value=\"\" type=\"password\"\/><\/td><\/tr><\/tbody><\/table><p class=\"wpf-table-placeholder submit\"><button class=\"wp_plugin_framework_ajax_button\" type=\"button\" style=\"background-color:#4D90FE;;color:#ffffff;;border:1px solid #3079ed;\" name=\"_event\" value=\"ButtonLogin\">Log in<\/button><\/p><\/td><td class=\"wpf-table-placeholder-input\"><\/td><\/tr><\/tbody><\/table><\/form><div id=\"ButtonStartRegister\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=register\">Register<\/a><\/div><div id=\"Link1\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=lostpassword\">Forgotten username or password?<\/a><\/div><div id=\"StatusBarFooter\"><\/div><\/div><\/div><div id=aru_remaining_content><\/div>","protected":false},"excerpt":{"rendered":"<p>\u975e\u7ebf\u6027\u652f\u6301\u5411\u91cf\u673a(\u9e22\u5c3e\u82b1\u5206\u7c7b)+\u81ea\u5b9a\u4e49\u968f\u673a\u6570\u636e \u5bfc\u5165\u6a21\u5757 import numpy as np import  [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":3094,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[276,291],"tags":[],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/3112"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3112"}],"version-history":[{"count":0,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/3112\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/media\/3094"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}