{"id":1019440,"date":"2024-12-27T13:00:03","date_gmt":"2024-12-27T05:00:03","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1019440.html"},"modified":"2024-12-27T13:00:19","modified_gmt":"2024-12-27T05:00:19","slug":"python%e5%a6%82%e4%bd%95%e7%bb%98%e5%88%b6%e8%b6%85%e5%b9%b3%e9%9d%a2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1019440.html","title":{"rendered":"python\u5982\u4f55\u7ed8\u5236\u8d85\u5e73\u9762"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25161940\/2a7f4a6d-86d3-48f8-8e51-e57d529813d8.webp\" alt=\"python\u5982\u4f55\u7ed8\u5236\u8d85\u5e73\u9762\" \/><\/p>\n<p><p> \u8981\u5728Python\u4e2d\u7ed8\u5236\u8d85\u5e73\u9762\uff0c\u9996\u5148\u9700\u8981\u7406\u89e3\u8d85\u5e73\u9762\u662f\u4ec0\u4e48\u4ee5\u53ca\u5982\u4f55\u5728\u9ad8\u7ef4\u7a7a\u95f4\u4e2d\u8868\u793a\u5b83\u3002<strong>\u8d85\u5e73\u9762\u662f\u4e00\u4e2an-1\u7ef4\u7684\u5b50\u7a7a\u95f4\uff0c\u5b83\u53ef\u4ee5\u5c06n\u7ef4\u7a7a\u95f4\u5206\u6210\u4e24\u4e2a\u90e8\u5206<\/strong>\u3002\u5728\u4e8c\u7ef4\u7a7a\u95f4\u4e2d\uff0c\u8d85\u5e73\u9762\u662f\u76f4\u7ebf\uff1b\u5728\u4e09\u7ef4\u7a7a\u95f4\u4e2d\uff0c\u8d85\u5e73\u9762\u662f\u5e73\u9762\u3002\u4e3a\u4e86\u7ed8\u5236\u8d85\u5e73\u9762\uff0c\u901a\u5e38\u9700\u8981\u4f7f\u7528\u5408\u9002\u7684Python\u5e93\uff0c\u5982Matplotlib\u548cNumpy\u3002<strong>\u9996\u5148\u9700\u8981\u5b9a\u4e49\u8d85\u5e73\u9762\u7684\u65b9\u7a0b\uff0c\u7136\u540e\u4f7f\u7528\u8fd9\u4e9b\u5e93\u6765\u53ef\u89c6\u5316\u5b83<\/strong>\u3002\u4f8b\u5982\uff0c\u5728\u4e09\u7ef4\u7a7a\u95f4\u4e2d\u7ed8\u5236\u4e00\u4e2a\u8d85\u5e73\u9762\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u5e73\u9762\u65b9\u7a0b\uff0c\u7136\u540e\u5728\u6307\u5b9a\u8303\u56f4\u5185\u751f\u6210\u7f51\u683c\u6570\u636e\uff0c\u5e76\u4f7f\u7528Matplotlib\u7684<code>plot_surface<\/code>\u65b9\u6cd5\u8fdb\u884c\u7ed8\u5236\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u8d85\u5e73\u9762\u7684\u5b9a\u4e49\u4e0e\u65b9\u7a0b<\/h3>\n<\/p>\n<p><p>\u8d85\u5e73\u9762\u901a\u5e38\u7528\u7ebf\u6027\u65b9\u7a0b\u8868\u793a\u3002\u5bf9\u4e8en\u7ef4\u7a7a\u95f4\u4e2d\u7684\u8d85\u5e73\u9762\uff0c\u5176\u65b9\u7a0b\u5f62\u5f0f\u4e3a\uff1a<br \/>[ w_1x_1 + w_2x_2 + &#8230; + w_nx_n + b = 0 ]<br \/>\u5176\u4e2d\uff0c(w_1, w_2, &#8230;, w_n) \u662f\u8d85\u5e73\u9762\u7684\u6cd5\u5411\u91cf\uff0cb\u662f\u504f\u7f6e\u9879\u3002\u6cd5\u5411\u91cf\u51b3\u5b9a\u4e86\u8d85\u5e73\u9762\u7684\u65b9\u5411\uff0c\u800c\u504f\u7f6e\u9879\u5219\u51b3\u5b9a\u4e86\u8d85\u5e73\u9762\u5728\u7a7a\u95f4\u4e2d\u7684\u4f4d\u7f6e\u3002<\/p>\n<\/p>\n<p><p>\u5728\u7f16\u7a0b\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u786e\u5b9a\u8fd9\u4e9b\u7cfb\u6570\u548c\u504f\u7f6e\u9879\uff0c\u7136\u540e\u6839\u636e\u8fd9\u4e9b\u53c2\u6570\u751f\u6210\u8d85\u5e73\u9762\u7684\u7f51\u683c\u6570\u636e\u3002\u5728\u4e8c\u7ef4\u548c\u4e09\u7ef4\u7a7a\u95f4\u4e2d\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u76f8\u5bf9\u7b80\u5355\uff0c\u56e0\u4e3a\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u5728\u5e73\u9762\u6216\u7a7a\u95f4\u4e2d\u751f\u6210\u6570\u636e\u5e76\u7ed8\u5236\u3002\u7136\u800c\uff0c\u5728\u66f4\u9ad8\u7ef4\u5ea6\u4e2d\uff0c\u7ed8\u5236\u8d85\u5e73\u9762\u53d8\u5f97\u66f4\u52a0\u590d\u6742\uff0c\u56e0\u4e3a\u6211\u4eec\u65e0\u6cd5\u76f4\u63a5\u89c6\u89c9\u5316\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528Numpy\u751f\u6210\u7f51\u683c\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u5728Python\u4e2d\u7ed8\u5236\u8d85\u5e73\u9762\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u751f\u6210\u6240\u9700\u7684\u7f51\u683c\u6570\u636e\u3002Numpy\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5e93\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u8f7b\u677e\u751f\u6210\u8fd9\u4e9b\u6570\u636e\u3002\u4f8b\u5982\uff0c\u5728\u4e8c\u7ef4\u7a7a\u95f4\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>numpy.linspace<\/code>\u51fd\u6570\u751f\u6210x\u548cy\u7684\u503c\uff0c\u7136\u540e\u8ba1\u7b97\u5bf9\u5e94\u7684z\u503c\u6765\u5f62\u6210\u5e73\u9762\u3002<\/p>\n<\/p>\n<p><p>\u5728\u4e09\u7ef4\u7a7a\u95f4\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u4e3ax\u548cy\u751f\u6210\u7f51\u683c\u6570\u636e\uff0c\u8ba1\u7b97\u5bf9\u5e94\u7684z\u503c\uff0c\u4ee5\u4fbf\u5728Matplotlib\u4e2d\u7ed8\u5236\u3002\u5177\u4f53\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u5b9a\u4e49\u8d85\u5e73\u9762\u7684\u7cfb\u6570<\/strong><\/h2>\n<p>w = np.array([1, -1, 2])  # \u5047\u8bbe\u6cd5\u5411\u91cfw = (1, -1, 2)<\/p>\n<p>b = -3  # \u504f\u7f6e\u9879<\/p>\n<h2><strong>\u751f\u6210x\u548cy\u7684\u503c<\/strong><\/h2>\n<p>x = np.linspace(-10, 10, 100)<\/p>\n<p>y = np.linspace(-10, 10, 100)<\/p>\n<p>X, Y = np.meshgrid(x, y)<\/p>\n<h2><strong>\u8ba1\u7b97\u5bf9\u5e94\u7684z\u503c<\/strong><\/h2>\n<p>Z = (-w[0] * X - w[1] * Y - b) \/ w[2]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528Matplotlib\u7ed8\u5236\u8d85\u5e73\u9762<\/h3>\n<\/p>\n<p><p>\u4e00\u65e6\u6211\u4eec\u751f\u6210\u4e86\u7f51\u683c\u6570\u636e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528Matplotlib\u8fdb\u884c\u7ed8\u5236\u3002Matplotlib\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u7ed8\u56fe\u5e93\u4e4b\u4e00\uff0c\u7279\u522b\u9002\u5408\u4e8c\u7ef4\u548c\u4e09\u7ef4\u6570\u636e\u7684\u53ef\u89c6\u5316\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>plot_surface<\/code>\u65b9\u6cd5\u6765\u7ed8\u5236\u4e09\u7ef4\u8d85\u5e73\u9762\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>from mpl_toolkits.mplot3d import Axes3D<\/p>\n<p>fig = plt.figure()<\/p>\n<p>ax = fig.add_subplot(111, projection=&#39;3d&#39;)<\/p>\n<h2><strong>\u7ed8\u5236\u8d85\u5e73\u9762<\/strong><\/h2>\n<p>ax.plot_surface(X, Y, Z, alpha=0.5, rstride=100, cstride=100)<\/p>\n<h2><strong>\u8bbe\u7f6e\u5750\u6807\u8f74\u6807\u7b7e<\/strong><\/h2>\n<p>ax.set_xlabel(&#39;X&#39;)<\/p>\n<p>ax.set_ylabel(&#39;Y&#39;)<\/p>\n<p>ax.set_zlabel(&#39;Z&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u7406\u89e3\u9ad8\u7ef4\u7a7a\u95f4\u4e2d\u7684\u8d85\u5e73\u9762<\/h3>\n<\/p>\n<p><p>\u5728\u9ad8\u7ef4\u7a7a\u95f4\u4e2d\uff0c\u8d85\u5e73\u9762\u4ecd\u7136\u662fn-1\u7ef4\u7684\u5b50\u7a7a\u95f4\uff0c\u5c3d\u7ba1\u6211\u4eec\u65e0\u6cd5\u76f4\u63a5\u89c6\u89c9\u5316\u5b83\uff0c\u4f46\u5176\u6570\u5b66\u5b9a\u4e49\u548c\u6027\u8d28\u4ecd\u7136\u9002\u7528\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6295\u5f71\u3001\u964d\u7ef4\u7b49\u6280\u672f\u95f4\u63a5\u7406\u89e3\u548c\u53ef\u89c6\u5316\u9ad8\u7ef4\u8d85\u5e73\u9762\u3002\u4f8b\u5982\uff0c\u4e3b\u6210\u5206\u5206\u6790\uff08PCA\uff09\u662f\u4e00\u79cd\u5e38\u7528\u7684\u964d\u7ef4\u6280\u672f\uff0c\u53ef\u4ee5\u5c06\u9ad8\u7ef4\u6570\u636e\u6295\u5f71\u5230\u8f83\u4f4e\u7ef4\u5ea6\u4e0a\uff0c\u4ece\u800c\u95f4\u63a5\u89c2\u5bdf\u5176\u7ed3\u6784\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5e94\u7528\u5b9e\u4f8b\uff1a\u652f\u6301\u5411\u91cf\u673a\u4e2d\u7684\u8d85\u5e73\u9762<\/h3>\n<\/p>\n<p><p>\u652f\u6301\u5411\u91cf\u673a\uff08SVM\uff09\u662f\u4e00\u79cd\u5e38\u7528\u7684<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u7b97\u6cd5\uff0c\u5176\u6838\u5fc3\u601d\u60f3\u662f\u627e\u5230\u4e00\u4e2a\u6700\u4f18\u8d85\u5e73\u9762\u5c06\u6570\u636e\u5206\u7c7b\u3002SVM\u4e2d\uff0c\u8d85\u5e73\u9762\u4e0d\u4ec5\u7528\u6765\u5206\u5272\u6570\u636e\uff0c\u8fd8\u7528\u4e8e\u6700\u5927\u5316\u6570\u636e\u4e4b\u95f4\u7684\u95f4\u9694\u3002\u5728\u5b9e\u73b0SVM\u65f6\uff0c\u901a\u5e38\u9700\u8981\u8ba1\u7b97\u8d85\u5e73\u9762\u7684\u4f4d\u7f6e\u548c\u65b9\u5411\uff0c\u5e76\u4f7f\u7528\u5b83\u6765\u8fdb\u884c\u9884\u6d4b\u548c\u5206\u7c7b\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5728\u4f7f\u7528Scikit-learn\u5e93\u5b9e\u73b0SVM\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7<code>coef_<\/code>\u548c<code>intercept_<\/code>\u5c5e\u6027\u83b7\u53d6\u8d85\u5e73\u9762\u7684\u6cd5\u5411\u91cf\u548c\u504f\u7f6e\u9879\uff0c\u5e76\u4f7f\u7528\u8fd9\u4e9b\u4fe1\u606f\u7ed8\u5236\u51b3\u7b56\u8fb9\u754c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn import svm<\/p>\n<h2><strong>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e9b\u4e8c\u7ef4\u6570\u636e<\/strong><\/h2>\n<p>X = np.array([[2, 3], [3, 4], [4, 5], [5, 6]])<\/p>\n<p>y = np.array([0, 1, 0, 1])<\/p>\n<h2><strong>\u4f7f\u7528SVM\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>model = svm.SVC(kernel=&#39;linear&#39;)<\/p>\n<p>model.fit(X, y)<\/p>\n<h2><strong>\u83b7\u53d6\u8d85\u5e73\u9762\u7684\u7cfb\u6570\u548c\u504f\u7f6e<\/strong><\/h2>\n<p>w = model.coef_[0]<\/p>\n<p>b = model.intercept_[0]<\/p>\n<h2><strong>\u7ed8\u5236\u6570\u636e\u70b9\u548c\u8d85\u5e73\u9762<\/strong><\/h2>\n<p>plt.scatter(X[:, 0], X[:, 1], c=y)<\/p>\n<p>x_plot = np.linspace(0, 6, 100)<\/p>\n<p>y_plot = -(w[0] * x_plot + b) \/ w[1]<\/p>\n<p>plt.plot(x_plot, y_plot, &#39;k-&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u8d85\u5e73\u9762\u7684\u6027\u8d28\u4e0e\u7279\u70b9<\/h3>\n<\/p>\n<p><p>\u8d85\u5e73\u9762\u5177\u6709\u8bb8\u591a\u91cd\u8981\u7684\u6027\u8d28\u548c\u7279\u70b9\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5206\u5272\u7a7a\u95f4<\/strong>\uff1a\u8d85\u5e73\u9762\u53ef\u4ee5\u5c06\u7a7a\u95f4\u5206\u6210\u4e24\u4e2a\u90e8\u5206\uff0c\u6bcf\u4e2a\u90e8\u5206\u4ee3\u8868\u4e0d\u540c\u7684\u7c7b\u522b\u6216\u533a\u57df\u3002\u5728\u5206\u7c7b\u95ee\u9898\u4e2d\uff0c\u8fd9\u4e00\u7279\u6027\u5c24\u4e3a\u91cd\u8981\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6cd5\u5411\u91cf<\/strong>\uff1a\u8d85\u5e73\u9762\u7684\u6cd5\u5411\u91cf\u5782\u76f4\u4e8e\u8d85\u5e73\u9762\uff0c\u51b3\u5b9a\u4e86\u8d85\u5e73\u9762\u7684\u65b9\u5411\u3002\u5728\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u6cd5\u5411\u91cf\u7684\u5927\u5c0f\u548c\u65b9\u5411\u76f4\u63a5\u5f71\u54cd\u5206\u7c7b\u7684\u7ed3\u679c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8ddd\u79bb\u8ba1\u7b97<\/strong>\uff1a\u53ef\u4ee5\u901a\u8fc7\u51e0\u4f55\u65b9\u6cd5\u8ba1\u7b97\u70b9\u5230\u8d85\u5e73\u9762\u7684\u8ddd\u79bb\uff0c\u8fd9\u5728\u4f18\u5316\u95ee\u9898\u4e2d\u975e\u5e38\u6709\u7528\u3002\u4f8b\u5982\uff0c\u5728\u652f\u6301\u5411\u91cf\u673a\u4e2d\uff0c\u6700\u5927\u5316\u6570\u636e\u70b9\u5230\u8d85\u5e73\u9762\u7684\u6700\u5c0f\u8ddd\u79bb\u53ef\u4ee5\u63d0\u9ad8\u5206\u7c7b\u7684\u9c81\u68d2\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u8d85\u5e73\u9762\u7684\u5e94\u7528\u9886\u57df<\/h3>\n<\/p>\n<p><p>\u8d85\u5e73\u9762\u5e7f\u6cdb\u5e94\u7528\u4e8e\u591a\u4e2a\u9886\u57df\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u673a\u5668\u5b66\u4e60\u4e0e\u6570\u636e\u6316\u6398<\/strong>\uff1a\u8d85\u5e73\u9762\u7528\u4e8e\u5206\u7c7b\u3001\u56de\u5f52\u7b49\u4efb\u52a1\uff0c\u662f\u8bb8\u591a\u7b97\u6cd5\uff08\u5982\u652f\u6301\u5411\u91cf\u673a\u3001\u611f\u77e5\u5668\u7b49\uff09\u7684\u6838\u5fc3\u6982\u5ff5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f18\u5316\u95ee\u9898<\/strong>\uff1a\u5728\u6570\u5b66\u4f18\u5316\u4e2d\uff0c\u8d85\u5e73\u9762\u7528\u4e8e\u5b9a\u4e49\u7ea6\u675f\u548c\u76ee\u6807\u51fd\u6570\uff0c\u5e2e\u52a9\u627e\u5230\u6700\u4f18\u89e3\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8ba1\u7b97\u51e0\u4f55<\/strong>\uff1a\u5728\u8ba1\u7b97\u51e0\u4f55\u4e2d\uff0c\u8d85\u5e73\u9762\u7528\u4e8e\u5904\u7406\u591a\u8fb9\u5f62\u3001\u591a\u9762\u4f53\u7684\u4ea4\u96c6\u3001\u5e76\u96c6\u7b49\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u56fe\u50cf\u5904\u7406\u4e0e\u8ba1\u7b97\u673a\u89c6\u89c9<\/strong>\uff1a\u5728\u56fe\u50cf\u5904\u7406\u548c\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\uff0c\u8d85\u5e73\u9762\u7528\u4e8e\u7279\u5f81\u63d0\u53d6\u3001\u6a21\u5f0f\u8bc6\u522b\u7b49\u4efb\u52a1\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516b\u3001\u603b\u7ed3\u4e0e\u5c55\u671b<\/h3>\n<\/p>\n<p><p>\u8d85\u5e73\u9762\u4f5c\u4e3a\u4e00\u4e2a\u57fa\u672c\u7684\u51e0\u4f55\u5bf9\u8c61\uff0c\u5176\u5e94\u7528\u5e7f\u6cdb\uff0c\u6db5\u76d6\u4e86\u4ece\u6570\u5b66\u7406\u8bba\u5230\u5b9e\u9645\u5e94\u7528\u7684\u591a\u4e2a\u9886\u57df\u3002\u901a\u8fc7Python\u53ca\u5176\u4e30\u5bcc\u7684\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u751f\u6210\u548c\u53ef\u89c6\u5316\u8d85\u5e73\u9762\uff0c\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7406\u89e3\u548c\u5e94\u7528\u8fd9\u4e00\u6982\u5ff5\u3002\u5728\u672a\u6765\uff0c\u968f\u7740\u8ba1\u7b97\u80fd\u529b\u7684\u63d0\u9ad8\u548c\u7b97\u6cd5\u7684\u4e0d\u65ad\u8fdb\u6b65\uff0c\u8d85\u5e73\u9762\u7684\u5e94\u7528\u5c06\u4f1a\u66f4\u52a0\u5e7f\u6cdb\uff0c\u7279\u522b\u662f\u5728\u5927\u6570\u636e\u548c<a href=\"https:\/\/docs.pingcode.com\/tag\/AI\" target=\"_blank\">\u4eba\u5de5\u667a\u80fd<\/a>\u9886\u57df\uff0c\u5176\u91cd\u8981\u6027\u5c06\u66f4\u52a0\u7a81\u51fa\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u7ed8\u5236\u8d85\u5e73\u9762\uff1f<\/strong><br \/>\u5728Python\u4e2d\u7ed8\u5236\u8d85\u5e73\u9762\uff0c\u901a\u5e38\u53ef\u4ee5\u4f7f\u7528Matplotlib\u5e93\u7ed3\u5408NumPy\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b9a\u4e49\u60a8\u7684\u8d85\u5e73\u9762\u65b9\u7a0b\u3002\u8d85\u5e73\u9762\u5728\u591a\u7ef4\u7a7a\u95f4\u4e2d\u662f\u4e00\u4e2a\u7ef4\u5ea6\u6bd4\u7a7a\u95f4\u4f4e\u4e00\u7ef4\u7684\u5e73\u9762\u3002\u4f8b\u5982\uff0c\u5728\u4e09\u7ef4\u7a7a\u95f4\u4e2d\uff0c\u8d85\u5e73\u9762\u662f\u4e00\u4e2a\u4e8c\u7ef4\u5e73\u9762\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u4e00\u7ec4\u5750\u6807\u70b9\u5e76\u5229\u7528Matplotlib\u7684<code>plot_surface<\/code>\u529f\u80fd\u6765\u53ef\u89c6\u5316\u8d85\u5e73\u9762\u3002<\/p>\n<p><strong>\u7ed8\u5236\u8d85\u5e73\u9762\u9700\u8981\u54ea\u4e9b\u5e93\u548c\u5de5\u5177\uff1f<\/strong><br \/>\u7ed8\u5236\u8d85\u5e73\u9762\u901a\u5e38\u9700\u8981\u4f7f\u7528NumPy\u548cMatplotlib\u3002NumPy\u7528\u4e8e\u5904\u7406\u6570\u7ec4\u548c\u6570\u5b66\u8fd0\u7b97\uff0c\u800cMatplotlib\u5219\u662f\u53ef\u89c6\u5316\u6570\u636e\u7684\u5f3a\u5927\u5de5\u5177\u3002\u786e\u4fdd\u5728\u60a8\u7684Python\u73af\u5883\u4e2d\u5b89\u88c5\u8fd9\u4e24\u4e2a\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7<code>pip install numpy matplotlib<\/code>\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p><strong>\u8d85\u5e73\u9762\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7684\u5e94\u7528\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u8d85\u5e73\u9762\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u5e38\u7528\u4e8e\u5206\u7c7b\u4efb\u52a1\uff0c\u7279\u522b\u662f\u5728\u652f\u6301\u5411\u91cf\u673a(SVM)\u6a21\u578b\u4e2d\u3002\u901a\u8fc7\u627e\u5230\u6700\u4f73\u7684\u8d85\u5e73\u9762\uff0c\u6a21\u578b\u53ef\u4ee5\u6709\u6548\u5730\u5c06\u4e0d\u540c\u7c7b\u522b\u7684\u6570\u636e\u5206\u5f00\u3002\u6b64\u5916\uff0c\u8d85\u5e73\u9762\u4e5f\u5728\u56de\u5f52\u5206\u6790\u4e2d\u626e\u6f14\u91cd\u8981\u89d2\u8272\uff0c\u5e2e\u52a9\u9884\u6d4b\u591a\u7ef4\u6570\u636e\u7684\u8d8b\u52bf\u548c\u5173\u7cfb\u3002<\/p>\n<p><strong>\u5982\u4f55\u8c03\u8bd5\u8d85\u5e73\u9762\u7ed8\u5236\u4e2d\u7684\u5e38\u89c1\u9519\u8bef\uff1f<\/strong><br \/>\u5728\u7ed8\u5236\u8d85\u5e73\u9762\u65f6\uff0c\u5e38\u89c1\u7684\u9519\u8bef\u5305\u62ec\u7ef4\u5ea6\u4e0d\u5339\u914d\u548c\u5750\u6807\u8303\u56f4\u8bbe\u7f6e\u4e0d\u5f53\u3002\u786e\u4fdd\u8f93\u5165\u7684\u70b9\u548c\u8d85\u5e73\u9762\u65b9\u7a0b\u5728\u540c\u4e00\u7ef4\u5ea6\u5185\u3002\u6b64\u5916\uff0c\u68c0\u67e5\u5750\u6807\u8f74\u7684\u8303\u56f4\u8bbe\u7f6e\uff0c\u786e\u4fdd\u5b83\u4eec\u8986\u76d6\u4e86\u8d85\u5e73\u9762\u6240\u9700\u7684\u533a\u57df\u3002\u5982\u679c\u51fa\u73b0\u56fe\u5f62\u65e0\u6cd5\u663e\u793a\u7684\u60c5\u51b5\uff0c\u786e\u8ba4Matplotlib\u7684<code>show()<\/code>\u51fd\u6570\u662f\u5426\u5df2\u8c03\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728Python\u4e2d\u7ed8\u5236\u8d85\u5e73\u9762\uff0c\u9996\u5148\u9700\u8981\u7406\u89e3\u8d85\u5e73\u9762\u662f\u4ec0\u4e48\u4ee5\u53ca\u5982\u4f55\u5728\u9ad8\u7ef4\u7a7a\u95f4\u4e2d\u8868\u793a\u5b83\u3002\u8d85\u5e73\u9762\u662f\u4e00\u4e2an-1\u7ef4\u7684\u5b50\u7a7a\u95f4 [&hellip;]","protected":false},"author":3,"featured_media":1019464,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1019440"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1019440"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1019440\/revisions"}],"predecessor-version":[{"id":1019467,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1019440\/revisions\/1019467"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1019464"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1019440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1019440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1019440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}