{"id":1170874,"date":"2025-01-15T16:28:01","date_gmt":"2025-01-15T08:28:01","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1170874.html"},"modified":"2025-01-15T16:28:05","modified_gmt":"2025-01-15T08:28:05","slug":"python%e5%a6%82%e4%bd%95%e5%81%9a%e6%97%b6%e9%97%b4%e5%ba%8f%e5%88%97-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1170874.html","title":{"rendered":"python\u5982\u4f55\u505a\u65f6\u95f4\u5e8f\u5217"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26073354\/4d468bc7-c6e0-40ca-b02b-9294ee70cc6a.webp\" alt=\"python\u5982\u4f55\u505a\u65f6\u95f4\u5e8f\u5217\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u5173\u952e\u6b65\u9aa4\u5305\u62ec<strong>\u6570\u636e\u5bfc\u5165\u4e0e\u9884\u5904\u7406\u3001\u6570\u636e\u63a2\u7d22\u4e0e\u53ef\u89c6\u5316\u3001\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u3001\u5efa\u6a21\u4e0e\u9884\u6d4b\u3001\u6a21\u578b\u8bc4\u4f30\u4e0e\u4f18\u5316<\/strong>\u3002\u5176\u4e2d\uff0c\u6570\u636e\u5bfc\u5165\u4e0e\u9884\u5904\u7406\u662f\u6700\u4e3a\u91cd\u8981\u7684\u90e8\u5206\uff0c\u56e0\u4e3a\u9ad8\u8d28\u91cf\u7684\u8f93\u5165\u6570\u636e\u662f\u4fdd\u8bc1\u6a21\u578b\u51c6\u786e\u6027\u7684\u57fa\u7840\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u6b65\u9aa4\u89e3\u6790\uff1a<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u6570\u636e\u5bfc\u5165\u4e0e\u9884\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u7684\u7b2c\u4e00\u6b65\u662f\u5bfc\u5165\u6570\u636e\u5e76\u8fdb\u884c\u9884\u5904\u7406\u3002\u901a\u5e38\u6211\u4eec\u4f7f\u7528Pandas\u5e93\u6765\u8fdb\u884c\u6570\u636e\u7684\u5bfc\u5165\u548c\u9884\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h4>1.1 \u6570\u636e\u5bfc\u5165<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5bfc\u5165\u5fc5\u8981\u7684\u5e93\u5e76\u52a0\u8f7d\u6570\u636e\u3002\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u5305\u542b\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684CSV\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u8bfb\u53d6\u6570\u636e<\/strong><\/h2>\n<p>df = pd.read_csv(&#39;data.csv&#39;, parse_dates=[&#39;Date&#39;], index_col=&#39;Date&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u5bfc\u5165\u6570\u636e\u65f6\uff0c\u6211\u4eec\u9700\u8981\u786e\u4fdd\u5c06\u65e5\u671f\u5217\u89e3\u6790\u4e3a\u65e5\u671f\u65f6\u95f4\u5bf9\u8c61\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3aDataFrame\u7684\u7d22\u5f15\u3002<\/p>\n<\/p>\n<p><h4>1.2 \u6570\u636e\u6e05\u6d17<\/h4>\n<\/p>\n<p><p>\u6570\u636e\u6e05\u6d17\u5305\u62ec\u5904\u7406\u7f3a\u5931\u503c\u3001\u91cd\u590d\u503c\u548c\u5f02\u5e38\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u68c0\u67e5\u7f3a\u5931\u503c<\/p>\n<p>df.isnull().sum()<\/p>\n<h2><strong>\u586b\u8865\u7f3a\u5931\u503c<\/strong><\/h2>\n<p>df.fillna(method=&#39;ffill&#39;, inplace=True)<\/p>\n<h2><strong>\u68c0\u67e5\u91cd\u590d\u503c<\/strong><\/h2>\n<p>df.duplicated().sum()<\/p>\n<h2><strong>\u5220\u9664\u91cd\u590d\u503c<\/strong><\/h2>\n<p>df.drop_duplicates(inplace=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.3 \u6570\u636e\u8f6c\u6362<\/h4>\n<\/p>\n<p><p>\u6839\u636e\u5177\u4f53\u9700\u6c42\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u4e00\u4e9b\u8f6c\u6362\uff0c\u4f8b\u5982\u65f6\u95f4\u9891\u7387\u8f6c\u6362\u3001\u5dee\u5206\u5904\u7406\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u9891\u7387\u8f6c\u6362<\/p>\n<p>df = df.asfreq(&#39;D&#39;)<\/p>\n<h2><strong>\u5dee\u5206\u5904\u7406<\/strong><\/h2>\n<p>df[&#39;value_diff&#39;] = df[&#39;value&#39;].diff()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u6570\u636e\u63a2\u7d22\u4e0e\u53ef\u89c6\u5316<\/h3>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u5efa\u6a21\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u63a2\u7d22\u548c\u53ef\u89c6\u5316\uff0c\u4ee5\u4e86\u89e3\u6570\u636e\u7684\u57fa\u672c\u7279\u5f81\u548c\u8d8b\u52bf\u3002<\/p>\n<\/p>\n<p><h4>2.1 \u6570\u636e\u57fa\u672c\u7edf\u8ba1<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528Pandas\u8fdb\u884c\u57fa\u672c\u7684\u7edf\u8ba1\u63cf\u8ff0\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u6570\u636e\u63cf\u8ff0<\/p>\n<p>df.describe()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.2 \u6570\u636e\u53ef\u89c6\u5316<\/h4>\n<\/p>\n<p><p>\u5229\u7528Matplotlib\u6216Seaborn\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>import seaborn as sns<\/p>\n<h2><strong>\u65f6\u95f4\u5e8f\u5217\u56fe<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(df[&#39;value&#39;])<\/p>\n<p>plt.title(&#39;Time Series&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Value&#39;)<\/p>\n<p>plt.show()<\/p>\n<h2><strong>\u81ea\u76f8\u5173\u56fe<\/strong><\/h2>\n<p>from pandas.plotting import autocorrelation_plot<\/p>\n<p>autocorrelation_plot(df[&#39;value&#39;])<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u65f6\u95f4\u5e8f\u5217\u5206\u89e3<\/h3>\n<\/p>\n<p><p>\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5c06\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u5206\u89e3\u4e3a\u8d8b\u52bf\u3001\u5b63\u8282\u6027\u548c\u968f\u673a\u6210\u5206\u3002<\/p>\n<\/p>\n<p><h4>3.1 \u8d8b\u52bf\u548c\u5b63\u8282\u6027\u5206\u89e3<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528statsmodels\u5e93\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from statsmodels.tsa.seasonal import seasonal_decompose<\/p>\n<p>result = seasonal_decompose(df[&#39;value&#39;], model=&#39;additive&#39;)<\/p>\n<p>result.plot()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.2 \u6ed1\u52a8\u5e73\u5747<\/h4>\n<\/p>\n<p><p>\u6ed1\u52a8\u5e73\u5747\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5e73\u6ed1\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u53bb\u9664\u77ed\u671f\u6ce2\u52a8\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u6ed1\u52a8\u5e73\u5747<\/p>\n<p>df[&#39;rolling_mean&#39;] = df[&#39;value&#39;].rolling(window=12).mean()<\/p>\n<h2><strong>\u53ef\u89c6\u5316\u6ed1\u52a8\u5e73\u5747<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 6))<\/p>\n<p>plt.plot(df[&#39;value&#39;], label=&#39;Original&#39;)<\/p>\n<p>plt.plot(df[&#39;rolling_mean&#39;], label=&#39;Rolling Mean&#39;)<\/p>\n<p>plt.legend(loc=&#39;best&#39;)<\/p>\n<p>plt.title(&#39;Rolling Mean&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u5efa\u6a21\u4e0e\u9884\u6d4b<\/h3>\n<\/p>\n<p><p>\u5efa\u6a21\u662f\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u7684\u6838\u5fc3\u6b65\u9aa4\u4e4b\u4e00\u3002\u5e38\u7528\u7684\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u5305\u62ecARIMA\u3001SARIMA\u3001Prophet\u7b49\u3002<\/p>\n<\/p>\n<p><h4>4.1 ARIMA\u6a21\u578b<\/h4>\n<\/p>\n<p><p>ARIMA\u6a21\u578b\u662f\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u4e2d\u5e38\u7528\u7684\u6a21\u578b\u4e4b\u4e00\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from statsmodels.tsa.arima.model import ARIMA<\/p>\n<h2><strong>\u521b\u5efaARIMA\u6a21\u578b<\/strong><\/h2>\n<p>model = ARIMA(df[&#39;value&#39;], order=(5, 1, 0))<\/p>\n<p>model_fit = model.fit()<\/p>\n<h2><strong>\u9884\u6d4b<\/strong><\/h2>\n<p>forecast = model_fit.forecast(steps=10)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.2 SARIMA\u6a21\u578b<\/h4>\n<\/p>\n<p><p>SARIMA\u6a21\u578b\u9002\u7528\u4e8e\u6709\u5b63\u8282\u6027\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from statsmodels.tsa.statespace.sarimax import SARIMAX<\/p>\n<h2><strong>\u521b\u5efaSARIMA\u6a21\u578b<\/strong><\/h2>\n<p>model = SARIMAX(df[&#39;value&#39;], order=(1, 1, 1), seasonal_order=(1, 1, 1, 12))<\/p>\n<p>model_fit = model.fit()<\/p>\n<h2><strong>\u9884\u6d4b<\/strong><\/h2>\n<p>forecast = model_fit.forecast(steps=10)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.3 Prophet\u6a21\u578b<\/h4>\n<\/p>\n<p><p>Prophet\u6a21\u578b\u7531Facebook\u5f00\u53d1\uff0c\u9002\u7528\u4e8e\u5177\u6709\u660e\u663e\u5b63\u8282\u6027\u548c\u8282\u5047\u65e5\u5f71\u54cd\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from fbprophet import Prophet<\/p>\n<h2><strong>\u521b\u5efaProphet\u6a21\u578b<\/strong><\/h2>\n<p>df_prophet = df.reset_index().rename(columns={&#39;Date&#39;: &#39;ds&#39;, &#39;value&#39;: &#39;y&#39;})<\/p>\n<p>model = Prophet()<\/p>\n<p>model.fit(df_prophet)<\/p>\n<h2><strong>\u9884\u6d4b<\/strong><\/h2>\n<p>future = model.make_future_dataframe(periods=10)<\/p>\n<p>forecast = model.predict(future)<\/p>\n<h2><strong>\u53ef\u89c6\u5316\u9884\u6d4b\u7ed3\u679c<\/strong><\/h2>\n<p>model.plot(forecast)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u6a21\u578b\u8bc4\u4f30\u4e0e\u4f18\u5316<\/h3>\n<\/p>\n<p><p>\u5728\u5b8c\u6210\u5efa\u6a21\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u6a21\u578b\u7684\u6027\u80fd\u8fdb\u884c\u8bc4\u4f30\uff0c\u5e76\u6839\u636e\u8bc4\u4f30\u7ed3\u679c\u8fdb\u884c\u4f18\u5316\u3002<\/p>\n<\/p>\n<p><h4>5.1 \u6a21\u578b\u8bc4\u4f30<\/h4>\n<\/p>\n<p><p>\u5e38\u7528\u7684\u6a21\u578b\u8bc4\u4f30\u6307\u6807\u5305\u62ecMAE\u3001MSE\u548cRMSE\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.metrics import mean_absolute_error, mean_squared_error<\/p>\n<h2><strong>\u8ba1\u7b97\u8bc4\u4f30\u6307\u6807<\/strong><\/h2>\n<p>mae = mean_absolute_error(df[&#39;value&#39;], forecast)<\/p>\n<p>mse = mean_squared_error(df[&#39;value&#39;], forecast)<\/p>\n<p>rmse = np.sqrt(mse)<\/p>\n<p>print(f&#39;MAE: {mae}, MSE: {mse}, RMSE: {rmse}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5.2 \u53c2\u6570\u4f18\u5316<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u7f51\u683c\u641c\u7d22\u6216\u8d1d\u53f6\u65af\u4f18\u5316\u7b49\u65b9\u6cd5\u5bf9\u6a21\u578b\u53c2\u6570\u8fdb\u884c\u4f18\u5316\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.model_selection import GridSearchCV<\/p>\n<h2><strong>\u5b9a\u4e49\u53c2\u6570\u8303\u56f4<\/strong><\/h2>\n<p>param_grid = {<\/p>\n<p>    &#39;order&#39;: [(1, 1, 1), (2, 1, 2), (3, 1, 3)],<\/p>\n<p>    &#39;seasonal_order&#39;: [(1, 1, 1, 12), (2, 1, 2, 12)]<\/p>\n<p>}<\/p>\n<h2><strong>\u7f51\u683c\u641c\u7d22<\/strong><\/h2>\n<p>grid_search = GridSearchCV(estimator=SARIMAX(df[&#39;value&#39;]), param_grid=param_grid, scoring=&#39;neg_mean_squared_error&#39;, cv=3)<\/p>\n<p>grid_search.fit(df[&#39;value&#39;])<\/p>\n<h2><strong>\u6700\u4f73\u53c2\u6570<\/strong><\/h2>\n<p>best_params = grid_search.best_params_<\/p>\n<p>print(f&#39;Best Parameters: {best_params}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u5b8c\u6574\u5730\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u5206\u6790\u548c\u5efa\u6a21\u3002<strong>\u6570\u636e\u5bfc\u5165\u4e0e\u9884\u5904\u7406<\/strong>\u662f\u6574\u4e2a\u8fc7\u7a0b\u7684\u57fa\u7840\uff0c<strong>\u6570\u636e\u63a2\u7d22\u4e0e\u53ef\u89c6\u5316<\/strong>\u5e2e\u52a9\u6211\u4eec\u4e86\u89e3\u6570\u636e\u7684\u57fa\u672c\u7279\u5f81\uff0c<strong>\u65f6\u95f4\u5e8f\u5217\u5206\u89e3<\/strong>\u6709\u52a9\u4e8e\u6211\u4eec\u8bc6\u522b\u6570\u636e\u4e2d\u7684\u8d8b\u52bf\u548c\u5b63\u8282\u6027\uff0c<strong>\u5efa\u6a21\u4e0e\u9884\u6d4b<\/strong>\u662f\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u7684\u6838\u5fc3\u6b65\u9aa4\uff0c\u800c<strong>\u6a21\u578b\u8bc4\u4f30\u4e0e\u4f18\u5316<\/strong>\u5219\u5e2e\u52a9\u6211\u4eec\u63d0\u9ad8\u6a21\u578b\u7684\u51c6\u786e\u6027\u548c\u9c81\u68d2\u6027\u3002<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u4e0d\u540c\u7684\u6570\u636e\u96c6\u548c\u4e1a\u52a1\u9700\u6c42\u53ef\u80fd\u9700\u8981\u4e0d\u540c\u7684\u65b9\u6cd5\u548c\u6280\u5de7\u3002\u901a\u8fc7\u4e0d\u65ad\u5730\u5b9e\u8df5\u548c\u603b\u7ed3\u7ecf\u9a8c\uff0c\u6211\u4eec\u53ef\u4ee5\u9010\u6b65\u63d0\u9ad8\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u7684\u80fd\u529b\u548c\u6c34\u5e73\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5206\u6790\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u901a\u5e38\u4f7f\u7528Pandas\u5e93\u8fdb\u884c\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u3002Pandas\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u7ed3\u6784\uff0c\u7279\u522b\u662f<code>DataFrame<\/code>\u548c<code>Series<\/code>\uff0c\u4f7f\u5f97\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u53d8\u5f97\u66f4\u52a0\u7b80\u4fbf\u3002\u53ef\u4ee5\u901a\u8fc7<code>pd.to_datetime()<\/code>\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u65f6\u95f4\u683c\u5f0f\uff0c\u5e76\u5229\u7528<code>.resample()<\/code>\u8fdb\u884c\u91cd\u91c7\u6837\uff0c\u4ece\u800c\u5206\u6790\u4e0d\u540c\u65f6\u95f4\u9891\u7387\u7684\u6570\u636e\u3002\u6b64\u5916\uff0cMatplotlib\u548cSeaborn\u7b49\u53ef\u89c6\u5316\u5e93\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7ed8\u5236\u65f6\u95f4\u5e8f\u5217\u56fe\uff0c\u4fbf\u4e8e\u89c2\u5bdf\u8d8b\u52bf\u548c\u5b63\u8282\u6027\u53d8\u5316\u3002<\/p>\n<p><strong>\u6709\u54ea\u4e9b\u5e38\u7528\u7684Python\u5e93\u9002\u5408\u65f6\u95f4\u5e8f\u5217\u5904\u7406\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u5e38\u7528\u5e93\u5305\u62ecPandas\u3001NumPy\u3001Statsmodels\u548cscikit-learn\u3002Pandas\u662f\u6700\u5e38\u7528\u7684\u6570\u636e\u5904\u7406\u5e93\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u5185\u7f6e\u51fd\u6570\u6765\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002Statsmodels\u5219\u7279\u522b\u9002\u7528\u4e8e\u7edf\u8ba1\u5efa\u6a21\u548c\u65f6\u95f4\u5e8f\u5217\u9884\u6d4b\uff0c\u63d0\u4f9b\u4e86\u5982ARIMA\u548cSARIMA\u7b49\u6a21\u578b\u8fdb\u884c\u5206\u6790\u3002scikit-learn\u5219\u9002\u5408\u7528\u4e8e<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u6a21\u578b\u7684\u6784\u5efa\uff0c\u80fd\u591f\u5bf9\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u8fdb\u884c\u66f4\u590d\u6742\u7684\u9884\u6d4b\u3002<\/p>\n<p><strong>\u5982\u4f55\u8bc4\u4f30\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u7684\u6027\u80fd\uff1f<\/strong><br \/>\u8bc4\u4f30\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u7684\u6027\u80fd\u901a\u5e38\u4f7f\u7528\u591a\u79cd\u6307\u6807\uff0c\u5305\u62ec\u5747\u65b9\u6839\u8bef\u5dee\uff08RMSE\uff09\u3001\u5e73\u5747\u7edd\u5bf9\u8bef\u5dee\uff08MAE\uff09\u548cR\u00b2\u503c\u7b49\u3002RMSE\u548cMAE\u80fd\u591f\u53cd\u6620\u9884\u6d4b\u503c\u4e0e\u5b9e\u9645\u503c\u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u6570\u503c\u8d8a\u4f4e\u8868\u793a\u6a21\u578b\u7684\u9884\u6d4b\u6027\u80fd\u8d8a\u597d\u3002R\u00b2\u503c\u5219\u7528\u4e8e\u8861\u91cf\u6a21\u578b\u5bf9\u6570\u636e\u53d8\u5f02\u6027\u7684\u89e3\u91ca\u80fd\u529b\uff0c\u503c\u8d8a\u63a5\u8fd11\u8868\u793a\u6a21\u578b\u6027\u80fd\u8d8a\u5f3a\u3002\u6b64\u5916\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ea4\u53c9\u9a8c\u8bc1\u7b49\u65b9\u6cd5\u5bf9\u6a21\u578b\u8fdb\u884c\u66f4\u5168\u9762\u7684\u8bc4\u4f30\uff0c\u4ee5\u786e\u4fdd\u5176\u6cdb\u5316\u80fd\u529b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u5173\u952e\u6b65\u9aa4\u5305\u62ec\u6570\u636e\u5bfc\u5165\u4e0e\u9884\u5904\u7406\u3001\u6570\u636e\u63a2\u7d22\u4e0e\u53ef\u89c6\u5316\u3001\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u3001\u5efa\u6a21\u4e0e\u9884\u6d4b\u3001\u6a21 [&hellip;]","protected":false},"author":3,"featured_media":1170879,"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\/1170874"}],"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=1170874"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1170874\/revisions"}],"predecessor-version":[{"id":1170881,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1170874\/revisions\/1170881"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1170879"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1170874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1170874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1170874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}