{"id":117,"date":"2021-11-17T16:28:28","date_gmt":"2021-11-17T07:28:28","guid":{"rendered":"https:\/\/www.avelio.co.jp\/math\/wordpress\/?p=117"},"modified":"2021-11-17T22:23:11","modified_gmt":"2021-11-17T13:23:11","slug":"prophet%e3%81%a7%e6%a0%aa%e4%be%a1%e4%ba%88%e6%b8%ac%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.avelio.co.jp\/math\/wordpress\/?p=117","title":{"rendered":"Prophet\u3067\u682a\u4fa1\u4e88\u6e2c\u3057\u3066\u307f\u308b"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Prophet\u306e\u6982\u8981<\/h2>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/facebook.github.io\/prophet\" target=\"_blank\">Prophet<\/a>\u306fFacebook\u793e\u304c\u958b\u767a\u3057\u305f\u6642\u7cfb\u5217\u89e3\u6790\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059.<\/p>\n\n\n\n<p>Prophet\u3067\u306f, \u6642\u7cfb\u5217\u30c7\u30fc\u30bf \\(y(t)\\) \u30923\u3064\u306e\u9805\u306e\u548c\u3068\u3057\u3066\u30e2\u30c7\u30ea\u30f3\u30b0\u3057\u307e\u3059.<\/p>\n\n\n\n<p>$$  y(t) = g(t) + s(t) + h(t) + \\varepsilon_t$$<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\\(g(t)\\) : \u6210\u9577\u95a2\u6570(growth)\u2192\u6642\u9593\u3068\u5171\u306b\u5358\u8abf\u306b\u5909\u52d5\u3059\u308b\u9805<\/li><li>\\(s(t)\\) : \u5468\u671f\u95a2\u6570(seasonality)\u2192\u5468\u671f\u7684\u306b\u7e70\u308a\u8fd4\u3055\u308c\u308b\u5909\u52d5<\/li><li>\\(h(t)\\) :  \u795d\u65e5\u52b9\u679c(holiday)\u2192\u30a4\u30ec\u30ae\u30e5\u30e9\u30fc\u306a\u30ab\u30ec\u30f3\u30c0\u30fc\u4e0a\u306e\u65e5\u7a0b\u304c\u4e0e\u3048\u308b\u5f71\u97ff<\/li><li>\\(\\varepsilon_t\\) : \u8aa4\u5dee\u9805 <\/li><\/ul>\n\n\n\n<p>\u4e0a\u8a18\u306e\u3088\u3046\u306a\u30e2\u30c7\u30eb\u306f<strong>\u4e00\u822c\u5316\u52a0\u6cd5\u30e2\u30c7\u30eb<\/strong>\u3068\u547c\u3070\u308c, \u3053\u306e\u30e2\u30c7\u30eb\u3067\u306f\u5e73\u6ed1\u5316(\u30b9\u30e0\u30fc\u30b8\u30f3\u30b0)\u3068\u547c\u3070\u308c\u308b\u95a2\u6570\u578b\u306b\u4f9d\u5b58\u3057\u306a\u3044\u81ea\u7531\u306a\u56de\u5e30\u3092\u884c\u3044\u307e\u3059.<\/p>\n\n\n\n<p>\u5e73\u6ed1\u5316\u3092\u7528\u3044\u3066\u4e88\u6e2c\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u306f, \u81ea\u5df1\u56de\u5e30\u578b\u30e2\u30c7\u30eb(ARIMA\u7b49)\u306a\u3069\u306e\u4f1d\u7d71\u7684\u306a\u6642\u7cfb\u5217\u30e2\u30c7\u30eb\u3068\u306f\u8003\u3048\u65b9\u304c\u6839\u672c\u7684\u306b\u7570\u306a\u308a\u307e\u3059.<\/p>\n\n\n\n<p>\u53e4\u5178\u7684\u306a\u6642\u7cfb\u5217\u30e2\u30c7\u30eb\u3067\u306f, \u904e\u53bb\u306e\u30c7\u30fc\u30bf\u3068\u672a\u6765\u306e\u30c7\u30fc\u30bf\u306e\u95a2\u4fc2\u6027\u3092\u30e2\u30c7\u30eb\u5316\u3057\u307e\u3059. \u305d\u308c\u306b\u5bfe\u3057\u3066\u5e73\u6ed1\u5316\u304c\u3059\u308b\u306e\u306f, \u30c7\u30fc\u30bf\u306e\u30b0\u30e9\u30d5\u306b\u3044\u3044\u611f\u3058\u306a\u66f2\u7dda\u3092\u5f15\u3044\u3066\u3044\u308b\u3060\u3051(\u8981\u306f\u56de\u5e30\u5206\u6790\uff01)\u306a\u306e\u3067, \u904e\u53bb\u306e\u30c7\u30fc\u30bf\u3068\u672a\u6765\u306e\u30c7\u30fc\u30bf\u306e\u95a2\u4fc2\u6027\u306a\u3069\u306e\u60c5\u5831\u306f\u30b4\u30df\u7bb1\u306b\u30dd\u30a4\u3057\u3066\u3044\u307e\u3059. <\/p>\n\n\n\n<p>\u305d\u306e\u4ee3\u308f\u308a\u306b, Prophet\u30e2\u30c7\u30eb\u306b\u306f\u69d8\u3005\u306a\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059. \u4f8b\u3048\u3070, Prophet\u30e2\u30c7\u30eb\u3067\u306f\u6b20\u640d\u5024\u3092\u88dc\u5b8c\u3057\u306a\u304f\u3066\u3082\u5b66\u7fd2\u304c\u3067\u304d\u308b\u70b9\u3067\u3059.<\/p>\n\n\n\n<p>\u4f1d\u7d71\u7684\u306a\u6642\u7cfb\u5217\u30e2\u30c7\u30eb\u3067\u306f, \u5404\u6642\u523b\u306e\u30c7\u30fc\u30bf\u306e\u95a2\u4fc2\u6027\u3092\u8a18\u8ff0\u3057\u3066\u3044\u307e\u3059. \u4f8b\u3068\u3057\u3066 AR(1)\u30e2\u30c7\u30eb\u3092\u8003\u3048\u3066\u307f\u307e\u3059.<\/p>\n\n\n\n<p>\u4f8b) AR(1)\u30e2\u30c7\u30eb\u3000$$X_t = c + \\varphi X_{t-1} + \\varepsilon_t$$<\/p>\n\n\n\n<p>\u4e0a\u5f0f\u3092\u898b\u3066\u308f\u304b\u308b\u3088\u3046\u306b, AR(1)\u30e2\u30c7\u30eb\u3067\u306f1\u6642\u70b9\u524d\u306e\u51fa\u529b\u304c\u6b21\u70b9\u306e\u30e2\u30c7\u30eb\u3092\u4e0e\u3048\u307e\u3059. \u3053\u308c\u306f, \u3042\u308b1\u6642\u70b9\u306e\u30c7\u30fc\u30bf\u304c\u6b20\u640d\u3059\u308b\u3068, \u305d\u308c\u3088\u308a\u5148\u306e\u6642\u70b9\u306e\u8a08\u7b97\u304c\u3067\u304d\u306a\u304f\u306a\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u3066\u3044\u307e\u3059.\u3057\u305f\u304c\u3063\u3066, \u81ea\u5df1\u56de\u5e30\u30e2\u30c7\u30eb\u7b49\u306e\u4f1d\u7d71\u7684\u306a\u6642\u7cfb\u5217\u30e2\u30c7\u30eb\u3067\u306f, \u30c7\u30fc\u30bf\u306e\u524d\u51e6\u7406\u3068\u3057\u3066\u6b20\u640d\u5024\u3092\u4f55\u304b\u3057\u3089\u306e\u5024\u3067\u88dc\u5b8c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067\u3059.<\/p>\n\n\n\n<p>\u4e00\u65b9\u3067, Prophet\u30e2\u30c7\u30eb\u306f\u901a\u5e38\u306e\u56de\u5e30\u30e2\u30c7\u30eb\u3068\u540c\u69d8\u306b, \u89b3\u6e2c\u3055\u308c\u305f\u30c7\u30fc\u30bf\u306b\u3044\u3044\u611f\u3058\u306b\u66f2\u7dda\u3092\u5f15\u304f\u3068\u3044\u3046\u624b\u6cd5\u3067\u3059\u304b\u3089, \u3042\u308b\u6642\u70b9\u306e\u30c7\u30fc\u30bf\u304c\u6b20\u3051\u3066\u3044\u3088\u3046\u304c\u304a\u69cb\u3044\u306a\u3057\u3067\u3059. ( \u4f8b\u3048\u3070, \u5e74\u9f62\u3068\u4f53\u91cd\u306e\u95a2\u4fc2\u3092\u56de\u5e30\u5206\u6790\u3059\u308b\u5834\u5408\u306b,  22\u6b73\u306e\u3068\u304d\u306e\u8eab\u9577\u3092\u6e2c\u308a\u5fd8\u308c\u3066\u3044\u305f\u3068\u3057\u3066\u3082\u56de\u5e30\u5206\u6790\u3067\u304d\u307e\u3059\u3088\u306d\uff1f\u305d\u308c\u3068\u540c\u3058\u3067\u3059.)<\/p>\n\n\n\n<p>\u3053\u306e\u4ed6\u306b\u3082, \u305f\u304f\u3055\u3093\u306e\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u304c, \u3068\u306b\u304b\u304f\u300c\u697d\u306b\u6642\u7cfb\u5217\u5206\u6790\u3067\u304d\u308b\u300d\u304c\u30e2\u30c3\u30c8\u30fc\u306e\u30e2\u30c7\u30eb\u306a\u3088\u3046\u3067\u3059.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install Prophet\n# anaconda\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u65b9\u306f\nconda install -c conda-forge fbprophet<\/code><\/pre>\n\n\n\n<p> \u203b \u7b46\u8005\u306fProphet\u4f7f\u7528\u4e2d\u306b <code>KeyError: 'metric_file'<\/code> \u3068\u3044\u3046\u30a8\u30e9\u30fc\u3092\u5410\u304b\u308c\u307e\u3057\u305f. pystan\u306eversion\u304c\u53e4\u3044\u3053\u3068\u304c\u539f\u56e0\u307d\u304b\u3063\u305f\u306e\u3067, \u4e0b\u8a18\u3092\u53c2\u8003\u306b pystan\u306eversion\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u307e\u3057\u305f. (\u3061\u306a\u307f\u306b, Prophet\u306e\u51e6\u7406\u81ea\u4f53\u306fpystan\u3067\u66f8\u304b\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059)<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/facebook\/prophet\/issues\/1670\">https:\/\/github.com\/facebook\/prophet\/issues\/1670<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30dd\u30fc\u30c8<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom fbprophet import Prophet\nfrom pandas_datareader.data import DataReader\nimport datetime\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30c7\u30fc\u30bf\u53d6\u5f97\uff06\u6574\u5f62<\/h2>\n\n\n\n<p>pandas\u306eDataReader\u3092\u4f7f\u7528\u3057\u3066, \u300cYahoo!\u30d5\u30a1\u30a4\u30ca\u30f3\u30b9\u300d\u304b\u3089\u30c8\u30e8\u30bf\u306e\u682a\u4fa1\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u307e\u3059.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>start = datetime.date(2018,1,1)\nend = datetime.date(2021,1,1)\ndata_train = DataReader('TM', 'yahoo', start, end)<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a2018\u5e741\u6708\u304b\u30892020\u5e7412\u6708\u306e\u30c8\u30e8\u30bf\u306e\u682a\u4fa1\u30c7\u30fc\u30bf\u306b\u306a\u3063\u3066\u3044\u307e\u3059.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th><\/th><th>  High  <\/th><th>  Low  <\/th><th>  Open  <\/th><th>  Close <\/th><th>  Volume  <\/th><th>  Adj Close <\/th><\/tr><tr><th>Date<\/th><th><\/th><th><\/th><th><\/th><th><\/th><th><\/th><th><\/th><\/tr><\/thead><tbody><tr><th>2018-01-02<\/th><td>128.429993<\/td><td>127.169998<\/td><td>127.430000<\/td><td>128.369995<\/td><td>83500<\/td><td>128.369995<\/td><\/tr><tr><th>2018-01-03<\/th><td>130.240005<\/td><td>128.559998<\/td><td>128.679993<\/td><td>130.130005<\/td><td>162200<\/td><td>130.130005<\/td><\/tr><tr><th>2018-01-04<\/th><td>132.160004<\/td><td>131.300003<\/td><td>131.309998<\/td><td>132.160004<\/td><td>161800<\/td><td>132.160004<\/td><\/tr><tr><th>2018-01-05<\/th><td>133.869995<\/td><td>133.080002<\/td><td>133.110001<\/td><td>133.860001<\/td><td>135300<\/td><td>133.860001<\/td><\/tr><tr><th>2018-01-08<\/th><td>134.789993<\/td><td>133.619995<\/td><td>133.979996<\/td><td>134.770004<\/td><td>131200<\/td><td>134.770004<\/td><\/tr><tr><th>&#8230;<\/th><td>&#8230;<\/td><td>&#8230;<\/td><td>&#8230;<\/td><td>&#8230;<\/td><td>&#8230;<\/td><td>&#8230;<\/td><\/tr><tr><th>2020-12-24<\/th><td>151.130005<\/td><td>150.179993<\/td><td>150.179993<\/td><td>150.470001<\/td><td>150200<\/td><td>150.470001<\/td><\/tr><tr><th>2020-12-28<\/th><td>153.419998<\/td><td>152.229996<\/td><td>153.100006<\/td><td>152.600006<\/td><td>215600<\/td><td>152.600006<\/td><\/tr><tr><th>2020-12-29<\/th><td>155.199997<\/td><td>152.899994<\/td><td>155.000000<\/td><td>153.339996<\/td><td>265100<\/td><td>153.339996<\/td><\/tr><tr><th>2020-12-30<\/th><td>155.210007<\/td><td>154.039993<\/td><td>154.509995<\/td><td>154.089996<\/td><td>193500<\/td><td>154.089996<\/td><\/tr><tr><th>2020-12-31<\/th><td>154.839996<\/td><td>153.970001<\/td><td>154.410004<\/td><td>154.570007<\/td><td>160000<\/td><td>154.570007<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u3053\u306e\u30c7\u30fc\u30bf\u306e\u3046\u3061, \u4e88\u6e2c\u306b\u5229\u7528\u3059\u308b\u306e\u306f `Adj Close` \u30ab\u30e9\u30e0\u3067\u3059. \u3053\u308c\u306f\u8abf\u6574\u5f8c\u7d42\u5024\u3068\u3044\u3046\u5024\u3067\u3059.<\/p>\n\n\n\n<p>( \u8abf\u6574\u5f8c\u7d42\u5024\u3068\u306f\uff1f <a href=\"https:\/\/support.yahoo-net.jp\/PccFinance\/s\/article\/H000006678\">https:\/\/support.yahoo-net.jp\/PccFinance\/s\/article\/H000006678<\/a> )<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u300c\u6642\u523b\u3092\u8868\u3059\u5217\u306f<code> ds<\/code> , \u4e88\u6e2c\u3059\u308b\u5024\u306e\u5217\u306f <code>y<\/code> \u3067\u8868\u3059\u300d\u3068\u3044\u3046Prophet\u306e\u4ed5\u69d8\u306b\u5408\u308f\u305b\u3066, \u30c7\u30fc\u30bf\u3092\u6574\u5f62\u3057\u307e\u3059.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>data_train&#91;'ds'] = data_train.index\ndata_train = data_train.rename({'Adj Close':'y'}, axis=1)<\/code><\/pre>\n\n\n\n<p>\u682a\u4fa1\u306f\u5bfe\u6570\u3092\u3068\u308b\u306e\u304c\u901a\u4f8b\u3089\u3057\u3044\u306e\u3067 , <code>y<\/code>\u5217\u306b\u5bfe\u6570\u3092\u88ab\u305b\u307e\u3059.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u682a\u4fa1\u30c1\u30e3\u30fc\u30c8\u306f\u300c\u7dda\u5f62\u30b0\u30e9\u30d5\u300d\u3060\u3051\u3067\u306a\u304f\u300c\u5bfe\u6570\u30b0\u30e9\u30d5\u300d\u3067\u3082\u898b\u308b\u7fd2\u6163\u3092\u3064\u3051\u3088\u3046\u3010\u521d\u5fc3\u8005\u5fc5\u898b\u3011 <a href=\"https:\/\/www.35kara.com\/2020\/07\/what-are-a-linear-graph-and-a-log-graph.html\" data-type=\"URL\" data-id=\"https:\/\/www.35kara.com\/2020\/07\/what-are-a-linear-graph-and-a-log-graph.html\">https:\/\/www.35kara.com\/2020\/07\/what-are-a-linear-graph-and-a-log-graph.html<\/a><\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>data_train&#91;'y'] = np.log(data_train&#91;'y'])<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b66\u7fd2\u30d1\u30fc\u30c8<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>model = Prophet()\nmodel.fit(data_train)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">parameter<\/h3>\n\n\n\n<p>\u30e2\u30c7\u30eb\u306b\u306f\u4ee5\u4e0b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u8a2d\u5b9a\u53ef\u80fd\u3067\u3059\u3002\u554f\u984c\u306b\u3088\u308a\u9069\u5207\u306a\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u7cbe\u5ea6\u304c\u5411\u4e0a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>growth<\/strong>: \u30c8\u30ec\u30f3\u30c9\u3092\u8868\u3059\u95a2\u6570\uff08\u7dda\u5f62\u304b\u30ed\u30b8\u30b9\u30c6\u30a3\u30c3\u30af\u66f2\u7dda\uff09<\/li><li><strong>changepoints<\/strong>: \u30c8\u30ec\u30f3\u30c9\u306e\u5909\u5316\u70b9\u306e\u30ea\u30b9\u30c8<\/li><li><strong>n_changepoints<\/strong>: \u30c8\u30ec\u30f3\u30c9\u306e\u5909\u5316\u70b9\u306e\u6570<\/li><li><strong>changepoint_range<\/strong>: \u30c8\u30ec\u30f3\u30c9\u306e\u5909\u5316\u70b9\u3092\u63a8\u6e2c\u3059\u308b\u5e45<\/li><li><strong>yearly_seasonality<\/strong>: \u5e74\u5358\u4f4d\u306e\u5468\u671f\u6027\u3092\u8003\u616e\u3059\u308b\u304b<\/li><li><strong>weekly_seasonality<\/strong>: \u9031\u5358\u4f4d\u306e\u5468\u671f\u6027\u3092\u8003\u616e\u3059\u308b\u304b<\/li><li><strong>daily_seasonality<\/strong>: \u65e5\u5358\u4f4d\u306e\u5468\u671f\u6027\u3092\u8003\u616e\u3059\u308b\u304b<\/li><li><strong>holidays<\/strong>: \u4f11\u65e5<\/li><li><strong>seasonality_mode<\/strong>: \u5468\u671f\u6027\u306e\u50be\u5411<\/li><li><strong>seasonality_prior_scale<\/strong>: \u5468\u671f\u6027\u306e\u5f37\u3055\u3092\u8868\u3059\u30d1\u30e9\u30e1\u30fc\u30bf<\/li><li><strong>holidays_prior_scale<\/strong>: \u4f11\u65e5\u306e\u5f37\u3055\u3092\u8868\u3059\u30d1\u30e9\u30e1\u30fc\u30bf<\/li><li><strong>changepoint_prior_scale<\/strong>: \u30c8\u30ec\u30f3\u30c9\u306e\u5909\u5316\u70b9\u306e\u5f37\u3055\u3092\u8868\u3059\u30d1\u30e9\u30e1\u30fc\u30bf<\/li><li><strong>mcmc_samples<\/strong>: MCMC\u6cd5\u306e\u30b5\u30f3\u30d7\u30eb\u6570<\/li><li><strong>interval_width<\/strong>: \u8aa4\u5dee\u306e\u7bc4\u56f2\u306e\u5e83\u3055<\/li><li><strong>uncertainty_samples<\/strong>: \u8aa4\u5dee\u3092\u63a8\u6e2c\u3059\u308b\u305f\u3081\u306e\u30b5\u30f3\u30d7\u30eb\u6570<\/li><li><strong>stan_backend<\/strong>: \u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306e\u6307\u5b9a<\/li><\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u6307\u5b9a\u304c\u3067\u304d\u307e\u3059\u3002\u4e0b\u8a18\u306f\u5168\u3066\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>params = {'growth': 'linear',\n          'changepoints': None,\n          'n_changepoints': 25,\n          'changepoint_range': 0.8,\n          'yearly_seasonality': 'auto',\n          'weekly_seasonality': 'auto',\n          'daily_seasonality': 'auto',\n          'holidays': None,\n          'seasonality_mode': 'additive',\n          'seasonality_prior_scale': 10.0,\n          'holidays_prior_scale': 10.0,\n          'changepoint_prior_scale': 0.05,\n          'mcmc_samples': 0,\n          'interval_width': 0.80,\n          'uncertainty_samples': 1000,\n          'stan_backend': None}\n\nmodel = Prophet(**params)<\/code><\/pre>\n\n\n\n<div class=\"wp-block-columns are-vertically-aligned-top is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-vertically-aligned-top is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p><\/p>\n<\/div><\/div>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e88\u6e2c\u30d1\u30fc\u30c8<\/h2>\n\n\n\n<p>\u5b66\u7fd2\u304c\u5b8c\u4e86\u3057\u305f\u3089\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3067\u4e88\u6e2c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p><code>make_future_dataframe<\/code>\u3067\u5b66\u7fd2\u30c7\u30fc\u30bf\u306e\u671f\u9593\u306b\u4e88\u6e2c\u3057\u305f\u3044\u671f\u9593\u3092\u8ffd\u52a0\u3057\u305fDataFrame\u3092\u4f5c\u6210\u3057\u307e\u3059.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>future = model.make_future_dataframe(\n    periods=365, # \u4e88\u6e2c\u3059\u308b\u65e5\u6570\n    freq = 'd'   # \u5358\u4f4d(d: \u65e5)\n)<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u304cfuture\u306e\u4e2d\u8eab\u3067\u3059.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th><\/th><th>ds<\/th><\/tr><\/thead><tbody><tr><th>0<\/th><td> 2018-01-02 <\/td><\/tr><tr><th>1<\/th><td> 2018-01-03 <\/td><\/tr><tr><th>2<\/th><td> 2018-01-04 <\/td><\/tr><tr><th>3<\/th><td> 2018-01-05 <\/td><\/tr><tr><th>4<\/th><td> 2018-01-08 <\/td><\/tr><tr><th>&#8230;<\/th><td> &#8230; <\/td><\/tr><tr><th>1116<\/th><td> 2021-12-27 <\/td><\/tr><tr><th>1117<\/th><td> 2021-12-28 <\/td><\/tr><tr><th>1118<\/th><td> 2021-12-29 <\/td><\/tr><tr><th>1119<\/th><td> 2021-12-30 <\/td><\/tr><tr><th>1120<\/th><td> 2021-12-31 <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u3067\u306f, \u3044\u3088\u3044\u3088\u4e88\u6e2c\u30d1\u30fc\u30c8\u3067\u3059. <code>predict<\/code> \u306b\u4e88\u6e2c\u3057\u305f\u3044\u671f\u9593\u3092\u542b\u3093\u3060 <code>future<\/code> \u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3092\u6e21\u3057\u3066\u4e88\u6e2c\u3092\u884c\u3044\u307e\u3059.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pred = model.predict(future)\nfig_pred = model.plot(pred)<\/code><\/pre>\n\n\n\n<p>\u9ed2\u70b9\u304c\u89b3\u6e2c\u5024\u3067, \u89b3\u6e2c\u5024\u304c\u306a\u3044\u672a\u6765\u306e\u671f\u9593(\u30b0\u30e9\u30d5\u53f3\u5074)\u306e\u9752\u7dda\u90e8\u5206\u304c\u4e88\u6e2c\u5024\u3068\u306a\u308a\u307e\u3059. \u6c34\u8272\u306e\u7bc4\u56f2\u306f\u8aa4\u5dee\u306e\u7bc4\u56f2\u3092\u8868\u3057\u3066\u3044\u307e\u3059. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"432\" src=\"https:\/\/www.avelio.co.jp\/math\/wordpress\/wp-content\/uploads\/2021\/11\/fig_pred.png\" alt=\"\" class=\"wp-image-263\"\/><\/figure>\n\n\n\n<p>\u30c8\u30ec\u30f3\u30c9\u3084\u5468\u671f\u6210\u5206\u3054\u3068\u306e\u30b0\u30e9\u30d5\u3092\u63cf\u753b\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059. 10\u6708\u672b\u3042\u305f\u308a\u304c\u8cb7\u3044\u306e\u3088\u3046\u3060\uff01<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fig_components = model.plot_components(pred)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"648\" height=\"648\" src=\"https:\/\/www.avelio.co.jp\/math\/wordpress\/wp-content\/uploads\/2021\/11\/fig_components.png\" alt=\"\" class=\"wp-image-265\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u3061\u3083\u3093\u3068\u4e88\u6e2c\u3067\u304d\u3066\u3044\u308b\u306e\u304b\uff1f<\/h2>\n\n\n\n<p>\u5148\u7a0b\u5f97\u3089\u308c\u305f\u4e88\u6e2c\u30e2\u30c7\u30eb\u306b, 2021\u5e741\u6708\u4ee5\u964d\u306e\u30c7\u30fc\u30bf\u3092\u91cd\u306d\u3066\u307f\u3066\u5b9f\u969b\u306b\u682a\u4fa1\u306e\u5024\u52d5\u304d\u304c\u4e88\u6e2c\u3067\u304d\u3066\u3044\u308b\u304b\u7c21\u5358\u306b\u78ba\u304b\u3081\u3066\u307f\u307e\u3059.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>start = datetime.date(2021,1,1)\nend = datetime.date(2021,11,1)\n\ndata_test = DataReader('TM', 'yahoo', start, end)\n\ndata_test&#91;'ds'] = data_test.index\ndata_test = data_test.rename({'Adj Close':'y'} ,axis=1)\ndata_test&#91;'y'] = np.log(data_test&#91;'y'])\n\nmodel = Prophet()\nmodel.fit(data_test)\n\nfig_test = model.plot(pred)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"432\" src=\"https:\/\/www.avelio.co.jp\/math\/wordpress\/wp-content\/uploads\/2021\/11\/fig_test.png\" alt=\"\" class=\"wp-image-258\"\/><\/figure>\n\n\n\n<p>\u4e0a\u6607\u30c8\u30ec\u30f3\u30c9\u306f\u6349\u3048\u3089\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059. 5\u6708\u524d\u534a\u304b\u3089\u306e6\u6708\u306b\u304b\u3051\u3066\u4e88\u6e2c\u4ee5\u4e0a\u306e\u6210\u9577\u3092\u898b\u305b\u3066\u3044\u307e\u3059\u304c, \u3053\u308c\u306f\u30c8\u30e8\u30bf\u306e\u6c7a\u7b97\u767a\u8868\u304c\u8981\u56e0\u307f\u305f\u3044\u3067\u3059\u306d.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u30c8\u30e8\u30bf\u306f5\u670812\u65e5\u306b\u767a\u8868\u3057\u305f\u6c7a\u7b97\u3067\uff64\u4eca\u671f\u306e\u55b6\u696d\u5229\u76ca\u304c\u524d\u671f\u6bd414\uff05\u5897\u306e2\u51465000\u5104\u5186\u306a\u3069\u3068\u3059\u308b\u898b\u901a\u3057\u3092\u516c\u8868\u3002\u30b3\u30ed\u30ca\u3084\u4e16\u754c\u7684\u306a\u534a\u5c0e\u4f53\u4e0d\u8db3\u306a\u3069\u306e\u5f71\u97ff\u3067\u81ea\u52d5\u8eca\u751f\u7523\u306b\u5f71\u97ff\u304c\u7d9a\u304d\uff64\u7af6\u5408\u306e\u65e5\u7523\u81ea\u52d5\u8eca\u306f\u53ce\u652f\u3068\u3093\u3068\u3093\u306e\u898b\u901a\u3057\u3092\u793a\u3059\u4e2d\u3067\u5f37\u3055\u3092\u793a\u3057\u305f\u3002<\/p><p><a href=\"https:\/\/shikiho.jp\/news\/0\/434454\" data-type=\"URL\" data-id=\"https:\/\/shikiho.jp\/news\/0\/434454\">\u4f1a\u793e\u56db\u5b63\u5831ONLINE-\u30c8\u30e8\u30bf\u81ea\u52d5\u8eca\u306e\u682a\u4fa1\u304c\u4e00\u6642\uff64\u4e0a\u5834\u6765\u521d\u306e1\u4e07\u5186\u53f0\u306b<\/a><\/p><\/blockquote>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b, \u682a\u4fa1\u306f\u5916\u4e71\u306e\u5f71\u97ff\u3092\u53d7\u3051\u307e\u304f\u308b\u306e\u3067, \u904e\u53bb\u306e\u682a\u4fa1\u3060\u3051\u304b\u3089\u5024\u52d5\u304d\u3092\u4e88\u6e2c\u3059\u308b\u306e\u306f\u4e0d\u53ef\u80fd\u3060\u3068\u8a00\u308f\u308c\u3066\u3044\u307e\u3059\u304c, \u4eca\u56de\u306f\u305f\u307e\u305f\u307e\u4e0a\u624b\u304f\u4e88\u6e2c\u3067\u304d\u307e\u307f\u305f\u3044\u3067\u3059. \u3084\u3063\u305f\u306d\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prophet\u306e\u6982\u8981 Prophet\u306fFacebook\u793e\u304c\u958b\u767a\u3057\u305f\u6642\u7cfb\u5217\u89e3\u6790\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059. Prophet\u3067\u306f, \u6642\u7cfb\u5217\u30c7\u30fc\u30bf \\(y(t)\\) \u30923\u3064\u306e\u9805\u306e\u548c\u3068\u3057\u3066\u30e2\u30c7\u30ea\u30f3\u30b0\u3057\u307e\u3059. $$ y(t) = g(t) + [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6],"tags":[],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry","category-5","category-6"],"_links":{"self":[{"href":"https:\/\/www.avelio.co.jp\/math\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.avelio.co.jp\/math\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.avelio.co.jp\/math\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.avelio.co.jp\/math\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.avelio.co.jp\/math\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=117"}],"version-history":[{"count":46,"href":"https:\/\/www.avelio.co.jp\/math\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/117\/revisions"}],"predecessor-version":[{"id":279,"href":"https:\/\/www.avelio.co.jp\/math\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/117\/revisions\/279"}],"wp:attachment":[{"href":"https:\/\/www.avelio.co.jp\/math\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.avelio.co.jp\/math\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.avelio.co.jp\/math\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}