{"id":1172647,"date":"2025-01-15T16:52:17","date_gmt":"2025-01-15T08:52:17","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1172647.html"},"modified":"2025-01-15T16:52:20","modified_gmt":"2025-01-15T08:52:20","slug":"%e5%a6%82%e4%bd%95%e5%a4%84%e7%90%86python%e6%97%b6%e9%97%b4%e5%ba%8f%e5%88%97","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1172647.html","title":{"rendered":"\u5982\u4f55\u5904\u7406python\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\/26074636\/8337c299-55cf-4228-abb1-b25a2d904200.webp\" alt=\"\u5982\u4f55\u5904\u7406python\u65f6\u95f4\u5e8f\u5217\" \/><\/p>\n<p><p> <strong>\u5904\u7406Python\u65f6\u95f4\u5e8f\u5217\u7684\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528pandas\u5e93\u3001\u8fdb\u884c\u6570\u636e\u6e05\u6d17\u3001\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u3001\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5efa\u6a21\u3002<\/strong>\u5176\u4e2d\uff0c<strong>\u4f7f\u7528pandas\u5e93<\/strong>\u662f\u4e00\u4e2a\u5173\u952e\u6b65\u9aa4\uff0cpandas\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u529f\u80fd\u6765\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u5305\u62ec\u65f6\u95f4\u7d22\u5f15\u3001\u91cd\u91c7\u6837\u3001\u79fb\u52a8\u7a97\u53e3\u8ba1\u7b97\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528Pandas\u5e93<\/h3>\n<\/p>\n<p><p><strong>pandas<\/strong>\u662fPython\u4e2d\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u4e3b\u8981\u5e93\u4e4b\u4e00\u3002\u5b83\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u529f\u80fd\u6765\u8fdb\u884c\u6570\u636e\u64cd\u4f5c\u548c\u5206\u6790\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002\u5728pandas\u4e2d\uff0c\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u901a\u5e38\u662f\u4ee5<strong>DatetimeIndex<\/strong>\u7d22\u5f15\u7684DataFrame\u6216Series\u5f62\u5f0f\u5b58\u50a8\u7684\u3002<\/p>\n<\/p>\n<p><h4>1. \u521b\u5efa\u65f6\u95f4\u5e8f\u5217\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u8981\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u9996\u5148\u9700\u8981\u521b\u5efa\u6216\u8bfb\u53d6\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>pd.date_range()<\/code>\u51fd\u6570\u6765\u751f\u6210\u4e00\u4e2a\u65f6\u95f4\u8303\u56f4\uff0c\u7136\u540e\u5c06\u5176\u4f5c\u4e3a\u7d22\u5f15\u521b\u5efa\u4e00\u4e2a\u65f6\u95f4\u5e8f\u5217\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>\u521b\u5efa\u4e00\u4e2a\u65f6\u95f4\u8303\u56f4<\/strong><\/h2>\n<p>date_range = pd.date_range(start=&#39;2020-01-01&#39;, end=&#39;2020-12-31&#39;, freq=&#39;D&#39;)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u968f\u673a\u65f6\u95f4\u5e8f\u5217\u6570\u636e<\/strong><\/h2>\n<p>data = np.random.randn(len(date_range))<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u65f6\u95f4\u5e8f\u5217DataFrame<\/strong><\/h2>\n<p>time_series = pd.DataFrame(data, index=date_range, columns=[&#39;Value&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u6570\u636e\u8bfb\u53d6\u4e0e\u89e3\u6790<\/h4>\n<\/p>\n<p><p>pandas\u53ef\u4ee5\u65b9\u4fbf\u5730\u8bfb\u53d6\u548c\u89e3\u6790\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u5e38\u89c1\u7684\u6570\u636e\u683c\u5f0f\u5305\u62ecCSV\u3001Excel\u7b49\u3002\u4f7f\u7528<code>pd.read_csv()<\/code>\u548c<code>pd.read_excel()<\/code>\u51fd\u6570\u53ef\u4ee5\u8f7b\u677e\u8bfb\u53d6\u5e26\u6709\u65f6\u95f4\u7d22\u5f15\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u5e26\u6709\u65f6\u95f4\u7d22\u5f15\u7684CSV\u6587\u4ef6<\/p>\n<p>time_series = pd.read_csv(&#39;time_series_data.csv&#39;, index_col=&#39;Date&#39;, parse_dates=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u8fdb\u884c\u6570\u636e\u6e05\u6d17<\/h3>\n<\/p>\n<p><p>\u5728\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u4e4b\u524d\uff0c\u6570\u636e\u6e05\u6d17\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u6b65\u9aa4\u3002\u6570\u636e\u6e05\u6d17\u5305\u62ec\u5904\u7406\u7f3a\u5931\u503c\u3001\u53bb\u9664\u5f02\u5e38\u503c\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. \u5904\u7406\u7f3a\u5931\u503c<\/h4>\n<\/p>\n<p><p>\u5728\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u4e2d\uff0c\u7f3a\u5931\u503c\u662f\u5e38\u89c1\u7684\u95ee\u9898\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u63d2\u503c\u65b9\u6cd5\u6765\u586b\u8865\u7f3a\u5931\u503c\uff0c\u6216\u4f7f\u7528\u5220\u9664\u65b9\u6cd5\u6765\u53bb\u9664\u5305\u542b\u7f3a\u5931\u503c\u7684\u8bb0\u5f55\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u7ebf\u6027\u63d2\u503c\u586b\u8865\u7f3a\u5931\u503c<\/p>\n<p>time_series.interpolate(method=&#39;linear&#39;, inplace=True)<\/p>\n<h2><strong>\u5220\u9664\u5305\u542b\u7f3a\u5931\u503c\u7684\u8bb0\u5f55<\/strong><\/h2>\n<p>time_series.dropna(inplace=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u53bb\u9664\u5f02\u5e38\u503c<\/h4>\n<\/p>\n<p><p>\u53bb\u9664\u5f02\u5e38\u503c\u4e5f\u662f\u6570\u636e\u6e05\u6d17\u7684\u91cd\u8981\u6b65\u9aa4\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u7edf\u8ba1\u65b9\u6cd5\u6216<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u65b9\u6cd5\u6765\u68c0\u6d4b\u548c\u53bb\u9664\u5f02\u5e38\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528Z-score\u65b9\u6cd5\u68c0\u6d4b\u548c\u53bb\u9664\u5f02\u5e38\u503c<\/p>\n<p>from scipy.stats import zscore<\/p>\n<p>time_series = time_series[(np.abs(zscore(time_series[&#39;Value&#39;])) &lt; 3)]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5206\u89e3<\/h3>\n<\/p>\n<p><p>\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u662f\u5c06\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u5206\u89e3\u6210\u8d8b\u52bf\u3001\u5b63\u8282\u6027\u548c\u6b8b\u5dee\u4e09\u90e8\u5206\u3002\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u6709\u52a9\u4e8e\u7406\u89e3\u6570\u636e\u7684\u7ec4\u6210\u90e8\u5206\uff0c\u5e76\u7528\u4e8e\u8fdb\u4e00\u6b65\u7684\u5206\u6790\u548c\u5efa\u6a21\u3002<\/p>\n<\/p>\n<p><h4>1. \u8d8b\u52bf\u548c\u5b63\u8282\u6027\u5206\u89e3<\/h4>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>statsmodels<\/code>\u5e93\u4e2d\u7684<code>seasonal_decompose()<\/code>\u51fd\u6570\u6765\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<h2><strong>\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5206\u89e3<\/strong><\/h2>\n<p>result = seasonal_decompose(time_series, model=&#39;additive&#39;)<\/p>\n<h2><strong>\u7ed8\u5236\u5206\u89e3\u7ed3\u679c<\/strong><\/h2>\n<p>result.plot()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u79fb\u52a8\u5e73\u5747\u6cd5<\/h4>\n<\/p>\n<p><p>\u79fb\u52a8\u5e73\u5747\u6cd5\u662f\u53e6\u4e00\u79cd\u5e38\u7528\u7684\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u65b9\u6cd5\u3002\u5b83\u901a\u8fc7\u8ba1\u7b97\u65f6\u95f4\u5e8f\u5217\u7684\u79fb\u52a8\u5e73\u5747\u503c\u6765\u5e73\u6ed1\u6570\u636e\uff0c\u4ece\u800c\u63ed\u793a\u8d8b\u52bf\u548c\u5b63\u8282\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u79fb\u52a8\u5e73\u5747\u503c<\/p>\n<p>time_series[&#39;Moving_Average&#39;] = time_series[&#39;Value&#39;].rolling(window=12).mean()<\/p>\n<h2><strong>\u7ed8\u5236\u79fb\u52a8\u5e73\u5747\u503c<\/strong><\/h2>\n<p>time_series[[&#39;Value&#39;, &#39;Moving_Average&#39;]].plot()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5efa\u6a21<\/h3>\n<\/p>\n<p><p>\u65f6\u95f4\u5e8f\u5217\u5efa\u6a21\u662f\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u7684\u6838\u5fc3\u6b65\u9aa4\u3002\u5e38\u7528\u7684\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u5305\u62ecARIMA\u3001SARIMA\u3001Prophet\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. ARIMA\u6a21\u578b<\/h4>\n<\/p>\n<p><p>ARIMA\uff08AutoRegressive Integrated Moving Average\uff09\u6a21\u578b\u662f\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u4e2d\u5e38\u7528\u7684\u6a21\u578b\u4e4b\u4e00\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>statsmodels<\/code>\u5e93\u4e2d\u7684<code>ARIMA<\/code>\u7c7b\u6765\u6784\u5efa\u548c\u62df\u5408ARIMA\u6a21\u578b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from statsmodels.tsa.arima.model import ARIMA<\/p>\n<h2><strong>\u62df\u5408ARIMA\u6a21\u578b<\/strong><\/h2>\n<p>model = ARIMA(time_series[&#39;Value&#39;], order=(1, 1, 1))<\/p>\n<p>model_fit = model.fit()<\/p>\n<h2><strong>\u6253\u5370\u6a21\u578b\u6458\u8981<\/strong><\/h2>\n<p>print(model_fit.summary())<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>forecast = model_fit.forecast(steps=12)<\/p>\n<h2><strong>\u7ed8\u5236\u9884\u6d4b\u7ed3\u679c<\/strong><\/h2>\n<p>time_series[&#39;Forecast&#39;] = forecast<\/p>\n<p>time_series[[&#39;Value&#39;, &#39;Forecast&#39;]].plot()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. SARIMA\u6a21\u578b<\/h4>\n<\/p>\n<p><p>SARIMA\uff08Seasonal ARIMA\uff09\u6a21\u578b\u662f\u5728ARIMA\u6a21\u578b\u7684\u57fa\u7840\u4e0a\u52a0\u5165\u4e86\u5b63\u8282\u6027\u6210\u5206\uff0c\u9002\u7528\u4e8e\u5177\u6709\u5b63\u8282\u6027\u7279\u5f81\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>\u62df\u5408SARIMA\u6a21\u578b<\/strong><\/h2>\n<p>model = SARIMAX(time_series[&#39;Value&#39;], order=(1, 1, 1), seasonal_order=(1, 1, 1, 12))<\/p>\n<p>model_fit = model.fit()<\/p>\n<h2><strong>\u6253\u5370\u6a21\u578b\u6458\u8981<\/strong><\/h2>\n<p>print(model_fit.summary())<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>forecast = model_fit.forecast(steps=12)<\/p>\n<h2><strong>\u7ed8\u5236\u9884\u6d4b\u7ed3\u679c<\/strong><\/h2>\n<p>time_series[&#39;Forecast&#39;] = forecast<\/p>\n<p>time_series[[&#39;Value&#39;, &#39;Forecast&#39;]].plot()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. Prophet\u6a21\u578b<\/h4>\n<\/p>\n<p><p>Prophet\u662fFacebook\u5f00\u53d1\u7684\u65f6\u95f4\u5e8f\u5217\u9884\u6d4b\u6a21\u578b\uff0c\u7279\u522b\u9002\u7528\u4e8e\u5177\u6709\u8282\u5047\u65e5\u6548\u5e94\u548c\u975e\u7ebf\u6027\u8d8b\u52bf\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>fbprophet<\/code>\u5e93\u6765\u6784\u5efa\u548c\u62df\u5408Prophet\u6a21\u578b\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>model = Prophet()<\/p>\n<h2><strong>\u51c6\u5907\u6570\u636e<\/strong><\/h2>\n<p>time_series.reset_index(inplace=True)<\/p>\n<p>time_series.rename(columns={&#39;index&#39;: &#39;ds&#39;, &#39;Value&#39;: &#39;y&#39;}, inplace=True)<\/p>\n<h2><strong>\u62df\u5408Prophet\u6a21\u578b<\/strong><\/h2>\n<p>model.fit(time_series)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>future = model.make_future_dataframe(periods=12, freq=&#39;M&#39;)<\/p>\n<p>forecast = model.predict(future)<\/p>\n<h2><strong>\u7ed8\u5236\u9884\u6d4b\u7ed3\u679c<\/strong><\/h2>\n<p>model.plot(forecast)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u65f6\u95f4\u5e8f\u5217\u7684\u53ef\u89c6\u5316<\/h3>\n<\/p>\n<p><p>\u6570\u636e\u53ef\u89c6\u5316\u662f\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\uff0c\u901a\u8fc7\u53ef\u89c6\u5316\u6211\u4eec\u53ef\u4ee5\u76f4\u89c2\u5730\u89c2\u5bdf\u6570\u636e\u7684\u8d8b\u52bf\u3001\u5b63\u8282\u6027\u548c\u5f02\u5e38\u503c\u3002<\/p>\n<\/p>\n<p><h4>1. \u65f6\u95f4\u5e8f\u5217\u7684\u57fa\u672c\u7ed8\u56fe<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528pandas\u548cmatplotlib\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ed8\u5236\u65f6\u95f4\u5e8f\u5217\u56fe\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u7ed8\u5236\u65f6\u95f4\u5e8f\u5217\u56fe<\/strong><\/h2>\n<p>time_series[&#39;Value&#39;].plot()<\/p>\n<p>plt.title(&#39;Time Series Plot&#39;)<\/p>\n<p>plt.xlabel(&#39;Date&#39;)<\/p>\n<p>plt.ylabel(&#39;Value&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u8d8b\u52bf\u548c\u5b63\u8282\u6027\u7684\u53ef\u89c6\u5316<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u7ed3\u679c\uff0c\u53ef\u4ee5\u5206\u522b\u7ed8\u5236\u8d8b\u52bf\u548c\u5b63\u8282\u6027\u6210\u5206\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u8d8b\u52bf\u548c\u5b63\u8282\u6027\u6210\u5206<\/p>\n<p>result.trend.plot()<\/p>\n<p>plt.title(&#39;Trend Component&#39;)<\/p>\n<p>plt.show()<\/p>\n<p>result.seasonal.plot()<\/p>\n<p>plt.title(&#39;Seasonal Component&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u65f6\u95f4\u5e8f\u5217\u7684\u7279\u5f81\u5de5\u7a0b<\/h3>\n<\/p>\n<p><p>\u7279\u5f81\u5de5\u7a0b\u662f\u63d0\u9ad8\u6a21\u578b\u6027\u80fd\u7684\u91cd\u8981\u6b65\u9aa4\u3002\u5bf9\u4e8e\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u53ef\u4ee5\u63d0\u53d6\u65f6\u95f4\u7279\u5f81\u3001\u6ede\u540e\u7279\u5f81\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. \u63d0\u53d6\u65f6\u95f4\u7279\u5f81<\/h4>\n<\/p>\n<p><p>\u63d0\u53d6\u65f6\u95f4\u7279\u5f81\u53ef\u4ee5\u5e2e\u52a9\u6a21\u578b\u66f4\u597d\u5730\u6355\u6349\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u65f6\u95f4\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u63d0\u53d6\u65f6\u95f4\u7279\u5f81<\/p>\n<p>time_series[&#39;Year&#39;] = time_series.index.year<\/p>\n<p>time_series[&#39;Month&#39;] = time_series.index.month<\/p>\n<p>time_series[&#39;Day&#39;] = time_series.index.day<\/p>\n<p>time_series[&#39;DayOfWeek&#39;] = time_series.index.dayofweek<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u63d0\u53d6\u6ede\u540e\u7279\u5f81<\/h4>\n<\/p>\n<p><p>\u6ede\u540e\u7279\u5f81\u662f\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u5386\u53f2\u503c\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6a21\u578b\u6355\u6349\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u4f9d\u8d56\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u63d0\u53d6\u6ede\u540e\u7279\u5f81<\/p>\n<p>time_series[&#39;Lag_1&#39;] = time_series[&#39;Value&#39;].shift(1)<\/p>\n<p>time_series[&#39;Lag_2&#39;] = time_series[&#39;Value&#39;].shift(2)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u65f6\u95f4\u5e8f\u5217\u7684\u6a21\u578b\u8bc4\u4ef7<\/h3>\n<\/p>\n<p><p>\u6a21\u578b\u8bc4\u4ef7\u662f\u65f6\u95f4\u5e8f\u5217\u5efa\u6a21\u7684\u6700\u540e\u4e00\u6b65\uff0c\u7528\u4e8e\u8bc4\u4f30\u6a21\u578b\u7684\u6027\u80fd\u3002\u5e38\u7528\u7684\u6a21\u578b\u8bc4\u4ef7\u6307\u6807\u5305\u62ec\u5747\u65b9\u8bef\u5dee\uff08MSE\uff09\u3001\u5747\u65b9\u6839\u8bef\u5dee\uff08RMSE\uff09\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. \u5747\u65b9\u8bef\u5dee\uff08MSE\uff09<\/h4>\n<\/p>\n<p><p>\u5747\u65b9\u8bef\u5dee\u662f\u9884\u6d4b\u503c\u4e0e\u5b9e\u9645\u503c\u4e4b\u95f4\u5dee\u503c\u7684\u5e73\u65b9\u548c\u7684\u5e73\u5747\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.metrics import mean_squared_error<\/p>\n<h2><strong>\u8ba1\u7b97\u5747\u65b9\u8bef\u5dee<\/strong><\/h2>\n<p>mse = mean_squared_error(time_series[&#39;Value&#39;], time_series[&#39;Forecast&#39;])<\/p>\n<p>print(&#39;Mean Squared Error:&#39;, mse)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u5747\u65b9\u6839\u8bef\u5dee\uff08RMSE\uff09<\/h4>\n<\/p>\n<p><p>\u5747\u65b9\u6839\u8bef\u5dee\u662f\u5747\u65b9\u8bef\u5dee\u7684\u5e73\u65b9\u6839\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u5747\u65b9\u6839\u8bef\u5dee<\/p>\n<p>rmse = np.sqrt(mse)<\/p>\n<p>print(&#39;Root Mean Squared Error:&#39;, rmse)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u65f6\u95f4\u5e8f\u5217\u7684\u5e94\u7528\u6848\u4f8b<\/h3>\n<\/p>\n<p><p>\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u5728\u5404\u4e2a\u9886\u57df\u90fd\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u5305\u62ec\u91d1\u878d\u3001\u96f6\u552e\u3001\u6c14\u8c61\u7b49\u3002\u4ee5\u4e0b\u662f\u51e0\u4e2a\u5178\u578b\u7684\u5e94\u7528\u6848\u4f8b\u3002<\/p>\n<\/p>\n<p><h4>1. \u80a1\u7968\u4ef7\u683c\u9884\u6d4b<\/h4>\n<\/p>\n<p><p>\u80a1\u7968\u4ef7\u683c\u662f\u5178\u578b\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u65b9\u6cd5\u8fdb\u884c\u9884\u6d4b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u80a1\u7968\u4ef7\u683c\u6570\u636e<\/p>\n<p>stock_data = pd.read_csv(&#39;stock_prices.csv&#39;, index_col=&#39;Date&#39;, parse_dates=True)<\/p>\n<h2><strong>\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5206\u89e3<\/strong><\/h2>\n<p>result = seasonal_decompose(stock_data[&#39;Close&#39;], model=&#39;multiplicative&#39;)<\/p>\n<h2><strong>\u62df\u5408ARIMA\u6a21\u578b<\/strong><\/h2>\n<p>model = ARIMA(stock_data[&#39;Close&#39;], order=(5, 1, 0))<\/p>\n<p>model_fit = model.fit()<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>forecast = model_fit.forecast(steps=30)<\/p>\n<h2><strong>\u7ed8\u5236\u9884\u6d4b\u7ed3\u679c<\/strong><\/h2>\n<p>stock_data[&#39;Forecast&#39;] = forecast<\/p>\n<p>stock_data[[&#39;Close&#39;, &#39;Forecast&#39;]].plot()<\/p>\n<p>plt.title(&#39;Stock Price Prediction&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u96f6\u552e\u9500\u91cf\u9884\u6d4b<\/h4>\n<\/p>\n<p><p>\u96f6\u552e\u9500\u91cf\u6570\u636e\u901a\u5e38\u5177\u6709\u660e\u663e\u7684\u5b63\u8282\u6027\uff0c\u53ef\u4ee5\u4f7f\u7528SARIMA\u6a21\u578b\u8fdb\u884c\u9884\u6d4b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u96f6\u552e\u9500\u91cf\u6570\u636e<\/p>\n<p>sales_data = pd.read_csv(&#39;ret<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>l_sales.csv&#39;, index_col=&#39;Date&#39;, parse_dates=True)<\/p>\n<h2><strong>\u62df\u5408SARIMA\u6a21\u578b<\/strong><\/h2>\n<p>model = SARIMAX(sales_data[&#39;Sales&#39;], order=(1, 1, 1), seasonal_order=(1, 1, 1, 12))<\/p>\n<p>model_fit = model.fit()<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>forecast = model_fit.forecast(steps=12)<\/p>\n<h2><strong>\u7ed8\u5236\u9884\u6d4b\u7ed3\u679c<\/strong><\/h2>\n<p>sales_data[&#39;Forecast&#39;] = forecast<\/p>\n<p>sales_data[[&#39;Sales&#39;, &#39;Forecast&#39;]].plot()<\/p>\n<p>plt.title(&#39;Retail Sales Prediction&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u5929\u6c14\u9884\u62a5<\/h4>\n<\/p>\n<p><p>\u6c14\u8c61\u6570\u636e\u662f\u5178\u578b\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528Prophet\u6a21\u578b\u8fdb\u884c\u9884\u6d4b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u6c14\u8c61\u6570\u636e<\/p>\n<p>weather_data = pd.read_csv(&#39;weather_data.csv&#39;, index_col=&#39;Date&#39;, parse_dates=True)<\/p>\n<h2><strong>\u521b\u5efaProphet\u6a21\u578b<\/strong><\/h2>\n<p>model = Prophet()<\/p>\n<h2><strong>\u51c6\u5907\u6570\u636e<\/strong><\/h2>\n<p>weather_data.reset_index(inplace=True)<\/p>\n<p>weather_data.rename(columns={&#39;index&#39;: &#39;ds&#39;, &#39;Temperature&#39;: &#39;y&#39;}, inplace=True)<\/p>\n<h2><strong>\u62df\u5408Prophet\u6a21\u578b<\/strong><\/h2>\n<p>model.fit(weather_data)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>future = model.make_future_dataframe(periods=30, freq=&#39;D&#39;)<\/p>\n<p>forecast = model.predict(future)<\/p>\n<h2><strong>\u7ed8\u5236\u9884\u6d4b\u7ed3\u679c<\/strong><\/h2>\n<p>model.plot(forecast)<\/p>\n<p>plt.title(&#39;Weather Forecast&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e5d\u3001\u65f6\u95f4\u5e8f\u5217\u7684\u9ad8\u7ea7\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u57fa\u672c\u7684\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u65b9\u6cd5\uff0c\u8fd8\u6709\u4e00\u4e9b\u9ad8\u7ea7\u5904\u7406\u65b9\u6cd5\u53ef\u4ee5\u63d0\u9ad8\u5206\u6790\u548c\u9884\u6d4b\u7684\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<p><h4>1. \u65f6\u95f4\u5e8f\u5217\u7684\u5e73\u7a33\u6027\u68c0\u6d4b<\/h4>\n<\/p>\n<p><p>\u5e73\u7a33\u6027\u662f\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u7684\u91cd\u8981\u5047\u8bbe\u3002\u53ef\u4ee5\u4f7f\u7528ADF\uff08Augmented Dickey-Fuller\uff09\u68c0\u9a8c\u6765\u68c0\u6d4b\u65f6\u95f4\u5e8f\u5217\u7684\u5e73\u7a33\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from statsmodels.tsa.stattools import adfuller<\/p>\n<h2><strong>\u8fdb\u884cADF\u68c0\u9a8c<\/strong><\/h2>\n<p>result = adfuller(time_series[&#39;Value&#39;])<\/p>\n<p>print(&#39;ADF Statistic:&#39;, result[0])<\/p>\n<p>print(&#39;p-value:&#39;, result[1])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u65f6\u95f4\u5e8f\u5217\u7684\u5dee\u5206\u5904\u7406<\/h4>\n<\/p>\n<p><p>\u5dee\u5206\u5904\u7406\u662f\u4e00\u79cd\u5c06\u975e\u5e73\u7a33\u65f6\u95f4\u5e8f\u5217\u8f6c\u6362\u4e3a\u5e73\u7a33\u65f6\u95f4\u5e8f\u5217\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8fdb\u884c\u5dee\u5206\u5904\u7406<\/p>\n<p>time_series[&#39;Differenced&#39;] = time_series[&#39;Value&#39;].diff()<\/p>\n<h2><strong>\u7ed8\u5236\u5dee\u5206\u540e\u7684\u65f6\u95f4\u5e8f\u5217<\/strong><\/h2>\n<p>time_series[&#39;Differenced&#39;].plot()<\/p>\n<p>plt.title(&#39;Differenced Time Series&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u65f6\u95f4\u5e8f\u5217\u7684\u5b63\u8282\u6027\u8c03\u6574<\/h4>\n<\/p>\n<p><p>\u5b63\u8282\u6027\u8c03\u6574\u662f\u53bb\u9664\u65f6\u95f4\u5e8f\u5217\u4e2d\u5b63\u8282\u6027\u6210\u5206\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4f7f\u7528<code>seasonal_decompose()<\/code>\u51fd\u6570\u7684\u5b63\u8282\u6027\u6210\u5206\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8fdb\u884c\u5b63\u8282\u6027\u8c03\u6574<\/p>\n<p>time_series[&#39;Seasonally_Adjusted&#39;] = time_series[&#39;Value&#39;] - result.seasonal<\/p>\n<h2><strong>\u7ed8\u5236\u5b63\u8282\u6027\u8c03\u6574\u540e\u7684\u65f6\u95f4\u5e8f\u5217<\/strong><\/h2>\n<p>time_series[&#39;Seasonally_Adjusted&#39;].plot()<\/p>\n<p>plt.title(&#39;Seasonally Adjusted Time Series&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u3001\u65f6\u95f4\u5e8f\u5217\u7684\u672a\u6765\u53d1\u5c55\u65b9\u5411<\/h3>\n<\/p>\n<p><p>\u968f\u7740\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\u7684\u53d1\u5c55\uff0c\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u4e5f\u5728\u4e0d\u65ad\u8fdb\u6b65\u3002\u4ee5\u4e0b\u662f\u51e0\u4e2a\u672a\u6765\u7684\u53d1\u5c55\u65b9\u5411\u3002<\/p>\n<\/p>\n<p><h4>1. \u6df1\u5ea6\u5b66\u4e60\u5728\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u4e2d\u7684\u5e94\u7528<\/h4>\n<\/p>\n<p><p>\u6df1\u5ea6\u5b66\u4e60\u5728\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u4e2d\u7684\u5e94\u7528\u8d8a\u6765\u8d8a\u5e7f\u6cdb\uff0c\u7279\u522b\u662fRNN\uff08\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff09\u548cLSTM\uff08\u957f\u77ed\u671f\u8bb0\u5fc6\u7f51\u7edc\uff09\u5728\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u65b9\u9762\u8868\u73b0\u51fa\u8272\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tensorflow as tf<\/p>\n<p>from tensorflow.keras.models import Sequential<\/p>\n<p>from tensorflow.keras.layers import LSTM, Dense<\/p>\n<h2><strong>\u51c6\u5907\u6570\u636e<\/strong><\/h2>\n<p>X = time_series[[&#39;Lag_1&#39;, &#39;Lag_2&#39;]].values[2:]<\/p>\n<p>y = time_series[&#39;Value&#39;].values[2:]<\/p>\n<h2><strong>\u6784\u5efaLSTM\u6a21\u578b<\/strong><\/h2>\n<p>model = Sequential()<\/p>\n<p>model.add(LSTM(50, input_shape=(X.shape[1], 1)))<\/p>\n<p>model.add(Dense(1))<\/p>\n<p>model.compile(loss=&#39;mean_squared_error&#39;, optimizer=&#39;adam&#39;)<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>model.fit(X, y, epochs=100, batch_size=1, verbose=2)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>forecast = model.predict(X[-12:])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u65f6\u95f4\u5e8f\u5217\u5206\u6790\u5de5\u5177\u548c\u5e73\u53f0\u7684\u53d1\u5c55<\/h4>\n<\/p>\n<p><p>\u968f\u7740\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u7684\u9700\u6c42\u589e\u52a0\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u5de5\u5177\u548c\u5e73\u53f0\u6d8c\u73b0\u51fa\u6765\uff0c\u5982Facebook\u7684Prophet\u3001Google\u7684TensorFlow\u7b49\u3002\u8fd9\u4e9b\u5de5\u5177\u548c\u5e73\u53f0\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u529f\u80fd\u548c\u6613\u7528\u7684\u754c\u9762\uff0c\u5e2e\u52a9\u6570\u636e\u79d1\u5b66\u5bb6\u548c\u5206\u6790\u5e08\u66f4\u9ad8\u6548\u5730\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u3002<\/p>\n<\/p>\n<p><h4>3. \u65f6\u95f4\u5e8f\u5217\u5206\u6790\u4e0e\u5927\u6570\u636e\u6280\u672f\u7684\u7ed3\u5408<\/h4>\n<\/p>\n<p><p>\u968f\u7740\u5927\u6570\u636e\u6280\u672f\u7684\u53d1\u5c55\uff0c\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u4e5f\u9010\u6e10\u4e0e\u5927\u6570\u636e\u6280\u672f\u7ed3\u5408\uff0c\u901a\u8fc7\u5206\u5e03\u5f0f\u8ba1\u7b97\u548c\u5b58\u50a8\u6280\u672f\uff0c\u53ef\u4ee5\u5904\u7406\u66f4\u5927\u89c4\u6a21\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u63d0\u9ad8\u5206\u6790\u548c\u9884\u6d4b\u7684\u51c6\u786e\u6027\u548c\u6548\u7387\u3002<\/p>\n<\/p>\n<p><p>\u7efc\u4e0a\u6240\u8ff0\uff0cPython\u65f6\u95f4\u5e8f\u5217\u7684\u5904\u7406\u65b9\u6cd5\u4e30\u5bcc\u591a\u6837\uff0c\u5305\u62ec\u6570\u636e\u6e05\u6d17\u3001\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u3001\u65f6\u95f4\u5e8f\u5217\u5efa\u6a21\u3001\u6a21\u578b\u8bc4\u4ef7\u3001\u7279\u5f81\u5de5\u7a0b\u7b49\u591a\u4e2a\u6b65\u9aa4\u3002\u901a\u8fc7\u4f7f\u7528pandas\u3001statsmodels\u3001fbprophet\u7b49\u5e93\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u548c\u9884\u6d4b\u3002\u540c\u65f6\uff0c\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u548c\u5927\u6570\u636e\u6280\u672f\u7684\u53d1\u5c55\uff0c\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u4e5f\u5728\u4e0d\u65ad\u8fdb\u6b65\uff0c\u672a\u6765\u5c06\u6709\u66f4\u591a\u7684\u5e94\u7528\u548c\u53d1\u5c55\u65b9\u5411\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8bfb\u53d6\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff1f<\/strong><br \/>\u8981\u8bfb\u53d6\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528Pandas\u5e93\u4e2d\u7684<code>read_csv<\/code>\u51fd\u6570\uff0c\u7ed3\u5408<code>parse_dates<\/code>\u53c2\u6570\u5c06\u65e5\u671f\u5217\u89e3\u6790\u4e3a\u65e5\u671f\u65f6\u95f4\u683c\u5f0f\u3002\u786e\u4fdd\u5728\u8bfb\u53d6\u6570\u636e\u65f6\u6307\u5b9a\u9002\u5f53\u7684\u65e5\u671f\u89e3\u6790\u683c\u5f0f\uff0c\u4ee5\u4fbfPandas\u80fd\u591f\u6b63\u786e\u8bc6\u522b\u65e5\u671f\u3002<\/p>\n<p><strong>Python\u4e2d\u6709\u54ea\u4e9b\u5e93\u53ef\u4ee5\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff1f<\/strong><br \/>\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u5e38\u7528\u5e93\u5305\u62ecPandas\u3001NumPy\u548cStatsmodels\u3002Pandas\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6570\u636e\u7ed3\u6784\u548c\u51fd\u6570\u6765\u5904\u7406\u65f6\u95f4\u5e8f\u5217\uff0cNumPy\u5219\u53ef\u4ee5\u7528\u4e8e\u6570\u503c\u8ba1\u7b97\uff0c\u800cStatsmodels\u5219\u9002\u5408\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5206\u6790\u548c\u5efa\u6a21\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u7684\u91cd\u91c7\u6837\uff1f<\/strong><br \/>\u91cd\u91c7\u6837\u53ef\u4ee5\u901a\u8fc7Pandas\u7684<code>resample<\/code>\u65b9\u6cd5\u5b9e\u73b0\u3002\u8be5\u65b9\u6cd5\u5141\u8bb8\u5c06\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u8f6c\u6362\u4e3a\u4e0d\u540c\u7684\u9891\u7387\uff0c\u4f8b\u5982\u4ece\u65e5\u9891\u7387\u8f6c\u6362\u4e3a\u6708\u9891\u7387\u3002\u5728\u91cd\u91c7\u6837\u65f6\uff0c\u53ef\u4ee5\u6307\u5b9a\u805a\u5408\u51fd\u6570\uff0c\u5982<code>mean<\/code>\u3001<code>sum<\/code>\u7b49\uff0c\u4ee5\u8ba1\u7b97\u65b0\u7684\u65f6\u95f4\u6bb5\u5185\u7684\u503c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5904\u7406Python\u65f6\u95f4\u5e8f\u5217\u7684\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528pandas\u5e93\u3001\u8fdb\u884c\u6570\u636e\u6e05\u6d17\u3001\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5206\u89e3\u3001\u8fdb\u884c\u65f6\u95f4\u5e8f\u5217\u5efa\u6a21\u3002\u5176\u4e2d\uff0c [&hellip;]","protected":false},"author":3,"featured_media":1172656,"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\/1172647"}],"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=1172647"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1172647\/revisions"}],"predecessor-version":[{"id":1172659,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1172647\/revisions\/1172659"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1172656"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1172647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1172647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1172647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}