{"id":283805,"date":"2017-03-23T14:05:02","date_gmt":"2017-03-23T11:05:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=283805"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=283805","title":{"rendered":"\u041f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Facebook Prophet"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/812\/803\/40b\/81280340b5c74e018e764a4dbea13f42.jpeg\" align=\"right\"\/>  <\/p>\n<p>\u041f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u2014 \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u041f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f online-\u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u0447\u0435\u0440\u0435\u0437 \u0433\u043e\u0434, \u043a\u0430\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0440\u043e\u0441 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u043e\u0432\u0430\u0440 \u0432 \u0433\u0438\u043f\u0435\u0440\u043c\u0430\u0440\u043a\u0435\u0442\u0435, \u0438\u043b\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0446\u0435\u043b\u0435\u0439 \u0438 \u043e\u0446\u0435\u043d\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c baseline \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u043c).<\/p>\n<p>  <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Autoregressive_integrated_moving_average\">ARIMA<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Autoregressive_conditional_heteroskedasticity\">ARCH<\/a>, \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438 \u0438 \u0442.\u0434. <\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0436\u0435 \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 <code>Facebook Prophet<\/code> (<em>\u0432 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u0441 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e, &quot;\u043f\u0440\u043e\u0440\u043e\u043a&quot;, <a href=\"https:\/\/research.fb.com\/prophet-forecasting-at-scale\/\">\u0432\u044b\u043f\u0443\u0449\u0435\u043d\u0430 \u0432 open-source<\/a> 23-\u0433\u043e \u0444\u0435\u0432\u0440\u0430\u043b\u044f 2017 \u0433\u043e\u0434\u0430<\/em>), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u2013 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u0441\u0442\u043e\u0432 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435\u0445\u0430\u0431\u0440\u0435. <\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"biblioteka\">\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<\/h2>\n<p>  <\/p>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e <a href=\"https:\/\/research.fb.com\/prophet-forecasting-at-scale\/\">\u0441\u0442\u0430\u0442\u044c\u0435 Facebook<\/a> <code>Prophet<\/code>, \u0431\u044b\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0441\u0442\u0440\u043e\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0435 default&#8217;\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0443\u043b\u0443\u0447\u0448\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0432 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u043c, \u043a\u0430\u043a \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <code>Prophet<\/code>. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Additive_model\">additive regression model<\/a>, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/959\/04b\/dbf\/95904bdbfc8292cd94691632babc8629.svg\" alt=\"$y(t) = g(t) + s(t) + h(t) + \\epsilon_{t}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<ol>\n<li><strong>\u0421\u0435\u0437\u043e\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b<\/strong> <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/eaf\/583\/ee1\/eaf583ee1c49552f156f235623828a82.svg\" alt=\"$s(t)$\" data-tex=\"inline\"\/><\/math> \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0438 \u0433\u043e\u0434\u043e\u0432\u043e\u0439 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c\u044e. \u041d\u0435\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>dummy variables<\/code>. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f 6 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>[monday, tuesday, wednesday, thursday, friday, saturday]<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 0 \u0438 1 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0430\u0442\u044b. \u041f\u0440\u0438\u0437\u043d\u0430\u043a <code>sunday<\/code>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0435\u0434\u044c\u043c\u043e\u043c\u0443 \u0434\u043d\u044e \u043d\u0435\u0434\u0435\u043b\u0438, \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0443\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u043d\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0438 \u0438 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c.<br \/>  \u0413\u043e\u0434\u043e\u0432\u0430\u044f \u0436\u0435 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u044f\u0434\u0430\u043c\u0438 \u0424\u0443\u0440\u044c\u0435.<\/li>\n<li><strong>\u0422\u0440\u0435\u043d\u0434<\/strong> <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c2b\/7de\/df6\/c2b7dedf6f4fa002207f0da9e7243b5d.svg\" alt=\"$g(t)$\" data-tex=\"inline\"\/><\/math> \u2014 \u044d\u0442\u043e \u043a\u0443\u0441\u043e\u0447\u043d\u043e-\u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0438\u043b\u0438 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0421 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u041b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0438\u0434\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1fd\/d92\/faa\/1fdd92faaa5b40c5e6651f3086a034f3.svg\" alt=\"$g(t) = \\frac{C}{1+exp(-k(t-b))}$\" data-tex=\"inline\"\/><\/math> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u043e\u0441\u0442 \u0441 \u043d\u0430\u0441\u044b\u0449\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0441\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c\u043f \u0435\u0433\u043e \u0440\u043e\u0441\u0442\u0430. \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u044d\u0442\u043e \u0440\u043e\u0441\u0442 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0441\u0430\u0439\u0442\u0430.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0443\u043c\u0435\u0435\u0442 \u043f\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u043d\u0434\u0430. \u041d\u043e \u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0434\u0430\u0442\u044b \u0440\u0435\u043b\u0438\u0437\u043e\u0432 \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0432\u043b\u0438\u044f\u043b\u0438 \u043d\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438).<\/li>\n<li>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/299\/d07\/dbe\/299d07dbeab8dd929a8d57710d7c50fb.svg\" alt=\"$h(t)$\" data-tex=\"inline\"\/><\/math> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c <strong>\u0430\u043d\u043e\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u043d\u0438<\/strong>, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043d\u0435\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Black Fridays.<\/li>\n<li><strong>\u041e\u0448\u0438\u0431\u043a\u0430<\/strong> <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/efe\/886\/4ae\/efe8864ae200b932551f59e518d0946c.svg\" alt=\"$\\epsilon_{t}$\" data-tex=\"inline\"\/><\/math> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0443\u0447\u0442\u0435\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c\u044e.<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 <em>Sean J. Taylor, Benjamin Letham <a href=\"https:\/\/facebookincubator.github.io\/prophet\/static\/prophet_paper_20170113.pdf\">&quot;Forecasting at scale&quot;<\/a><\/em>.<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0436\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 <code>mean absolute percentage error<\/code> \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 <code>Prophet<\/code> \u0438\u043c\u0435\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"https:\/\/habrastorage.org\/files\/491\/363\/dfa\/491363dfa9da400686ce13018a167b7f.png\"\/><\/div>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043b\u0438 <code>Prophet<\/code>.<\/p>\n<p>  <\/p>\n<p><code>MAPE (mean absolute percentage error)<\/code> \u2014 \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430. \u041f\u0443\u0441\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ce0\/009\/fc5\/ce0009fc5603a0e2edc997cebe4cc560.svg\" alt=\"$y_{i}$\" data-tex=\"inline\"\/><\/math> \u2014 \u044d\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f01\/036\/a1e\/f01036a1e0fc69925d0d591a7ad44d90.svg\" alt=\"$\\hat{y_{i}}$\" data-tex=\"inline\"\/><\/math> \u2014 \u044d\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0449\u0438\u0439 \u044d\u0442\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u0422\u043e\u0433\u0434\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b02\/62c\/26d\/b0262c26d4209386512db0f7bc3fe437.svg\" alt=\"$e_{i} = y_{i} - \\hat{y_{i}}$\" data-tex=\"inline\"\/><\/math> \u2014 \u044d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430, a <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5c3\/94e\/af6\/5c394eaf6378733785708713df5834a9.svg\" alt=\"$p_{i} =100 \\frac{e_{i}}{y_{i}}$\" data-tex=\"inline\"\/><\/math> \u2014 \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445.<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/66c\/006\/de5\/66c006de5aeb3e603d3656a2e2b9864e.svg\" alt=\"$MAPE = mean(|p_{i}|)$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><code>MAPE<\/code> \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u0430 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438 \u043f\u043e \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u0436\u0435 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438 \u043d\u0430 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 <code>MAE - mean average error<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0448\u0438\u0431\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430\u0445.<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/dec\/0db\/bbf\/dec0dbbbfd88e93e3c28d9f4b6530d41.svg\" alt=\"$MAE = mean(|e_{i}|)$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>C\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043e \u0442\u0435\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043b\u0438 <code>Prophet<\/code> \u0432 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u043d\u0438\u0445 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0438 \u0438\u0445 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043a\u0430\u043a baseline:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>naive<\/code> \u2014 \u043d\u0430\u0438\u0432\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439;<\/li>\n<li><code>snaive - seasonal naive<\/code> \u2014 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u044f\u0432\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u043e\u0439 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0441 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0431\u0440\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a, \u0434\u043b\u044f \u0432\u0442\u043e\u0440\u043d\u0438\u043a\u0430 \u2014 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0432\u0442\u043e\u0440\u043d\u0438\u043a \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435;<\/li>\n<li><code>mean<\/code> \u2014 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f;<\/li>\n<li><code>arima - autoregressive integrated moving average<\/code> \u2014 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Autoregressive_integrated_moving_average\">wiki<\/a>;<\/li>\n<li><code>ets - exponential smoothing<\/code> \u2014 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Exponential_smoothing\">wiki<\/a>.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"praktika\">\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/h2>\n<p>  <\/p>\n<h3 id=\"ustanovka\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <code>Prophet<\/code> \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0434\u043b\u044f <code>python<\/code> \u0438 <code>R<\/code>. \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e <code>python<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e. \u0414\u043b\u044f <code>python<\/code> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>PyPi<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">pip install fbprophet<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0434 <code>R<\/code> \u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0435\u0441\u0442\u044c <code>CRAN package<\/code>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/facebookincubator.github.io\/prophet\/docs\/installation.html\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>. <\/p>\n<p>  <\/p>\n<h3 id=\"dannye\">\u0414\u0430\u043d\u043d\u044b\u0435<\/h3>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u044f \u0432\u044b\u0431\u0440\u0430\u043b\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0441\u0442\u043e\u0432, \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0425\u0430\u0431\u0440\u0430\u0445\u0430\u0431\u0440\u0435. \u0414\u0430\u043d\u043d\u044b\u0435 \u044f \u0432\u0437\u044f\u043b\u0430 \u0438\u0437 \u0443\u0447\u0435\u0431\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430 \u043d\u0430 Kaggle <a href=\"https:\/\/inclass.kaggle.com\/c\/howpop-habrahabr-favs-lognorm\">&quot;\u041f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435&quot;<\/a>. <a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/323890\/#7-domashnee-zadanie--4\">\u0422\u0443\u0442<\/a> \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 <a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/322626\/\">\u043a\u0443\u0440\u0441\u0435<\/a> \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import pandas as pd  habr_df = pd.read_csv('howpop_train.csv') habr_df['published'] = pd.to_datetime(habr_df.published) habr_df = habr_df[['published', 'url']]  aggr_habr_df = habr_df.groupby('published')[['url']].count()  aggr_habr_df.columns = ['posts']  aggr_habr_df = aggr_habr_df.resample('D').apply(sum)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c <code>time series plot<\/code> \u0437\u0430 \u0432\u0435\u0441\u044c \u043f\u0435\u0440\u0438\u043e\u0434. \u041d\u0430 \u0442\u0430\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u043e\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u0435 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438. <\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>plot.ly<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 <code>python<\/code> \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u043d\u0435\u0435 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u0446\u0435\u043b\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/323210\/\">\u041e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u0443\u0440\u0441 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0422\u0435\u043c\u0430 2: \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 c Python<\/a>.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot from plotly import graph_objs as go  # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c plotly init_notebook_mode(connected = True)  # \u043e\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 dataframe \u0432 \u0432\u0438\u0434\u0435 line plot def plotly_df(df, title = ''):     data = []      for column in df.columns:         trace = go.Scatter(             x = df.index,             y = df[column],             mode = 'lines',             name = column         )         data.append(trace)      layout = dict(title = title)     fig = dict(data = data, layout = layout)     iplot(fig, show_link=False)  plotly_df(aggr_habr_df.resample('W').apply(sum), title = '\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u044b \u043d\u0430 \u0425\u0430\u0431\u0440\u0430\u0445\u0430\u0431\u0440\u0435')<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cba\/53b\/cf7\/cba53bcf789b43b18e55931554ea50a7.png\"\/>  <\/p>\n<h3 id=\"postroenie-prognoza\">\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430<\/h3>\n<p>  <\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <code>Prophet<\/code> \u0438\u043c\u0435\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043d\u0430 <code>sklearn<\/code>, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0443 \u043d\u0435\u0435 \u043c\u0435\u0442\u043e\u0434 <code>fit<\/code> \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437. \u041d\u0430 \u0432\u0445\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0443 <code>fit<\/code> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <code>dataframe<\/code> \u0441 \u0434\u0432\u0443\u043c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c\u0438: <\/p>\n<p>  <\/p>\n<ul>\n<li><code>ds<\/code> \u2014 \u0432\u0440\u0435\u043c\u044f, \u043f\u043e\u043b\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0438\u043f\u0430 <code>date<\/code> \u0438\u043b\u0438 <code>datetime<\/code>,<\/li>\n<li><code>y<\/code> \u2014 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u0440\u0438\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430, \u0443\u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043c\u0435\u0441\u044f\u0446 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e. \u0421\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u0441\u043e\u0432\u0435\u0442\u0443\u044e\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043c\u0435\u0441\u044f\u0446\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u2013 \u0433\u043e\u0434 \u0438 \u0431\u043e\u043b\u0435\u0435 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f).<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">#\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 from fbprophet import Prophet  predictions = 30  # \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c dataframe \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443 df = aggr_habr_df.reset_index() df.columns = ['ds', 'y']  # \u043e\u0442\u0440\u0435\u0437\u0430\u0435\u043c \u0438\u0437 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 30 \u0442\u043e\u0447\u0435\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u043d\u0438\u0445 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e train_df = df[:-predictions] <\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Prophet<\/code> (\u0432\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c default&#8217;\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b) \u0438 \u043e\u0431\u0443\u0447\u0430\u0435\u043c \u0435\u0433\u043e. <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">m = Prophet() m.fit(train_df)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>Prophet.make_future_dataframe<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u043c <code>dataframe<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0438 \u0435\u0449\u0435 30 \u0434\u043d\u0435\u0439, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437. <\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0443 \u043c\u043e\u0434\u0435\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>predict<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043d\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435 <code>dataframe future<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">future = m.make_future_dataframe(periods=predictions) forecast = m.predict(future)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <code>Prophet<\/code> \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u0435\u0442\u043e\u0434 <code>Prophet.plot<\/code> \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437. \u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u0430\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0432\u044b\u0432\u043e\u0434 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u2014 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043d\u043e\u0433\u043e <code>outlier<\/code>&#8216;\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u043e\u0447\u0435\u043a, \u0442\u043e \u043f\u043e \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043d\u044f\u0442\u044c.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">m.plot(forecast)<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c50\/b7d\/fb8\/c50b7dfb80924f27bc7e193eba4112b4.png\"\/>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>Prophet.plot_components<\/code>, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b: \u0442\u0440\u0435\u043d\u0434, \u0433\u043e\u0434\u043e\u0432\u0443\u044e \u0438 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u044b\u043b\u0438 \u0437\u0430\u0434\u0430\u043d\u044b \u0430\u043d\u043e\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u043d\u0438\/\u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043a\u0438, \u0442\u043e \u043e\u043d\u0438 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">m.plot_components(forecast)<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/667\/bd5\/b26\/667bd5b265774c4188f166d239609351.png\"\/>  <\/p>\n<p>\u041d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e <code>Prophet<\/code> \u0445\u043e\u0440\u043e\u0448\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0438\u043b\u0441\u044f \u043f\u043e\u0434 \u0440\u043e\u0441\u0442 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u0441\u0442\u043e\u0432 &quot;\u0441\u0442\u0443\u043f\u0435\u043d\u044c\u043a\u043e\u0439&quot; \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 2015-\u0433\u043e. \u041f\u043e \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u0441\u0442\u043e\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435 \u0438 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a. \u041d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0433\u043e\u0434\u043e\u0432\u043e\u0439 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438 \u044f\u0440\u0447\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0430\u043b \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0432 \u041d\u043e\u0432\u043e\u0433\u043e\u0434\u043d\u0438\u0435 \u043a\u0430\u043d\u0438\u043a\u0443\u043b\u044b, \u0442\u0430\u043a\u0436\u0435 \u0432\u0438\u0434\u0435\u043d \u0441\u043f\u0430\u0434 \u0438 \u043d\u0430 \u043c\u0430\u0439\u0441\u043a\u0438\u0445 \u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043a\u0430\u0445.<\/p>\n<p>  <\/p>\n<h3 id=\"ocenka-kachestva-modeli\">\u041e\u0446\u0435\u043d\u043a\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438<\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0446\u0435\u043d\u0438\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c <code>MAPE<\/code> \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 30 \u0434\u043d\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438. \u0414\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ce0\/009\/fc5\/ce0009fc5603a0e2edc997cebe4cc560.svg\" alt=\"$y_{i}$\" data-tex=\"inline\"\/><\/math> \u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u0434\u043b\u044f \u043d\u0438\u0445 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f01\/036\/a1e\/f01036a1e0fc69925d0d591a7ad44d90.svg\" alt=\"$ \\hat{y_{i}}$\" data-tex=\"inline\"\/><\/math>. <\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 <code>forecast<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e <code>dataframe<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0432\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u043d\u0430\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">print(', '.join(forecast.columns))<\/code><\/pre>\n<p>  <\/p>\n<pre><code>ds, t, trend, seasonal_lower, seasonal_upper, trend_lower, trend_upper, yhat_lower, yhat_upper, weekly, weekly_lower, weekly_upper, yearly, yearly_lower, yearly_upper, seasonal, yhat<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c <code>forecast<\/code> \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">cmp_df = forecast.set_index('ds')[['yhat', 'yhat_lower', 'yhat_upper']].join(df.set_index('ds'))<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u043c\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u043e\u0436\u0438\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043c\u0435\u0441\u044f\u0446, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 30 \u0434\u043d\u0435\u0439 \u0438 \u0438\u0437\u043c\u0435\u0440\u0438\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import numpy as np cmp_df['e'] = cmp_df['y'] - cmp_df['yhat'] cmp_df['p'] = 100*cmp_df['e']\/cmp_df['y'] print 'MAPE', np.mean(abs(cmp_df[-predictions:]['p'])) print 'MAE', np.mean(abs(cmp_df[-predictions:]['e']))<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043a\u043e\u043b\u043e <code>37.35%<\/code>, \u0430 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0432 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0448\u0438\u0431\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <code>10.62<\/code> \u043f\u043e\u0441\u0442\u0430.<\/p>\n<p>  <\/p>\n<h3 id=\"vizualizaciya\">\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0432\u043e\u044e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 <code>Prophet<\/code> \u043c\u043e\u0434\u0435\u043b\u0438: \u0441 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u043c \u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044f \u0445\u043e\u0447\u0443 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u043f\u0435\u0440\u0438\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u043b\u0438\u0441\u044c \u0432 \u043c\u0435\u0441\u0438\u0432\u043e \u0442\u043e\u0447\u0435\u043a. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 \u0442\u043e\u0442 \u043f\u0435\u0440\u0438\u043e\u0434, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u2014 \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0442\u0430\u043a \u0433\u0440\u0430\u0444\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c. \u0412-\u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>plot.ly<\/code>.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"> # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 def show_forecast(cmp_df, num_predictions, num_values):     # \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430     upper_bound = go.Scatter(         name='Upper Bound',         x=cmp_df.tail(num_predictions).index,         y=cmp_df.tail(num_predictions).yhat_upper,         mode='lines',         marker=dict(color=&quot;444&quot;),         line=dict(width=0),         fillcolor='rgba(68, 68, 68, 0.3)',         fill='tonexty')      # \u043f\u0440\u043e\u0433\u043d\u043e\u0437     forecast = go.Scatter(         name='Prediction',         x=cmp_df.tail(predictions).index,         y=cmp_df.tail(predictions).yhat,         mode='lines',         line=dict(color='rgb(31, 119, 180)'),     )      # \u043d\u0438\u0436\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430     lower_bound = go.Scatter(         name='Lower Bound',         x=cmp_df.tail(num_predictions).index,         y=cmp_df.tail(num_predictions).yhat_lower,         marker=dict(color=&quot;444&quot;),         line=dict(width=0),         mode='lines')      # \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f     fact = go.Scatter(         name='Fact',         x=cmp_df.tail(num_values).index,         y=cmp_df.tail(num_values).y,         marker=dict(color=&quot;red&quot;),         mode='lines',     )      # \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u044f\u0434\u043e\u0432 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0430\u0436\u043d\u0430 \u0438\u0437-\u0437\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043b\u0438\u0432\u043a\u0438     data = [lower_bound, upper_bound, forecast, fact]      layout = go.Layout(         yaxis=dict(title='\u041f\u043e\u0441\u0442\u044b'),         title='\u041e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u044b \u043d\u0430 \u0425\u0430\u0431\u0440\u0430\u0445\u0430\u0431\u0440\u0435',         showlegend = False)      fig = go.Figure(data=data, layout=layout)     iplot(fig, show_link=False)  show_forecast(cmp_df, predictions, 200)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438. <\/p>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fd8\/1a9\/80e\/fd81a980ecdb49c6ad53d648bba52d95.png\"\/>  <\/p>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0438 \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u043c. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u0430\u043a\u0430\u044f \u043d\u0438\u0437\u043a\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0430\u043d\u043e\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0441\u0442\u043e\u0432 13 \u0438 17 \u043e\u043a\u0442\u044f\u0431\u0440\u044f \u0438 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0441 7 \u043e\u043a\u0442\u044f\u0431\u0440\u044f.<br \/>  \u0422\u0430\u043a\u0436\u0435 \u043f\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a \u043b\u0435\u0436\u0430\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430.<\/p>\n<p>  <\/p>\n<h2 id=\"sravnenie-s-arima-modelyu\">\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 ARIMA \u043c\u043e\u0434\u0435\u043b\u044c\u044e<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430 \u0433\u043b\u0430\u0437 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u043c, \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0435\u0433\u043e \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e <code>SARIMA - Seasonal autoregressive integrated moving average<\/code> \u0441 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c. <\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0425\u0430\u0431\u0440\u0430\u0445\u0430\u0431\u0440\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e <code>ARIMA<\/code>-\u043c\u043e\u0434\u0435\u043b\u0438, \u0432\u0441\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u043c\u0441\u044f \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445: <a href=\"https:\/\/habrahabr.ru\/post\/210530\/\">\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 SARIMA \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python+R<\/a> \u0438 <a href=\"https:\/\/habrahabr.ru\/post\/207160\/\">\u0410\u043d\u0430\u043b\u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e python<\/a>. <\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u044f \u0442\u0430\u043a\u0436\u0435 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0443\u0447\u0435\u0431\u043d\u044b\u043c\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u043c\u0438 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/www.coursera.org\/learn\/data-analysis-applications\/home\/week\/1\">\u041f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/a> \u043d\u0430 \u0421oursera, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u044b <code>ARIMA<\/code>-\u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043a\u0430\u043a \u0438\u0445 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430 <code>python<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 <code>ARIMA<\/code> \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u0430\u0442\u0440\u0430\u0442 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 <code>Prophet<\/code>: \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0440\u044f\u0434, \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0435\u0433\u043e \u043a \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u043c\u0443, \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0435\u043c\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043f\u043e\u0434\u0431\u043e\u0440 \u0433\u0438\u043f\u0435\u0440-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 (\u043d\u0430 \u043c\u043e\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u043b\u0430\u0441\u044c \u043f\u043e\u0447\u0442\u0438 2 \u0447\u0430\u0441\u0430).<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u0438\u043b\u0438\u044f \u0431\u044b\u043b\u0438 \u043d\u0435 \u043d\u0430\u043f\u0440\u0430\u0441\u043d\u044b \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 <code>SARIMA<\/code> \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u043c: <code>MAPE=16.54%, MAE=7.28 \u043f\u043e\u0441\u0442\u0430<\/code>. \u041b\u0443\u0447\u0448\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438: <code>D=1, d=1, Q=1, q=4, P=1, p=3<\/code>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/331\/0dc\/ff3\/3310dcff35b8496ba98512a73ade4e9c.png\"\/>  <\/p>\n<p>\u041d\u043e \u0438 <code>Prophet<\/code>, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u043f\u043e\u0442\u044e\u043d\u0438\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043d\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0440\u044f\u0434, \u0430 \u043f\u043e\u0441\u043b\u0435 <a href=\"http:\/\/www.machinelearning.ru\/wiki\/index.php?title=%D0%9C%D0%B5%D1%82%D0%BE%D0%B4_%D0%91%D0%BE%D0%BA%D1%81%D0%B0-%D0%9A%D0%BE%D0%BA%D1%81%D0%B0\">\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0411\u043e\u043a\u0441\u0430-\u041a\u043e\u043a\u0441\u0430<\/a>, \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e \u0440\u044f\u0434\u0430, \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430: <code>MAPE=26.79%, MAE=8.49 \u043f\u043e\u0441\u0442\u0430<\/code>.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0440\u044f\u0434\u0430 \u0441 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0411\u043e\u043a\u0441\u0430-\u041a\u043e\u043a\u0441\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from scipy import stats import statsmodels.api as sm  def invboxcox(y,lmbda):     if lmbda == 0:         return(np.exp(y))     else:         return(np.exp(np.log(lmbda*y+1)\/lmbda))  train_df2 = train_df.copy().fillna(14) train_df2 = train_df2.set_index('ds') train_df2['y'], lmbda_prophet = stats.boxcox(train_df2['y'])  train_df2.reset_index(inplace=True)  m2 = Prophet() m2.fit(train_df2) future2 = m2.make_future_dataframe(periods=30)  forecast2 = m2.predict(future2) forecast2['yhat'] = invboxcox(forecast2.yhat, lmbda_prophet) forecast2['yhat_lower'] = invboxcox(forecast2.yhat_lower, lmbda_prophet) forecast2['yhat_upper'] = invboxcox(forecast2.yhat_upper, lmbda_prophet)  cmp_df2 = forecast2.set_index('ds')[['yhat', 'yhat_lower', 'yhat_upper']].join(df.set_index('ds'))  cmp_df2['e'] = cmp_df2['y'] - cmp_df2['yhat'] cmp_df2['p'] = 100*cmp_df2['e']\/cmp_df2['y'] np.mean(abs(cmp_df2[-predictions:]['p'])), np.mean(abs(cmp_df2[-predictions:]['e']))<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2 id=\"itog\">\u0418\u0442\u043e\u0433<\/h2>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 open-source \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 <code>Prophet<\/code> \u0438 \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435.<br \/>  \u042f \u0431\u044b \u043d\u0435 \u0441\u0442\u0430\u043b\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0442\u0432\u043e\u0440\u0438\u0442 \u0447\u0443\u0434\u0435\u0441\u0430 \u0438 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u0443\u0434\u0443\u0449\u0435\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0445\u0443\u0436\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 <code>SARIMA<\/code>. \u041e\u0434\u043d\u0430\u043a\u043e, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <code>Prophet<\/code> \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u0430\u044f, \u043b\u0435\u0433\u043a\u043e \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f (\u0447\u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u0438\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0430\u043d\u043e\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u043d\u0435\u0439), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0432 \u0441\u0432\u043e\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c <code>toolbox'e<\/code>.<\/p>\n<p>  <\/p>\n<h2 id=\"poleznye-ssylki\">\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>Prophet<\/code> \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u0432 \u043e\u0431\u0449\u0435\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>Prophet<\/code> GitHub <a href=\"https:\/\/github.com\/facebookincubator\/prophet\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a> Prophet<\/li>\n<li><code>Prophet<\/code> <a href=\"https:\/\/facebookincubator.github.io\/prophet\/docs\/quick_start.html\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/a><\/li>\n<li><em>Sean J. Taylor, Benjamin Letham <a href=\"https:\/\/facebookincubator.github.io\/prophet\/static\/prophet_paper_20170113.pdf\">&quot;Forecasting at scale&quot;<\/a><\/em> \u2014 \u043d\u0430\u0443\u0447\u043d\u0430\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f, \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0430\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>Prophet<\/code><\/li>\n<li><em><a href=\"http:\/\/pbpython.com\/prophet-overview.html\">Forecasting Website Traffic Using Facebook\u2019s Prophet Library <\/a><\/em> \u2014 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0430 \u0441\u0430\u0439\u0442<\/li>\n<li><em>Rob J Hyndman, George Athana\u00adsopou\u00adlos <a href=\"https:\/\/www.otexts.org\/fpp\">&quot;Forecasting: principles and practice&quot;<\/a><\/em> \u2013 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a, \u0445\u043e\u0440\u043e\u0448\u0430\u044f online-\u043a\u043d\u0438\u0433\u0430, \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u0430\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432<\/li>\n<li><a href=\"http:\/\/nbviewer.jupyter.org\/github\/miptgirl\/habra_materials\/blob\/master\/prophet\/habra_data.ipynb\">jupyter notebook<\/a> \u0441 \u043a\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/li>\n<\/ul>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/323730\/\"> https:\/\/habrahabr.ru\/post\/323730\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/812\/803\/40b\/81280340b5c74e018e764a4dbea13f42.jpeg\" align=\"right\"\/>  <\/p>\n<p>\u041f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u2014 \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u041f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f online-\u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u0447\u0435\u0440\u0435\u0437 \u0433\u043e\u0434, \u043a\u0430\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0440\u043e\u0441 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u043e\u0432\u0430\u0440 \u0432 \u0433\u0438\u043f\u0435\u0440\u043c\u0430\u0440\u043a\u0435\u0442\u0435, \u0438\u043b\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0446\u0435\u043b\u0435\u0439 \u0438 \u043e\u0446\u0435\u043d\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c baseline \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u043c).<\/p>\n<p>  <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Autoregressive_integrated_moving_average\">ARIMA<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Autoregressive_conditional_heteroskedasticity\">ARCH<\/a>, \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438 \u0438 \u0442.\u0434. <\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0436\u0435 \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 <code>Facebook Prophet<\/code> (<em>\u0432 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u0441 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e, &quot;\u043f\u0440\u043e\u0440\u043e\u043a&quot;, <a href=\"https:\/\/research.fb.com\/prophet-forecasting-at-scale\/\">\u0432\u044b\u043f\u0443\u0449\u0435\u043d\u0430 \u0432 open-source<\/a> 23-\u0433\u043e \u0444\u0435\u0432\u0440\u0430\u043b\u044f 2017 \u0433\u043e\u0434\u0430<\/em>), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u2013 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u0441\u0442\u043e\u0432 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435\u0445\u0430\u0431\u0440\u0435. <\/p>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-283805","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=283805"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283805\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}