{"id":962750,"date":"2024-12-27T04:11:13","date_gmt":"2024-12-26T20:11:13","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/962750.html"},"modified":"2024-12-27T04:11:15","modified_gmt":"2024-12-26T20:11:15","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8python%e6%8b%9f%e5%90%88%e6%9b%b2%e7%ba%bf","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/962750.html","title":{"rendered":"\u5982\u4f55\u5728python\u62df\u5408\u66f2\u7ebf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25104626\/4b4b8b2c-7fbf-48d1-8044-38e0335334b9.webp\" alt=\"\u5982\u4f55\u5728python\u62df\u5408\u66f2\u7ebf\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u62df\u5408\u66f2\u7ebf\u7684\u5e38\u7528\u65b9\u6cd5\u6709\uff1a\u5229\u7528<code>numpy<\/code>\u548c<code>scipy<\/code>\u5e93\u8fdb\u884c\u591a\u9879\u5f0f\u62df\u5408\u3001\u5229\u7528<code>scipy.optimize<\/code>\u8fdb\u884c\u975e\u7ebf\u6027\u62df\u5408\u3001\u4f7f\u7528<code>statsmodels<\/code>\u8fdb\u884c\u7edf\u8ba1\u5efa\u6a21\u62df\u5408\u3001\u5229\u7528<code>sklearn<\/code>\u8fdb\u884c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u62df\u5408<\/strong>\u3002\u8fd9\u4e9b\u65b9\u6cd5\u5404\u6709\u4f18\u7f3a\u70b9\uff0c\u4f8b\u5982<code>numpy<\/code>\u9002\u7528\u4e8e\u7b80\u5355\u7684\u591a\u9879\u5f0f\u62df\u5408\uff0c<code>scipy.optimize<\/code>\u5219\u9002\u5408\u590d\u6742\u7684\u975e\u7ebf\u6027\u6a21\u578b\u3002\u63a5\u4e0b\u6765\uff0c\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528<code>numpy<\/code>\u8fdb\u884c\u591a\u9879\u5f0f\u62df\u5408\u3002<\/p>\n<\/p>\n<p><p><code>numpy<\/code>\u5e93\u7684<code>polyfit<\/code>\u51fd\u6570\u662f\u4e00\u4e2a\u7b80\u5355\u4e14\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u6267\u884c\u591a\u9879\u5f0f\u62df\u5408\u3002<code>polyfit<\/code>\u51fd\u6570\u53ef\u4ee5\u6839\u636e\u7ed9\u5b9a\u7684\u70b9\u96c6\u548c\u6307\u5b9a\u7684\u591a\u9879\u5f0f\u9636\u6570\uff0c\u8fd4\u56de\u62df\u5408\u591a\u9879\u5f0f\u7684\u7cfb\u6570\u3002\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u8fd9\u662f\u4e00\u79cd\u5feb\u901f\u800c\u6709\u6548\u7684\u62df\u5408\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528<code>NUMPY<\/code>\u8fdb\u884c\u591a\u9879\u5f0f\u62df\u5408<\/h3>\n<\/p>\n<p><p><code>numpy<\/code>\u5e93\u4e2d\u7684<code>polyfit<\/code>\u51fd\u6570\u662f\u8fdb\u884c\u591a\u9879\u5f0f\u62df\u5408\u7684\u57fa\u7840\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u6839\u636e\u7ed9\u5b9a\u7684\u6570\u636e\u70b9\u548c\u6307\u5b9a\u7684\u591a\u9879\u5f0f\u9636\u6570\uff0c\u8ba1\u7b97\u51fa\u62df\u5408\u591a\u9879\u5f0f\u7684\u7cfb\u6570\u3002<\/p>\n<\/p>\n<p><h4>1.1\u3001\u57fa\u672c\u7528\u6cd5<\/h4>\n<\/p>\n<p><p><code>numpy.polyfit(x, y, deg)<\/code>\u51fd\u6570\u63a5\u53d7\u4e09\u4e2a\u53c2\u6570\uff1a<code>x<\/code>\u548c<code>y<\/code>\u662f\u6570\u636e\u70b9\u7684\u5750\u6807\uff0c<code>deg<\/code>\u662f\u62df\u5408\u591a\u9879\u5f0f\u7684\u9636\u6570\u3002\u8fd4\u56de\u503c\u662f\u4e00\u4e2a\u5305\u542b\u591a\u9879\u5f0f\u7cfb\u6570\u7684\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u751f\u6210\u793a\u4f8b\u6570\u636e<\/strong><\/h2>\n<p>x = np.linspace(0, 10, 100)<\/p>\n<p>y = 3 * x2 + 2 * x + 1 + np.random.normal(0, 10, size=x.shape)<\/p>\n<h2><strong>\u4f7f\u7528polyfit\u8fdb\u884c\u4e8c\u6b21\u591a\u9879\u5f0f\u62df\u5408<\/strong><\/h2>\n<p>coefficients = np.polyfit(x, y, 2)<\/p>\n<h2><strong>\u751f\u6210\u62df\u5408\u66f2\u7ebf<\/strong><\/h2>\n<p>polynomial = np.poly1d(coefficients)<\/p>\n<p>y_fit = polynomial(x)<\/p>\n<h2><strong>\u7ed8\u5236\u539f\u59cb\u6570\u636e\u548c\u62df\u5408\u66f2\u7ebf<\/strong><\/h2>\n<p>plt.scatter(x, y, label=&#39;Data&#39;)<\/p>\n<p>plt.plot(x, y_fit, color=&#39;red&#39;, label=&#39;Fitted curve&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.2\u3001\u9009\u62e9\u5408\u9002\u7684\u591a\u9879\u5f0f\u9636\u6570<\/h4>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u591a\u9879\u5f0f\u9636\u6570\u5bf9\u4e8e\u62df\u5408\u7684\u51c6\u786e\u6027\u81f3\u5173\u91cd\u8981\u3002\u9636\u6570\u8fc7\u4f4e\u53ef\u80fd\u5bfc\u81f4\u62df\u5408\u4e0d\u8db3\uff0c\u800c\u9636\u6570\u8fc7\u9ad8\u5219\u53ef\u80fd\u5bfc\u81f4\u8fc7\u62df\u5408\u3002\u53ef\u4ee5\u901a\u8fc7\u4ea4\u53c9\u9a8c\u8bc1\u6216\u89c2\u5bdf\u62df\u5408\u66f2\u7ebf\u7684\u8868\u73b0\u6765\u8c03\u6574\u591a\u9879\u5f0f\u7684\u9636\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528<code>SCIPY.OPTIMIZE<\/code>\u8fdb\u884c\u975e\u7ebf\u6027\u62df\u5408<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u590d\u6742\u7684\u975e\u7ebf\u6027\u6a21\u578b\uff0c<code>scipy.optimize<\/code>\u6a21\u5757\u4e2d\u7684<code>curve_fit<\/code>\u51fd\u6570\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\u3002\u5b83\u5141\u8bb8\u7528\u6237\u81ea\u5b9a\u4e49\u975e\u7ebf\u6027\u51fd\u6570\u6a21\u578b\uff0c\u7136\u540e\u8fdb\u884c\u53c2\u6570\u4f18\u5316\u4ee5\u6700\u5c0f\u5316\u8bef\u5dee\u3002<\/p>\n<\/p>\n<p><h4>2.1\u3001\u57fa\u672c\u7528\u6cd5<\/h4>\n<\/p>\n<p><p><code>curve_fit<\/code>\u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u81ea\u5b9a\u4e49\u51fd\u6570\u3001\u6570\u636e\u70b9\u7684\u5750\u6807\u4ee5\u53ca\u521d\u59cb\u53c2\u6570\u4f30\u8ba1\u503c\uff0c\u8fd4\u56de\u4f18\u5316\u540e\u7684\u53c2\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from scipy.optimize import curve_fit<\/p>\n<h2><strong>\u5b9a\u4e49\u975e\u7ebf\u6027\u51fd\u6570\u6a21\u578b<\/strong><\/h2>\n<p>def model(x, a, b, c):<\/p>\n<p>    return a * np.exp(b * x) + c<\/p>\n<h2><strong>\u4f7f\u7528curve_fit\u8fdb\u884c\u975e\u7ebf\u6027\u62df\u5408<\/strong><\/h2>\n<p>params, covariance = curve_fit(model, x, y, p0=[1, 0.1, 1])<\/p>\n<h2><strong>\u751f\u6210\u62df\u5408\u66f2\u7ebf<\/strong><\/h2>\n<p>y_fit = model(x, *params)<\/p>\n<h2><strong>\u7ed8\u5236\u539f\u59cb\u6570\u636e\u548c\u62df\u5408\u66f2\u7ebf<\/strong><\/h2>\n<p>plt.scatter(x, y, label=&#39;Data&#39;)<\/p>\n<p>plt.plot(x, y_fit, color=&#39;green&#39;, label=&#39;Fitted curve&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.2\u3001\u4f18\u5316\u521d\u59cb\u53c2\u6570\u4f30\u8ba1<\/h4>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u521d\u59cb\u53c2\u6570\u4f30\u8ba1\u503c\u5bf9\u4e8e\u975e\u7ebf\u6027\u62df\u5408\u7684\u6536\u655b\u6027\u548c\u51c6\u786e\u6027\u975e\u5e38\u91cd\u8981\u3002\u53ef\u4ee5\u6839\u636e\u7ecf\u9a8c\u6216\u6570\u636e\u7684\u8d8b\u52bf\u6765\u9009\u62e9\u521d\u59cb\u503c\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528<code>STATSMODELS<\/code>\u8fdb\u884c\u7edf\u8ba1\u5efa\u6a21\u62df\u5408<\/h3>\n<\/p>\n<p><p><code>statsmodels<\/code>\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u7edf\u8ba1\u5efa\u6a21\u5de5\u5177\uff0c\u9002\u5408\u7528\u4e8e\u9700\u8981\u8fdb\u884c\u5047\u8bbe\u68c0\u9a8c\u6216\u7edf\u8ba1\u63a8\u65ad\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h4>3.1\u3001\u7ebf\u6027\u56de\u5f52<\/h4>\n<\/p>\n<p><p><code>statsmodels<\/code>\u7684<code>OLS<\/code>\u7c7b\u63d0\u4f9b\u4e86\u7ebf\u6027\u56de\u5f52\u7684\u529f\u80fd\uff0c\u5b83\u4e0d\u4ec5\u8ba1\u7b97\u62df\u5408\u53c2\u6570\uff0c\u8fd8\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684\u7edf\u8ba1\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import statsmodels.api as sm<\/p>\n<h2><strong>\u6dfb\u52a0\u5e38\u6570\u9879\u7528\u4e8e\u7ebf\u6027\u56de\u5f52<\/strong><\/h2>\n<p>X = sm.add_constant(x)<\/p>\n<h2><strong>\u8fdb\u884c\u7ebf\u6027\u56de\u5f52<\/strong><\/h2>\n<p>model = sm.OLS(y, X).fit()<\/p>\n<h2><strong>\u8f93\u51fa\u56de\u5f52\u7ed3\u679c<\/strong><\/h2>\n<p>print(model.summary())<\/p>\n<h2><strong>\u751f\u6210\u62df\u5408\u66f2\u7ebf<\/strong><\/h2>\n<p>y_fit = model.predict(X)<\/p>\n<h2><strong>\u7ed8\u5236\u539f\u59cb\u6570\u636e\u548c\u62df\u5408\u66f2\u7ebf<\/strong><\/h2>\n<p>plt.scatter(x, y, label=&#39;Data&#39;)<\/p>\n<p>plt.plot(x, y_fit, color=&#39;purple&#39;, label=&#39;Fitted line&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.2\u3001\u5047\u8bbe\u68c0\u9a8c\u4e0e\u53c2\u6570\u663e\u8457\u6027<\/h4>\n<\/p>\n<p><p><code>statsmodels<\/code>\u63d0\u4f9b\u7684\u7ebf\u6027\u56de\u5f52\u7ed3\u679c\u5305\u542b\u4e86\u53c2\u6570\u7684\u663e\u8457\u6027\u68c0\u9a8c\uff08p\u503c\uff09\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5224\u65ad\u54ea\u4e9b\u53d8\u91cf\u5bf9\u6a21\u578b\u6709\u663e\u8457\u5f71\u54cd\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528<code>SKLEARN<\/code>\u8fdb\u884c\u673a\u5668\u5b66\u4e60\u62df\u5408<\/h3>\n<\/p>\n<p><p><code>sklearn<\/code>\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u673a\u5668\u5b66\u4e60\u6a21\u578b\uff0c\u5305\u62ec\u7ebf\u6027\u56de\u5f52\u3001\u51b3\u7b56\u6811\u3001\u652f\u6301\u5411\u91cf\u673a\u7b49\uff0c\u7528\u4e8e\u62df\u5408\u590d\u6742\u7684\u975e\u7ebf\u6027\u5173\u7cfb\u3002<\/p>\n<\/p>\n<p><h4>4.1\u3001\u7ebf\u6027\u56de\u5f52<\/h4>\n<\/p>\n<p><p><code>sklearn<\/code>\u7684<code>LinearRegression<\/code>\u7c7b\u63d0\u4f9b\u4e86\u7b80\u5355\u6613\u7528\u7684\u7ebf\u6027\u56de\u5f52\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.linear_model import LinearRegression<\/p>\n<h2><strong>\u91cd\u5851\u6570\u636e\u4ee5\u9002\u5e94sklearn\u7684\u8f93\u5165\u683c\u5f0f<\/strong><\/h2>\n<p>x_reshape = x.reshape(-1, 1)<\/p>\n<h2><strong>\u521b\u5efa\u7ebf\u6027\u56de\u5f52\u6a21\u578b\u5e76\u62df\u5408\u6570\u636e<\/strong><\/h2>\n<p>model = LinearRegression()<\/p>\n<p>model.fit(x_reshape, y)<\/p>\n<h2><strong>\u751f\u6210\u62df\u5408\u66f2\u7ebf<\/strong><\/h2>\n<p>y_fit = model.predict(x_reshape)<\/p>\n<h2><strong>\u7ed8\u5236\u539f\u59cb\u6570\u636e\u548c\u62df\u5408\u66f2\u7ebf<\/strong><\/h2>\n<p>plt.scatter(x, y, label=&#39;Data&#39;)<\/p>\n<p>plt.plot(x, y_fit, color=&#39;orange&#39;, label=&#39;Fitted line&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.2\u3001\u975e\u7ebf\u6027\u6a21\u578b<\/h4>\n<\/p>\n<p><p><code>sklearn<\/code>\u7684<code>PolynomialFeatures<\/code>\u548c<code>Pipeline<\/code>\u53ef\u4ee5\u7528\u4e8e\u521b\u5efa\u548c\u62df\u5408\u591a\u9879\u5f0f\u56de\u5f52\u6a21\u578b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.preprocessing import PolynomialFeatures<\/p>\n<p>from sklearn.pipeline import Pipeline<\/p>\n<h2><strong>\u521b\u5efa\u591a\u9879\u5f0f\u56de\u5f52\u6a21\u578b<\/strong><\/h2>\n<p>polynomial_features = PolynomialFeatures(degree=2)<\/p>\n<p>model = Pipeline([(&quot;polynomial_features&quot;, polynomial_features),<\/p>\n<p>                  (&quot;linear_regression&quot;, LinearRegression())])<\/p>\n<h2><strong>\u62df\u5408\u6570\u636e<\/strong><\/h2>\n<p>model.fit(x_reshape, y)<\/p>\n<h2><strong>\u751f\u6210\u62df\u5408\u66f2\u7ebf<\/strong><\/h2>\n<p>y_fit = model.predict(x_reshape)<\/p>\n<h2><strong>\u7ed8\u5236\u539f\u59cb\u6570\u636e\u548c\u62df\u5408\u66f2\u7ebf<\/strong><\/h2>\n<p>plt.scatter(x, y, label=&#39;Data&#39;)<\/p>\n<p>plt.plot(x, y_fit, color=&#39;teal&#39;, label=&#39;Fitted polynomial&#39;)<\/p>\n<p>plt.legend()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u6570\u636e\u9884\u5904\u7406\u4e0e\u8bc4\u4f30<\/h3>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u4efb\u4f55\u62df\u5408\u4e4b\u524d\uff0c\u6570\u636e\u7684\u9884\u5904\u7406\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u53bb\u9664\u5f02\u5e38\u503c\u3001\u8fdb\u884c\u6570\u636e\u5f52\u4e00\u5316\u6216\u6807\u51c6\u5316\u3001\u9009\u62e9\u5408\u9002\u7684\u7279\u5f81\u7b49\uff0c\u90fd\u80fd\u663e\u8457\u63d0\u9ad8\u62df\u5408\u6548\u679c\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u4ea4\u53c9\u9a8c\u8bc1\u548c\u6b8b\u5dee\u5206\u6790\u7b49\u65b9\u6cd5\u53ef\u4ee5\u6709\u6548\u8bc4\u4f30\u62df\u5408\u6a21\u578b\u7684\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><h4>5.1\u3001\u6570\u636e\u6e05\u6d17\u4e0e\u7279\u5f81\u9009\u62e9<\/h4>\n<\/p>\n<p><p>\u6570\u636e\u6e05\u6d17\u5305\u62ec\u53bb\u9664\u5f02\u5e38\u503c\u3001\u5904\u7406\u7f3a\u5931\u503c\u7b49\u3002\u7279\u5f81\u9009\u62e9\u5219\u662f\u9009\u62e9\u5bf9\u6a21\u578b\u6709\u5f71\u54cd\u7684\u53d8\u91cf\uff0c\u4ee5\u7b80\u5316\u6a21\u578b\u5e76\u63d0\u9ad8\u62df\u5408\u7cbe\u5ea6\u3002<\/p>\n<\/p>\n<p><h4>5.2\u3001\u6a21\u578b\u8bc4\u4f30<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u4ea4\u53c9\u9a8c\u8bc1\u3001\u6b8b\u5dee\u5206\u6790\u3001R-squared\u7b49\u6307\u6807\u6765\u8bc4\u4f30\u6a21\u578b\u7684\u62df\u5408\u6548\u679c\u3002\u6b8b\u5dee\u5206\u6790\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u62df\u5408\u4e0d\u8db3\u6216\u8fc7\u62df\u5408\u7684\u95ee\u9898\uff0c\u800cR-squared\u5219\u63d0\u4f9b\u4e86\u6a21\u578b\u89e3\u91ca\u529b\u7684\u91cf\u5316\u6307\u6807\u3002<\/p>\n<\/p>\n<p><p>\u603b\u7ed3\u6765\u8bf4\uff0cPython\u63d0\u4f9b\u4e86\u591a\u79cd\u5de5\u5177\u548c\u5e93\u6765\u8fdb\u884c\u66f2\u7ebf\u62df\u5408\uff0c\u5305\u62ec<code>numpy<\/code>\u3001<code>scipy<\/code>\u3001<code>statsmodels<\/code>\u548c<code>sklearn<\/code>\u7b49\u3002\u6839\u636e\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6709\u6548\u63d0\u9ad8\u62df\u5408\u7684\u51c6\u786e\u6027\u548c\u6548\u7387\u3002\u5728\u5b9e\u8df5\u4e2d\uff0c\u6570\u636e\u7684\u9884\u5904\u7406\u4e0e\u6a21\u578b\u8bc4\u4f30\u4e5f\u662f\u4e0d\u53ef\u5ffd\u89c6\u7684\u73af\u8282\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Python\u4e2d\u6709\u54ea\u4e9b\u5e38\u7528\u7684\u5e93\u53ef\u4ee5\u8fdb\u884c\u66f2\u7ebf\u62df\u5408\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u5e93\u6765\u8fdb\u884c\u66f2\u7ebf\u62df\u5408\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u662fNumPy\u548cSciPy\u3002NumPy\u63d0\u4f9b\u4e86\u57fa\u672c\u7684\u6570\u5b66\u8fd0\u7b97\u529f\u80fd\uff0c\u800cSciPy\u5219\u5305\u542b\u4e86\u66f4\u9ad8\u7ea7\u7684\u4f18\u5316\u548c\u62df\u5408\u529f\u80fd\u3002\u53e6\u4e00\u4e2a\u6d41\u884c\u7684\u5e93\u662fPandas\uff0c\u901a\u5e38\u7528\u4e8e\u6570\u636e\u5904\u7406\u548c\u5206\u6790\uff0c\u53ef\u4ee5\u4e0eNumPy\u548cSciPy\u7ed3\u5408\u4f7f\u7528\u3002Matplotlib\u53ef\u4ee5\u7528\u6765\u53ef\u89c6\u5316\u62df\u5408\u7ed3\u679c\uff0c\u4f7f\u6570\u636e\u548c\u62df\u5408\u66f2\u7ebf\u4e00\u76ee\u4e86\u7136\u3002<\/p>\n<p><strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u62df\u5408\u6a21\u578b\uff1f<\/strong><br \/>\u9009\u62e9\u62df\u5408\u6a21\u578b\u901a\u5e38\u53d6\u51b3\u4e8e\u6570\u636e\u7684\u7279\u70b9\u548c\u62df\u5408\u7684\u76ee\u7684\u3002\u7ebf\u6027\u6a21\u578b\u9002\u7528\u4e8e\u7ebf\u6027\u5173\u7cfb\u7684\u6570\u636e\uff0c\u800c\u591a\u9879\u5f0f\u6a21\u578b\u5219\u9002\u7528\u4e8e\u66f4\u590d\u6742\u7684\u5173\u7cfb\u3002\u5982\u679c\u6570\u636e\u5448\u73b0\u51fa\u5468\u671f\u6027\u6216\u6307\u6570\u589e\u957f\u7684\u8d8b\u52bf\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u6b63\u5f26\u51fd\u6570\u6216\u6307\u6570\u51fd\u6570\u8fdb\u884c\u62df\u5408\u3002\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316\uff0c\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u54ea\u79cd\u6a21\u578b\u6700\u7b26\u5408\u6570\u636e\u8d8b\u52bf\u3002<\/p>\n<p><strong>\u5982\u4f55\u8bc4\u4f30\u62df\u5408\u6548\u679c\u7684\u597d\u574f\uff1f<\/strong><br \/>\u8bc4\u4f30\u62df\u5408\u6548\u679c\u53ef\u4ee5\u901a\u8fc7\u8ba1\u7b97\u51b3\u5b9a\u7cfb\u6570R\u00b2\u503c\u3001\u5747\u65b9\u6839\u8bef\u5dee(RMSE)\u7b49\u6307\u6807\u6765\u8fdb\u884c\u3002R\u00b2\u503c\u8868\u793a\u6a21\u578b\u89e3\u91ca\u7684\u53d8\u5f02\u6bd4\u4f8b\uff0c\u503c\u8d8a\u63a5\u8fd11\u8868\u793a\u62df\u5408\u6548\u679c\u8d8a\u597d\u3002\u5747\u65b9\u6839\u8bef\u5dee\u5219\u63d0\u4f9b\u4e86\u62df\u5408\u503c\u4e0e\u5b9e\u9645\u503c\u4e4b\u95f4\u7684\u5e73\u5747\u5dee\u5f02\u3002\u6b64\u5916\uff0c\u6b8b\u5dee\u5206\u6790\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u6a21\u578b\u7684\u4e0d\u8db3\u4e4b\u5904\uff0c\u786e\u4fdd\u62df\u5408\u6a21\u578b\u7684\u5047\u8bbe\u6761\u4ef6\u5f97\u5230\u6ee1\u8db3\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u62df\u5408\u66f2\u7ebf\u7684\u5e38\u7528\u65b9\u6cd5\u6709\uff1a\u5229\u7528numpy\u548cscipy\u5e93\u8fdb\u884c\u591a\u9879\u5f0f\u62df\u5408\u3001\u5229\u7528scipy.optimi [&hellip;]","protected":false},"author":3,"featured_media":962760,"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\/962750"}],"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=962750"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/962750\/revisions"}],"predecessor-version":[{"id":962762,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/962750\/revisions\/962762"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/962760"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=962750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=962750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=962750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}