{"id":1208,"date":"2024-08-07T08:14:00","date_gmt":"2024-08-07T00:14:00","guid":{"rendered":"https:\/\/www.laoyulaoyu.com\/?p=1208"},"modified":"2024-08-06T13:52:01","modified_gmt":"2024-08-06T05:52:01","slug":"%e6%89%8b%e6%8a%8a%e6%89%8b%e6%95%99%e4%bd%a0-ai-%e9%a1%be%e6%8a%95%ef%bc%9a%e5%9f%ba%e4%ba%8eprophet%e6%97%b6%e9%97%b4%e5%ba%8f%e5%88%97%e6%a8%a1%e5%9e%8b%e9%a2%84%e6%b5%8b%e8%82%a1%e7%a5%a8%e4%bb%b7","status":"publish","type":"post","link":"https:\/\/laoyulaoyu.com\/index.php\/2024\/08\/07\/%e6%89%8b%e6%8a%8a%e6%89%8b%e6%95%99%e4%bd%a0-ai-%e9%a1%be%e6%8a%95%ef%bc%9a%e5%9f%ba%e4%ba%8eprophet%e6%97%b6%e9%97%b4%e5%ba%8f%e5%88%97%e6%a8%a1%e5%9e%8b%e9%a2%84%e6%b5%8b%e8%82%a1%e7%a5%a8%e4%bb%b7\/","title":{"rendered":"\u624b\u628a\u624b\u6559\u4f60 AI \u987e\u6295\uff1a\u57fa\u4e8eProphet\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u9884\u6d4b\u80a1\u7968\u4ef7\u683c\u8d8b\u52bf"},"content":{"rendered":"\n<p>\u4f5c\u8005\uff1a<a href=\"https:\/\/www.laoyulaoyu.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u8001\u4f59\u635e\u9c7c<\/a><\/p>\n\n\n\n<p><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002<\/mark><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/07\/3.webp\" alt=\"\" class=\"wp-image-798\"\/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<pre class=\"wp-block-verse\"><strong>\u5199\u5728\u524d\u9762\u7684\u8bdd\uff1a<\/strong>\u5728\u5f53\u4eca\u590d\u6742\u591a\u53d8\u7684\u91d1\u878d\u5e02\u573a\u4e2d\uff0c\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u4e00\u76f4\u662f\u6295\u8d44\u8005\u548c\u5206\u6790\u5e08\u5173\u6ce8\u7684\u7126\u70b9\u3002\u672c\u6587\u65e8\u5728<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u5229\u7528Prophet\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u5bf9\u80a1\u7968\u4ef7\u683c\u8d8b\u52bf\u8fdb\u884c\u9884\u6d4b<\/mark>\u3002Prophet\u6a21\u578b\u662f\u4e00\u79cd\u57fa\u4e8e\u53ef\u5206\u89e3\u7684\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\uff0c\u7531\u8d8b\u52bf\u9879\u3001\u5b63\u8282\u9879\u548c\u5047\u671f\u56e0\u7d20\u7ec4\u6210\uff0c\u80fd\u591f\u7075\u6d3b\u6355\u6349\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u4e2d\u7684\u5468\u671f\u6027\u3001\u8d8b\u52bf\u6027\u548c\u5f02\u5e38\u503c\u7b49\u7279\u70b9\u3002\u8be5\u6a21\u578b\u5728\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u65f6\u5177\u6709\u8f83\u9ad8\u7684\u7cbe\u5ea6\u548c\u53ef\u89e3\u91ca\u6027\uff0c\u5df2\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u9884\u6d4b\u573a\u666f\u3002<\/pre>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001Prophet\u4ecb\u7ecd<\/strong><\/h2>\n\n\n\n<p>Prophet \u662f\u7531 Facebook \u5f00\u53d1\u7684\u4e00\u4e2a\u5f00\u6e90\u65f6\u95f4\u5e8f\u5217\u9884\u6d4b\u5e93\uff0c\u8bbe\u8ba1\u8003\u8651\u4e86\u4e1a\u52a1\u573a\u666f\u4e2d\u7684\u65f6\u95f4\u5e8f\u5217\u7279\u70b9\uff0c\u5982\u5b63\u8282\u6027\u53d8\u5316\u3001\u5047\u65e5\u6548\u5e94\u548c\u8d8b\u52bf\u53d8\u5316\u3002Prophet \u7279\u522b\u9002\u5408\u5904\u7406\u65e5\u7ea7\u522b\uff08\u6216\u4ee5\u4e0a\u9891\u7387\uff09\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u5e76\u4e14\u5728\u5904\u7406\u7f3a\u5931\u6570\u636e\u548c\u5f02\u5e38\u503c\u65b9\u9762\u8868\u73b0\u51fa\u8272\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u5b89\u88c5<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install prophet<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u5b66\u4e60\u6587\u6863<\/strong><\/h3>\n\n\n\n<p>github\u5730\u5740\uff1a<a href=\"https:\/\/github.com\/facebook\/prophet\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/facebook\/prophet<\/a><\/p>\n\n\n\n<p>\u6587\u6863\u5730\u5740\uff1a<a href=\"http:\/\/facebook.github.io\/prophet\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/facebook.github.io\/prophet<\/a><\/p>\n\n\n\n<p>\u82f1\u6587\u6559\u7a0b\u6587\u6863\uff1a<a href=\"https:\/\/facebook.github.io\/prophet\/docs\/quick_start.html#python-api\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/facebook.github.io\/prophet\/docs\/quick_start.html#python-api<\/a><\/p>\n\n\n\n<p>\u4e2d\u6587\u7ffb\u8bd1\uff1a<a href=\"https:\/\/www.cnblogs.com\/wt11\/collections\/1524\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.cnblogs.com\/wt11\/collections\/1524<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u6a21\u578b\u539f\u7406<\/strong><\/h3>\n\n\n\n<p><strong>y(t)=g(t)+s(s)+h(t)+\u03f5t<\/strong><br><br>g(t)\u8868\u793a\u589e\u957f\u51fd\u6570\uff0c\u7528\u6765\u62df\u5408\u975e\u5468\u671f\u6027\u53d8\u5316\u7684\u3002<br>s(t)\u7528\u6765\u8868\u793a\u5468\u671f\u6027\u53d8\u5316\uff0c\u6bd4\u5982\u8bf4\u6bcf\u5468\uff0c\u6bcf\u5e74\uff0c\u5b63\u8282\u7b49\u3002<br>h(t)\u8868\u793a\u5047\u671f\uff0c\u8282\u65e5\u7b49\u7279\u6b8a\u539f\u56e0\u7b49\u9020\u6210\u7684\u53d8\u5316\u3002<br>\u03f5t\u4e3a\u566a\u58f0\u9879\uff0c\u7528\u4ed6\u6765\u8868\u793a\u968f\u673a\u65e0\u6cd5\u9884\u6d4b\u7684\u6ce2\u52a8\uff0c\u6211\u4eec\u5047\u8bbe\u03f5t\u662f\u9ad8\u65af\u7684\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Prophet\u7684\u9ed8\u8ba4\u53c2\u6570<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>def <strong>init<\/strong>(\nself,\ngrowth='linear',\nchangepoints=None,\nn_changepoints=25,\nchangepoint_range=0.8,\nyearly_seasonality='auto',\nweekly_seasonality='auto',\ndaily_seasonality='auto',\nholidays=None,\nseasonality_mode='additive',\nseasonality_prior_scale=10.0,\nholidays_prior_scale=10.0,\nchangepoint_prior_scale=0.05,\nmcmc_samples=0,\ninterval_width=0.80,\nuncertainty_samples=1000,\n)\n<\/code><\/pre>\n\n\n\n<p>1\u3001growth\uff1a\u589e\u957f\u8d8b\u52bf\u6a21\u578b\uff0c\u5206\u4e3a\u201clinear\u201d\u4e0e\u201clogistic\u201d\uff0c\u5206\u522b\u4ee3\u8868\u7ebf\u6027\u4e0e\u975e\u7ebf\u6027\u7684\u589e\u957f\uff0c\u9ed8\u8ba4\u503c\u4e3alinear\u3002<\/p>\n\n\n\n<p>2\u3001Capacity\uff1a\u5728\u589e\u91cf\u51fd\u6570\u662f\u903b\u8f91\u56de\u5f52\u51fd\u6570\u7684\u65f6\u5019\uff0c\u9700\u8981\u8bbe\u7f6e\u7684\u5bb9\u91cf\u503c,\u8868\u793a\u975e\u7ebf\u6027\u589e\u957f\u8d8b\u52bf\u4e2d\u9650\u5b9a\u7684\u6700\u5927\u503c\uff0c\u9884\u6d4b\u503c\u5c06\u5728\u8be5\u70b9\u8fbe\u5230\u9971\u548c.<\/p>\n\n\n\n<p>3\u3001Change Points\uff1a\u53ef\u4ee5\u901a\u8fc7 n_changepoints \u548c changepoint_range \u6765\u8fdb\u884c\u7b49\u8ddd\u7684\u53d8\u70b9\u8bbe\u7f6e\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4eba\u5de5\u8bbe\u7f6e\u7684\u65b9\u5f0f\u6765\u6307\u5b9a\u65f6\u95f4\u5e8f\u5217\u7684\u53d8\u70b9\uff0c\u9ed8\u8ba4\u503c\uff1a\u201cNone\u201d.<\/p>\n\n\n\n<p>4\u3001n_changepoints\uff1a\u7528\u6237\u6307\u5b9a\u6f5c\u5728\u7684\u201dchangepoint\u201d\u7684\u4e2a\u6570\uff0c\u9ed8\u8ba4\u503c\uff1a25\u3002<\/p>\n\n\n\n<p>5\u3001changepoint_prior_scale\uff1a\u589e\u957f\u8d8b\u52bf\u6a21\u578b\u7684\u7075\u6d3b\u5ea6\u3002\u8c03\u8282\u201dchangepoint\u201d\u9009\u62e9\u7684\u7075\u6d3b\u5ea6\uff0c\u503c\u8d8a\u5927\uff0c\u9009\u62e9\u7684\u201dchangepoint\u201d\u8d8a\u591a\uff0c\u4ece\u800c\u4f7f\u6a21\u578b\u5bf9\u5386\u53f2\u6570\u636e\u7684\u62df\u5408\u7a0b\u5ea6\u53d8\u5f3a\uff0c\u7136\u800c\u4e5f\u589e\u52a0\u4e86\u8fc7\u62df\u5408\u7684\u98ce\u9669\u3002\u9ed8\u8ba4\u503c\uff1a0.05\u3002<\/p>\n\n\n\n<p>6\u3001seasonality_prior_scale\uff08seasonality\u6a21\u578b\u4e2d\u7684\uff09\uff1a\u8c03\u8282\u5b63\u8282\u6027\u7ec4\u4ef6\u7684\u5f3a\u5ea6\u3002\u503c\u8d8a\u5927\uff0c\u6a21\u578b\u5c06\u9002\u5e94\u66f4\u5f3a\u7684\u5b63\u8282\u6027\u6ce2\u52a8\uff0c\u503c\u8d8a\u5c0f\uff0c\u8d8a\u6291\u5236\u5b63\u8282\u6027\u6ce2\u52a8\uff0c\u9ed8\u8ba4\u503c\uff1a10.0.<\/p>\n\n\n\n<p>7\u3001holidays_prior_scale\uff08holidays\u6a21\u578b\u4e2d\u7684\uff09\uff1a\u8c03\u8282\u8282\u5047\u65e5\u6a21\u578b\u7ec4\u4ef6\u7684\u5f3a\u5ea6\u3002\u503c\u8d8a\u5927\uff0c\u8be5\u8282\u5047\u65e5\u5bf9\u6a21\u578b\u7684\u5f71\u54cd\u8d8a\u5927\uff0c\u503c\u8d8a\u5c0f\uff0c\u8282\u5047\u65e5\u7684\u5f71\u54cd\u8d8a\u5c0f\uff0c\u9ed8\u8ba4\u503c\uff1a10.0\u3002<\/p>\n\n\n\n<p>8\u3001freq\uff1a\u6570\u636e\u4e2d\u65f6\u95f4\u7684\u7edf\u8ba1\u5355\u4f4d\uff08\u9891\u7387\uff09\uff0c\u9ed8\u8ba4\u4e3a\u201dD\u201d\uff0c\u6309\u5929\u7edf\u8ba1.<\/p>\n\n\n\n<p>9\u3001periods\uff1a\u9700\u8981\u9884\u6d4b\u7684\u672a\u6765\u65f6\u95f4\u7684\u4e2a\u6570\u3002\u4f8b\u5982\u6309\u5929\u7edf\u8ba1\u7684\u6570\u636e\uff0c\u60f3\u8981\u9884\u6d4b\u672a\u6765\u4e00\u5e74\u65f6\u95f4\u5185\u7684\u60c5\u51b5\uff0c\u5219\u9700\u586b\u5199365\u3002<\/p>\n\n\n\n<p>10\u3001mcmc_samples\uff1amcmc\u91c7\u6837\uff0c\u7528\u4e8e\u83b7\u5f97\u9884\u6d4b\u672a\u6765\u7684\u4e0d\u786e\u5b9a\u6027\u3002\u82e5\u5927\u4e8e0\uff0c\u5c06\u505amcmc\u6837\u672c\u7684\u5168\u8d1d\u53f6\u65af\u63a8\u7406\uff0c\u5982\u679c\u4e3a0\uff0c\u5c06\u505a\u6700\u5927\u540e\u9a8c\u4f30\u8ba1\uff0c\u9ed8\u8ba4\u503c\uff1a0\u3002<\/p>\n\n\n\n<p>11\u3001interval_width\uff1a\u8861\u91cf\u672a\u6765\u65f6\u95f4\u5185\u8d8b\u52bf\u6539\u53d8\u7684\u7a0b\u5ea6\u3002\u8868\u793a\u9884\u6d4b\u672a\u6765\u65f6\u4f7f\u7528\u7684\u8d8b\u52bf\u95f4\u9694\u51fa\u73b0\u7684\u9891\u7387\u548c\u5e45\u5ea6\u4e0e\u5386\u53f2\u6570\u636e\u7684\u76f8\u4f3c\u5ea6\uff0c\u503c\u8d8a\u5927\u8d8a\u76f8\u4f3c\uff0c\u9ed8\u8ba4\u503c\uff1a0.80\u3002\u5f53mcmc_samples = 0\u65f6\uff0c\u8be5\u53c2\u6570\u4ec5\u7528\u4e8e\u589e\u957f\u8d8b\u52bf\u6a21\u578b\u7684\u6539\u53d8\u7a0b\u5ea6\uff0c\u5f53mcmc_samples &gt; 0\u65f6\uff0c\u8be5\u53c2\u6570\u4e5f\u5305\u62ec\u4e86\u5b63\u8282\u6027\u8d8b\u52bf\u6539\u53d8\u7684\u7a0b\u5ea6\u3002<\/p>\n\n\n\n<p>12\u3001uncertainty_samples\uff1a\u7528\u4e8e\u4f30\u8ba1\u672a\u6765\u65f6\u95f4\u7684\u589e\u957f\u8d8b\u52bf\u95f4\u9694\u7684\u4eff\u771f\u7ed8\u5236\u6570\uff0c\u9ed8\u8ba4\u503c\uff1a1000\u3002<\/p>\n\n\n\n<p>13\u3001yearly_seasonality: \u6570\u636e\u662f\u5426\u6709\u5e74\u5b63\u8282\u6027\uff0c\u9ed8\u8ba4\u201c\u81ea\u52a8\u68c0\u6d4b\u201d\u3002<\/p>\n\n\n\n<p>14\u3001weekly_seasonality: \u6570\u636e\u662f\u5426\u6709\u5468\u5b63\u8282\u6027\uff0c\u9ed8\u8ba4\u201c\u81ea\u52a8\u68c0\u6d4b\u201d\u3002<\/p>\n\n\n\n<p>15\u3001daily_seasonality: \u6570\u636e\u662f\u5426\u6709\u5929\u5b63\u8282\u6027\uff0c\u9ed8\u8ba4\u201c\u81ea\u52a8\u68c0\u6d4b\u201d\u3002<\/p>\n\n\n\n<p>16\u3001seasonality_mode: \u5b63\u8282\u6027\u6548\u5e94\u6a21\u5f0f\uff0c\u9ed8\u8ba4\u52a0\u6cd5\u6a21\u5f0f\u201cadditive\u201d\uff0c\u53ef\u9009\u201cmultiplicative\u201d\u4e58\u6cd5\u6a21\u5f0f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001\u5b9e\u9a8c\u80cc\u666f<\/strong><\/h2>\n\n\n\n<p><br>\u5728\u5f53\u4eca\u590d\u6742\u591a\u53d8\u7684\u91d1\u878d\u5e02\u573a\u4e2d\uff0c\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u4e00\u76f4\u662f\u6295\u8d44\u8005\u548c\u5206\u6790\u5e08\u5173\u6ce8\u7684\u7126\u70b9\u3002\u51c6\u786e\u9884\u6d4b\u80a1\u7968\u4ef7\u683c\u8d8b\u52bf\u5bf9\u4e8e\u6295\u8d44\u8005\u5236\u5b9a\u6295\u8d44\u7b56\u7565\u3001\u89c4\u907f\u98ce\u9669\u548c\u5b9e\u73b0\u8d44\u672c\u589e\u503c\u5177\u6709\u91cd\u8981\u610f\u4e49\u3002\u7136\u800c\uff0c\u80a1\u7968\u4ef7\u683c\u53d7\u5230\u591a\u79cd\u56e0\u7d20\u7684\u5f71\u54cd\uff0c\u5305\u62ec\u5b8f\u89c2\u7ecf\u6d4e\u73af\u5883\u3001\u516c\u53f8\u8d22\u52a1\u72b6\u51b5\u3001\u5e02\u573a\u60c5\u7eea\u7b49\uff0c\u8fd9\u4e9b\u56e0\u7d20\u4f7f\u5f97\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u53d8\u5f97\u590d\u6742\u4e14\u5145\u6ee1\u6311\u6218\u3002<\/p>\n\n\n\n<p>\u963f\u91cc\u5df4\u5df4\uff08BABA\uff09\u4f5c\u4e3a\u5168\u7403\u77e5\u540d\u7684\u7535\u5b50\u5546\u52a1\u5e73\u53f0\uff0c\u5176\u80a1\u7968\u4ef7\u683c\u4e00\u76f4\u53d7\u5230\u5e7f\u6cdb\u5173\u6ce8\u3002\u6295\u8d44\u8005\u548c\u5206\u6790\u5e08\u5bf9\u963f\u91cc\u5df4\u5df4\u80a1\u7968\u4ef7\u683c\u8d8b\u52bf\u7684\u9884\u6d4b\u9700\u6c42\u65e5\u76ca\u589e\u957f\uff0c\u5e0c\u671b\u901a\u8fc7\u9884\u6d4b\u7ed3\u679c\u6765\u6307\u5bfc\u6295\u8d44\u51b3\u7b56\u3002\u7136\u800c\uff0c\u7531\u4e8e\u80a1\u7968\u4ef7\u683c\u53d7\u5230\u591a\u79cd\u56e0\u7d20\u7684\u5f71\u54cd\uff0c\u4f20\u7edf\u7684\u7ebf\u6027\u9884\u6d4b\u6a21\u578b\u5f80\u5f80\u96be\u4ee5\u51c6\u786e\u6355\u6349\u80a1\u7968\u4ef7\u683c\u7684\u52a8\u6001\u53d8\u5316\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c\u672c\u6587\u65e8\u5728\u5229\u7528Prophet\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u5bf9\u963f\u91cc\u5df4\u5df4\u80a1\u7968\u4ef7\u683c\u8d8b\u52bf\u8fdb\u884c\u9884\u6d4b\u3002Prophet\u6a21\u578b\u662f\u4e00\u79cd\u57fa\u4e8e\u53ef\u5206\u89e3\u7684\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\uff0c\u7531\u8d8b\u52bf\u9879\u3001\u5b63\u8282\u9879\u548c\u5047\u671f\u56e0\u7d20\u7ec4\u6210\uff0c\u80fd\u591f\u7075\u6d3b\u6355\u6349\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u4e2d\u7684\u5468\u671f\u6027\u3001\u8d8b\u52bf\u6027\u548c\u5f02\u5e38\u503c\u7b49\u7279\u70b9\u3002\u8be5\u6a21\u578b\u5728\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u65f6\u5177\u6709\u8f83\u9ad8\u7684\u7cbe\u5ea6\u548c\u53ef\u89e3\u91ca\u6027\uff0c\u5df2\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u9884\u6d4b\u573a\u666f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u3001\u6570\u636e\u96c6\u4ecb\u7ecd<\/strong><\/h2>\n\n\n\n<p>\u672c\u6587\u6570\u636e\u96c6\u6765\u6e90\u4e8eKaggle\uff0c\u6570\u636e\u96c6\u5305\u542b\u963f\u91cc\u5df4\u5df4\u96c6\u56e2\u63a7\u80a1\u516c\u53f8(BABA)\u4ece[2020\u5e741\u67081\u65e5]\u5230[2024\u5e745\u67081\u65e5]\u7684\u5386\u53f2\u80a1\u4ef7\u6570\u636e\u3002\u6570\u636e\u96c6\u5305\u62ec\u6bcf\u65e5\u5f00\u76d8\u4ef7\u3001\u6700\u9ad8\u4ef7\u3001\u6700\u4f4e\u4ef7\u548c\u6536\u76d8\u4ef7\uff0c\u4ee5\u53ca\u8c03\u6574\u540e\u7684\u6536\u76d8\u4ef7\u548c\u6210\u4ea4\u91cf\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/copy.png\" alt=\"\" class=\"wp-image-1212\" style=\"width:543px;height:auto\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u56db\u3001\u6280\u672f\u5de5\u5177<\/strong><\/h2>\n\n\n\n<p>Python\u7248\u672c:3.10<\/p>\n\n\n\n<p>\u4ee3\u7801\u7f16\u8f91\u5668\uff1ajupyter notebook+VScode<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e94\u3001\u5b9e\u9a8c\u8fc7\u7a0b<\/strong><\/h2>\n\n\n\n<p>\u9996\u5148\u5bfc\u5165\u7b2c\u4e09\u65b9\u5e93\u5e76\u52a0\u8f7d\u6570\u636e\u96c6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\nimport pandas as pd\nfrom prophet import Prophet\nimport warnings\nwarnings.filterwarnings(\"ignore\")\n\ndf = pd.read_csv('BABA.csv')\ndf.head()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/copy-1.png\" alt=\"\" class=\"wp-image-1213\"\/><\/figure>\n\n\n\n<p><strong>\u7b5b\u9009\u51fa\u5efa\u6a21\u9700\u8981\u7684\u7279\u5b9a\u5217\u5e76\u91cd\u547d\u540d<\/strong><\/p>\n\n\n\n<p>\u6a21\u578b\u9700\u8981\u4e24\u5217\uff1a1.ds \u65f6\u95f4\u5217 2.y \u6570\u636e\u5217<\/p>\n\n\n\n<p><strong>\u5bf9\u4e8eds\u7684\u8981\u6c42\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5bf9\u4e8e\u53ea\u6709\u65e5\u671f\u6ca1\u6709\u65f6\u95f4\u7684\u6570\u636e\uff0cds\u5217\u5e94\u8be5\u662fYYYY-MM-DD\u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u6216\u8005pandas\u7684datetime\u7c7b\u578b\u6570\u636e\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u6570\u636e\u5305\u542b\u65f6\u95f4\u6233\uff0cds\u5217\u5e94\u8be5\u662fYYYY-MM-DD HH:MM:SS\u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u6216\u8005pandas\u7684datetime\u7c7b\u578b\u6570\u636e\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\u7b5b\u9009\u7279\u5b9a\u5217<br>new_df = df&#91;&#91;'Date','Close']]<br>\u4e3aProphet Model \u65f6\u95f4\u5e8f\u5217:ds, price:y\u91cd\u547d\u540d\u5217<br>new_df.columns = &#91;'ds','y']<br>new_df<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/copy-2.png\" alt=\"\" class=\"wp-image-1214\"\/><\/figure>\n\n\n\n<p><strong>\u521d\u59cb\u5316\u6a21\u578b\u5e76\u8bad\u7ec3\uff0c\u6700\u540e\u4f7f\u7528\u6a21\u578b\u9884\u6d4b\u672a\u6765360\u5929\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<p>\u4e3b\u8981\u7684\u7406\u89e3\u5728make_future_dataframe\u662f\u6839\u636efreq\u4ee5\u53caperiods\uff0c\u521b\u5efa\u672a\u6765\u65e5\u671f\u7684\u6570\u636e\u5e27\uff0cfreq\u53ef\u4ee5\u4e3a&#8217;30s&#8217;, &#8216;T&#8217;\uff0c\u9ed8\u8ba4\u4e3a&#8217;D&#8217;,\u5206\u522b\u4e3a30s\uff0c\u6bcf\u5206\u949f\uff0c\u6bcf\u5929\uff0cperiods\u7684\u610f\u601d\u5c31\u662f\u591a\u5c11\u4e2afreq\u7684\u65f6\u95f4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u521d\u59cb\u5316\u6a21\u578b\nmodel = Prophet()\n# \u8bad\u7ec3\u6a21\u578b\nmodel.fit(new_df)\nfuture = model.make_future_dataframe(periods=360,freq='D') # \u9884\u6d4b\u672a\u6765360\u5929\n# \u6a21\u578b\u9884\u6d4b\nguess = model.predict(future)\nguess<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/copy-3-1024x479.png\" alt=\"\" class=\"wp-image-1215\" style=\"width:603px;height:auto\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u6700\u540e\u5c06\u6a21\u578b\u9884\u6d4b\u7ed3\u679c\u53ef\u89c6\u5316<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>model.plot(guess)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/copy-4.png\" alt=\"\" class=\"wp-image-1216\"\/><\/figure>\n\n\n\n<p>\u4e0a\u56fe\u4e2d<strong>\u9ed1\u8272\u7684\u70b9<\/strong>\u8868\u793a\u539f\u59cb\u7684\u65f6\u95f4\u5e8f\u5217\u79bb\u6563\u70b9\uff1b<strong>\u6df1\u84dd\u8272\u7684\u7ebf<\/strong>\u8868\u793a\u4f7f\u7528\u65f6\u95f4\u5e8f\u5217\u6765\u62df\u5408\u6240\u5f97\u5230\u7684\u53d6\u503c\uff1b<strong>\u6d45\u84dd\u8272\u7684\u533a\u57df<\/strong>\u8868\u793a\u65f6\u95f4\u5e8f\u5217\u7684\u4e00\u4e2a\u7f6e\u4fe1\u533a\u95f4\uff0c\u4e5f\u5c31\u662f\u6240\u8c13\u7684\u5408\u7406\u7684\u4e0a\u754c\u548c\u4e0b\u754c\u3002\u539f\u59cb\u6570\u636e\u53ea\u52302024-04-30\u5c31\u7ed3\u675f\u4e86\uff0c\u540e\u9762\u7684\u90fd\u662f\u6a21\u578b\u9884\u6d4b\u7684\u6570\u636e\u8d8b\u52bf\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u516d\u3001\u603b\u7ed3<\/strong><\/h2>\n\n\n\n<p>\u5229\u7528\u963f\u91cc\u5df4\u5df4\u96c6\u56e2\u63a7\u80a1\u516c\u53f8\uff08BABA\uff09\u4ece2020\u5e741\u67081\u65e5\u81f32024\u5e745\u67081\u65e5\u7684\u5386\u53f2\u80a1\u4ef7\u6570\u636e\uff0c\u901a\u8fc7Prophet\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u5bf9\u5176\u672a\u6765360\u5929\u7684\u80a1\u7968\u4ef7\u683c\u8d8b\u52bf\u8fdb\u884c\u4e86\u9884\u6d4b\u3002\u672c\u6b21\u56de\u6eaf\u7684\u76ee\u7684\u662f\u8bc4\u4f30Prophet\u6a21\u578b\u5728\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u65b9\u9762\u7684\u5e94\u7528\u6548\u679c\uff0c\u5e76\u4e3a\u6295\u8d44\u8005\u63d0\u4f9b\u53c2\u8003\u4fe1\u606f\u3002\u540c\u65f6\u8bc1\u660eProphet\u6a21\u578b\u5728\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u65b9\u9762\u7684\u5e94\u7528\u6f5c\u529b\u3002\u672a\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u8fdb\u4e00\u6b65\u4f18\u5316\u6a21\u578b\u7ed3\u6784\u3001\u5f15\u5165\u66f4\u591a\u76f8\u5173\u56e0\u7d20\uff0c\u4ee5\u63d0\u9ad8\u9884\u6d4b\u51c6\u786e\u6027\u548c\u53ef\u9760\u6027\u3002\u540c\u65f6\uff0c\u6211\u4eec\u4e5f\u5c06\u5173\u6ce8\u5176\u4ed6\u5148\u8fdb\u7684\u9884\u6d4b\u65b9\u6cd5\u548c\u6280\u672f\uff0c\u4ee5\u63a2\u7d22\u66f4\u4f18\u79c0\u7684\u80a1\u7968\u4ef7\u683c\u9884\u6d4b\u65b9\u6848\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u6e90\u4ee3\u7801<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np \nimport pandas as pd\nfrom prophet import Prophet\nimport warnings\nwarnings.filterwarnings(\"ignore\")\n \ndf = pd.read_csv('BABA.csv')\ndf.head()\n \n# \u7b5b\u9009\u7279\u5b9a\u5217\nnew_df = df&#91;&#91;'Date','Close']]\n# \u4e3aProphet Model \u65f6\u95f4\u5e8f\u5217:ds, price:y\u91cd\u547d\u540d\u5217\nnew_df.columns = &#91;'ds','y']\nnew_df\n \n# \u521d\u59cb\u5316\u6a21\u578b\nmodel = Prophet()\n# \u8bad\u7ec3\u6a21\u578b\nmodel.fit(new_df)\nfuture = model.make_future_dataframe(periods=360,freq='D') # \u9884\u6d4b\u672a\u6765360\u5929\n# \u6a21\u578b\u9884\u6d4b\nguess = model.predict(future)\nguess\nmodel.plot(guess)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u672c\u6587\u5185\u5bb9\u4ec5\u4ec5\u662f\u6280\u672f\u63a2\u8ba8\u548c\u5b66\u4e60\uff0c\u5e76\u4e0d\u6784\u6210\u4efb\u4f55\u6295\u8d44\u5efa\u8bae\u3002<br>\u8f6c\u53d1\u8bf7\u6ce8\u660e\u539f\u4f5c\u8005\u548c\u51fa\u5904\u3002<\/mark><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u8001\u4f59\u635e\u9c7c \u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/laoyulaoyu.com\/index.php\/2024\/08\/07\/%e6%89%8b%e6%8a%8a%e6%89%8b%e6%95%99%e4%bd%a0-ai-%e9%a1%be%e6%8a%95%ef%bc%9a%e5%9f%ba%e4%ba%8eprophet%e6%97%b6%e9%97%b4%e5%ba%8f%e5%88%97%e6%a8%a1%e5%9e%8b%e9%a2%84%e6%b5%8b%e8%82%a1%e7%a5%a8%e4%bb%b7\/\">Continue reading<span class=\"screen-reader-text\">\u624b\u628a\u624b\u6559\u4f60 AI \u987e\u6295\uff1a\u57fa\u4e8eProphet\u65f6\u95f4\u5e8f\u5217\u6a21\u578b\u9884\u6d4b\u80a1\u7968\u4ef7\u683c\u8d8b\u52bf<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,6],"class_list":["post-1208","post","type-post","status-publish","format-standard","hentry","category-aiinvest","tag-ai","tag-6","entry"],"_links":{"self":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/comments?post=1208"}],"version-history":[{"count":2,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1208\/revisions"}],"predecessor-version":[{"id":1297,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1208\/revisions\/1297"}],"wp:attachment":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}