{"id":285430,"date":"2017-04-24T15:05:04","date_gmt":"2017-04-24T11:05:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=285430"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=285430","title":{"rendered":"\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"},"content":{"rendered":"<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0434\u043d\u044f!<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043d\u0430\u0448 \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u0443\u0440\u0441\u0430 \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0438 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u0430\u0445. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/234\/dcd\/2fc\/234dcd2fca894e80bc4c753e67bf613f.jpg\" width=\"250\" align=\"right\"\/>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 Python, \u043a\u0430\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f; \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0434\u0432\u043e\u0439\u043d\u043e\u0435 \u0438 \u0442\u0440\u043e\u0439\u043d\u043e\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0437\u0432\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435; \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e \u0432\u0430\u0441; \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c SARIMA \u0438 \u043d\u0435 \u0443\u043c\u0435\u0440\u0435\u0442\u044c; \u0438 \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c xgboost-\u043e\u043c. \u0418 \u0432\u0441\u0451 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0438\u0437 \u0441\u0443\u0440\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041f\u043b\u0430\u043d \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0414\u0432\u0438\u0436\u0435\u043c\u0441\u044f, \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u0435\u043c \u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c<br \/> \n<ul>\n<li>Rolling window estimations<\/li>\n<li>\u042d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435, \u043c\u043e\u0434\u0435\u043b\u044c \u0425\u043e\u043b\u044c\u0442\u0430-\u0412\u0438\u043d\u0442\u0435\u0440\u0441\u0430<\/li>\n<li>\u041a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u0430\u0445, \u043f\u043e\u0434\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/li>\n<\/ul>\n<\/li>\n<li>\u042d\u043a\u043e\u043d\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434<br \/> \n<ul>\n<li>\u0421\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c, \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u0440\u043d\u0438<\/li>\n<li>\u0418\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u043d\u0435\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u0442\u0440\u043e\u0438\u043c SARIMA<\/li>\n<\/ul>\n<\/li>\n<li>\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u0430\u0445<br \/> \n<ul>\n<li>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 (Feature extraction)<\/li>\n<li>\u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f vs XGBoost<\/li>\n<\/ul>\n<\/li>\n<li>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/li>\n<\/ol>\n<p>  <\/p>\n<h2 id=\"vvedenie\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435 \u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0441\u044c \u0441 \u0442\u0435\u043c\u0438 \u0438\u043b\u0438 \u0438\u043d\u044b\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u0430 \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0432 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439 \u0434\u0435\u043d\u044c\/\u043d\u0435\u0434\u0435\u043b\u044e\/\u043c\u0435\u0441\u044f\u0446\/\u043f\u0440. \u2014 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u043d\u043b\u0430\u0439\u043d\u0430, \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041a \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u043e\u0433\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u043d\u043e\u0437, \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0435\u0433\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c, \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u0430\u043a \u0434\u043e\u043b\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f. <\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0445, \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0439 \u0438 \u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0439.<\/p>\n<p>  <\/p>\n<h1 id=\"dvizhemsya-sglazhivaem-i-ocenivaem\">\u0414\u0432\u0438\u0436\u0435\u043c\u0441\u044f, \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u0435\u043c \u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c<\/h1>\n<p>  <\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439_\u0440\u044f\u0434\">\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/a> \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430:<\/p>\n<p>  <\/p>\n<blockquote><p><em>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434<\/em> \u2013 \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u043e\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043e\u0431\u044b\u0447\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u0438<\/p><\/blockquote>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u044b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0438, \u0437\u043d\u0430\u0447\u0438\u0442, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u044b\u0431\u043e\u0440\u043e\u043a, \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u044c. <\/p>\n<p>  <\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"http:\/\/statsmodels.sourceforge.net\/stable\/\">statsmodels<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432. \u0414\u043b\u044f \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u043e\u0432 R, \u043f\u0435\u0440\u0435\u0441\u0435\u0432\u0448\u0438\u0445 \u043d\u0430 \u043f\u0438\u0442\u043e\u043d, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0440\u043e\u0434\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u0441\u0442\u0438\u043b\u0435 &#8216;Wage ~ Age + Education&#8217;. <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import sys import warnings warnings.filterwarnings('ignore') from tqdm import tqdm  import pandas as pd import numpy as np from sklearn.metrics import mean_absolute_error, mean_squared_error  import statsmodels.formula.api as smf import statsmodels.tsa.api as smt import statsmodels.api as sm import scipy.stats as scs from scipy.optimize import minimize  import matplotlib.pyplot as plt<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u043c\u0443 \u043e\u043d\u043b\u0430\u0439\u043d\u0443 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0438\u0433\u0440\u0443\u0448\u0435\u043a:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/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 init_notebook_mode(connected = True)  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)  dataset = pd.read_csv('hour_online.csv', index_col=['Time'], parse_dates=['Time']) plotly_df(dataset, title = &quot;Online users&quot;)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/6d5\/ca9\/91f\/6d5ca991f01445178a9c61a3b901f069.png\"\/>  <\/p>\n<h2 id=\"rolling-window-estimations\">Rolling window estimations<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043d\u0430\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2014 &quot;\u0437\u0430\u0432\u0442\u0440\u0430 \u0431\u0443\u0434\u0435\u0442, \u043a\u0430\u043a \u0432\u0447\u0435\u0440\u0430&quot;, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5b8\/b7e\/524\/5b8b7e5243e1fa66280da49e86bbbcfb.svg\" alt=\"$\\hat{y}_{t} = y_{t-1}$\" data-tex=\"inline\"\/><\/math> \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u0443\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/17e\/d16\/be1\/17ed16be17023e4cd19584781c333593.svg\" alt=\"$n$\" data-tex=\"inline\"\/><\/math> \u0435\u0451 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <strong>\u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439<\/strong>. <\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4f5\/3f4\/929\/4f53f492986aa421d428e7b792433dab.svg\" alt=\"$\\hat{y}_{t} = \\frac{1}{k} \\displaystyle\\sum^{k-1}_{n=0} y_{t-n}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u044d\u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043f\u0438\u0442\u043e\u043d\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043f\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u043c\u0443 \u0434\u043d\u044e (24 \u0447\u0430\u0441\u0430)<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def moving_average(series, n):     return np.average(series[-n:])  moving_average(dataset.Users, 24)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Out: 29858.333333333332<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0434\u043e\u043b\u0433\u043e\u0441\u0440\u043e\u0447\u043d\u044b\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u2014 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u0430 \u0448\u0430\u0433 \u0432\u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u043e\u0439. \u0417\u0430\u0442\u043e \u0443 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u2014 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u043d\u0434\u043e\u0432. \u0412 \u043f\u0430\u043d\u0434\u0430\u0441\u0435 \u0435\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u2014 <a href=\"http:\/\/pandas.pydata.org\/pandas-docs\/stable\/generated\/pandas.DataFrame.rolling.html\"><code>DataFrame.rolling(window).mean()<\/code><\/a>. \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0448\u0438\u0440\u0438\u043d\u0443 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u2014 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u0433\u043b\u0430\u0436\u0435\u043d\u043d\u044b\u043c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0442\u0440\u0435\u043d\u0434. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u044b, \u0447\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u0445, \u0442\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043e\u0431\u0449\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u044f\u0434\u0430 \u0442\u0440\u0435\u043d\u0434\u044b \u0438 \u0442\u0430\u043a \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b, \u043d\u043e \u0435\u0441\u043b\u0438 \u0441\u0433\u043b\u0430\u0434\u0438\u0442\u044c \u043f\u043e \u0434\u043d\u044f\u043c, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0435 \u0432\u0438\u0434\u043d\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0430 \u043e\u043d\u043b\u0430\u0439\u043d\u0430 \u043f\u043e \u0431\u0443\u0434\u043d\u044f\u043c \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u043c (\u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u2014 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c), \u0430 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u043e\u0431\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0440\u0435\u0437\u043a\u0438\u043c \u0440\u043e\u0441\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u0432 \u0444\u0435\u0432\u0440\u0430\u043b\u0435 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u0432 \u043c\u0430\u0440\u0442\u0435.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def plotMovingAverage(series, n):      &quot;&quot;&quot;     series - dataframe with timeseries     n - rolling window size       &quot;&quot;&quot;      rolling_mean = series.rolling(window=n).mean()      # \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0434\u043b\u044f \u0441\u0433\u043b\u0430\u0436\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439     #rolling_std =  series.rolling(window=n).std()     #upper_bond = rolling_mean+1.96*rolling_std     #lower_bond = rolling_mean-1.96*rolling_std      plt.figure(figsize=(15,5))     plt.title(&quot;Moving average\\n window size = {}&quot;.format(n))     plt.plot(rolling_mean, &quot;g&quot;, label=&quot;Rolling mean trend&quot;)      #plt.plot(upper_bond, &quot;r--&quot;, label=&quot;Upper Bond \/ Lower Bond&quot;)     #plt.plot(lower_bond, &quot;r--&quot;)     plt.plot(dataset[n:], label=&quot;Actual values&quot;)     plt.legend(loc=&quot;upper left&quot;)     plt.grid(True)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"python\">plotMovingAverage(dataset, 24) # \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u0435\u043c \u043f\u043e \u0434\u043d\u044f\u043c plotMovingAverage(dataset, 24*7) # \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u0435\u043c \u043f\u043e \u043d\u0435\u0434\u0435\u043b\u044f\u043c<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/3e2\/004\/3b6\/3e20043b67d540d0af26c90777c0b230.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b94\/839\/0e0\/b948390e05854780a2249e95a0d7cccd.png\"\/>  <\/p>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <strong>\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f<\/strong>, \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c \u043f\u0440\u0438\u0434\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0435\u0441\u0430, \u0432 \u0441\u0443\u043c\u043c\u0435 \u0434\u0430\u044e\u0449\u0438\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u0443, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0432\u0435\u0441. <\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/71d\/8bb\/c91\/71d8bbc91095f6bb775e3b64ee3b7937.svg\" alt=\"$\\hat{y}_{t} = \\displaystyle\\sum^{k}_{n=1} \\omega_n y_{t+1-n}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def weighted_average(series, weights):     result = 0.0     weights.reverse()     for n in range(len(weights)):         result += series[-n-1] * weights[n]     return result  weighted_average(dataset.Users, [0.6, 0.2, 0.1, 0.07, 0.03])<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Out: 35967.550000000003<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"eksponencialnoe-sglazhivanie-model-holta-vintersa\">\u042d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435, \u043c\u043e\u0434\u0435\u043b\u044c \u0425\u043e\u043b\u044c\u0442\u0430-\u0412\u0438\u043d\u0442\u0435\u0440\u0441\u0430<\/h2>\n<p>  <\/p>\n<h3 id=\"prostoe-eksponencialnoe-sglazhivanie\">\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442, \u0435\u0441\u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u0437\u0432\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 $n$ \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0440\u044f\u0434\u0430 \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u0432\u0437\u0432\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u0432\u0435\u0441\u0430 \u043f\u043e \u043c\u0435\u0440\u0435 \u0443\u0433\u043b\u0443\u0431\u043b\u0435\u043d\u0438\u044f \u0432 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0444\u043e\u0440\u043c\u0443\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e <a href=\"http:\/\/www.machinelearning.ru\/wiki\/index.php?title=\u042d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435_\u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435\">\u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f<\/a>:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/19a\/2ad\/f08\/19a2adf08116c55732d3c8ccc8b03599.svg\" alt=\"$\\hat{y}_{t} = \\alpha \\cdot y_t + (1-\\alpha) \\cdot \\hat y_{t-1}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0443\u044e \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c \u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u0412\u0435\u0441 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8bb\/e73\/0e9\/8bbe730e90adaf07435b47deee6a1b38.svg\" alt=\"$\\alpha$\" data-tex=\"inline\"\/><\/math> \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u043c \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u043c. \u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c &quot;\u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c&quot; \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435. \u0427\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8bb\/e73\/0e9\/8bbe730e90adaf07435b47deee6a1b38.svg\" alt=\"$\\alpha$\" data-tex=\"inline\"\/><\/math>, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0438 \u0442\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u044f\u0434. <\/p>\n<p>  <\/p>\n<p>\u042d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1e5\/717\/6fb\/1e57176fbbfa63862a117e7390dac5dc.svg\" alt=\"$(1-\\alpha)$\" data-tex=\"inline\"\/><\/math> \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u043e \u0432 \u0441\u0435\u0431\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1e5\/717\/6fb\/1e57176fbbfa63862a117e7390dac5dc.svg\" alt=\"$(1-\\alpha)$\" data-tex=\"inline\"\/><\/math>, \u0438 \u0442\u0430\u043a \u0434\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def exponential_smoothing(series, alpha):     result = [series[0]] # first value is same as series     for n in range(1, len(series)):         result.append(alpha * series[n] + (1 - alpha) * result[n-1])     return result<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">with plt.style.context('seaborn-white'):         plt.figure(figsize=(20, 8))     for alpha in [0.3, 0.05]:         plt.plot(exponential_smoothing(dataset.Users, alpha), label=&quot;Alpha {}&quot;.format(alpha))     plt.plot(dataset.Users.values, &quot;c&quot;, label = &quot;Actual&quot;)     plt.legend(loc=&quot;best&quot;)     plt.axis('tight')     plt.title(&quot;Exponential Smoothing&quot;)     plt.grid(True)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/485\/0b1\/b90\/4850b1b90baf4674aeab0c2a08a26306.png\"\/>  <\/p>\n<h3 id=\"dvoynoe-eksponencialnoe-sglazhivanie\">\u0414\u0432\u043e\u0439\u043d\u043e\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u0414\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442 \u043d\u0430\u0448\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u043b\u0443\u0447\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043b\u0438\u0448\u044c \u043d\u0430 \u043e\u0434\u043d\u0443 \u0442\u043e\u0447\u043a\u0443 \u0432\u043f\u0435\u0440\u0451\u0434 (\u0438 \u0435\u0449\u0451 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0441\u0433\u043b\u0430\u0434\u0438\u0442\u044c \u0440\u044f\u0434), \u044d\u0442\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044e \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0434\u0432\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u043f\u0435\u0440\u0435\u0434 (\u0438 \u0442\u043e\u0436\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u0440\u044f\u0434).<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u0440\u044f\u0434\u0430 \u043d\u0430 \u0434\u0432\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u2014 \u0443\u0440\u043e\u0432\u0435\u043d\u044c (level, intercept) <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1f4\/690\/9a1\/1f46909a1e747ff58f4935981c50a941.svg\" alt=\"$\\ell$\" data-tex=\"inline\"\/><\/math> \u0438 \u0442\u0440\u0435\u043d\u0434 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5d2\/218\/e72\/5d2218e7292f24a1ff72a7ba614d11e9.svg\" alt=\"$b$\" data-tex=\"inline\"\/><\/math> (trend, slope). \u0423\u0440\u043e\u0432\u0435\u043d\u044c, \u0438\u043b\u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u044f\u0434\u0430, \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u0442\u0440\u0435\u043d\u0434\u0443, \u043d\u0430\u0438\u0432\u043d\u043e \u0438\u043b\u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0430\u0433\u0430\u044f, \u0447\u0442\u043e \u0431\u0443\u0434\u0443\u0449\u0435\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u044f\u0434\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9fc\/13c\/fa4\/9fc13cfa4f475bd06eef12d6767636ec.svg\" alt=\"$ \\ell_x = \\alpha y_x + (1-\\alpha)(\\ell_{x-1} + b_{x-1})\\\\ b_x = \\beta(\\ell_x - \\ell_{x-1}) + (1-\\beta)b_{x-1}\\\\ \\hat{y}_{x+1} = \\ell_x + b_x $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041f\u0435\u0440\u0432\u0430\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u2014 \u043e\u043d, \u043a\u0430\u043a \u0438 \u043f\u0440\u0435\u0436\u0434\u0435, \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u044f\u0434\u0430, \u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u0438 \u0442\u0440\u0435\u043d\u0434\u0430. \u0412\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0442\u0440\u0435\u043d\u0434 \u2014 \u043e\u043d \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0443\u0440\u043e\u0432\u043d\u044f \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435, \u0438 \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u043d\u0434\u0430. \u0417\u0434\u0435\u0441\u044c \u0432 \u0440\u043e\u043b\u0438 \u0432\u0435\u0441\u0430 \u0432 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0438 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f39\/05b\/5cf\/f3905b5cfab08d98b2d380d5ea75c66c.svg\" alt=\"$\\beta$\" data-tex=\"inline\"\/><\/math>. \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0443\u043c\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0443\u0440\u043e\u0432\u043d\u044f \u0438 \u0442\u0440\u0435\u043d\u0434\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def double_exponential_smoothing(series, alpha, beta):     result = [series[0]]     for n in range(1, len(series)+1):         if n == 1:             level, trend = series[0], series[1] - series[0]         if n &gt;= len(series): # \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c             value = result[-1]         else:             value = series[n]         last_level, level = level, alpha*value + (1-alpha)*(level+trend)         trend = beta*(level-last_level) + (1-beta)*trend         result.append(level+trend)     return result<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">with plt.style.context('seaborn-white'):         plt.figure(figsize=(20, 8))     for alpha in [0.9, 0.02]:         for beta in [0.9, 0.02]:             plt.plot(double_exponential_smoothing(dataset.Users, alpha, beta), label=&quot;Alpha {}, beta {}&quot;.format(alpha, beta))     plt.plot(dataset.Users.values, label = &quot;Actual&quot;)     plt.legend(loc=&quot;best&quot;)     plt.axis('tight')     plt.title(&quot;Double Exponential Smoothing&quot;)     plt.grid(True)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c47\/eb0\/262\/c47eb0262b90465c88151194624cb20f.png\"\/>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0443\u0436\u0435 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u2014 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8bb\/e73\/0e9\/8bbe730e90adaf07435b47deee6a1b38.svg\" alt=\"$\\alpha$\" data-tex=\"inline\"\/><\/math> \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f39\/05b\/5cf\/f3905b5cfab08d98b2d380d5ea75c66c.svg\" alt=\"$\\beta$\" data-tex=\"inline\"\/><\/math>. \u041f\u0435\u0440\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0440\u044f\u0434\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u0442\u0440\u0435\u043d\u0434\u0430, \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u0437\u0430 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0434\u0430. \u0427\u0435\u043c \u0432\u044b\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0432\u0435\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c \u0438 \u0442\u0435\u043c \u043c\u0435\u043d\u0435\u0435 \u0441\u0433\u043b\u0430\u0436\u0435\u043d\u043d\u044b\u043c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u044f\u0434. \u041a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u0447\u0443\u0434\u043b\u0438\u0432\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0440\u0443\u043a\u0430\u043c\u0438. \u0410 \u043e \u043d\u0435 \u0440\u0443\u0447\u043d\u043e\u043c \u043f\u043e\u0434\u0431\u043e\u0440\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435, \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0442\u0440\u043e\u0439\u043d\u043e\u0433\u043e \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<h3 id=\"troynoe-eksponencialnoe-sglazhivanie-aka-holt-winters\">\u0422\u0440\u043e\u0439\u043d\u043e\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 a.k.a. Holt-Winters<\/h3>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0434\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f, \u043d\u0430 \u0441\u0435\u0439 \u0440\u0430\u0437 \u0442\u0440\u043e\u0439\u043d\u043e\u0433\u043e.<\/p>\n<p>  <\/p>\n<p>\u0418\u0434\u0435\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0439, \u0442\u0440\u0435\u0442\u044c\u0435\u0439, \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u2014 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0440\u044f\u0434 \u044d\u0442\u043e\u0439 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435 \u043e\u0431\u0434\u0435\u043b\u0451\u043d, \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0435\u0440\u043d\u043e. \u0421\u0435\u0437\u043e\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u043a\u043e\u043b\u0435\u0431\u0430\u043d\u0438\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u0443\u0440\u043e\u0432\u043d\u044f \u0438 \u0442\u0440\u0435\u043d\u0434\u0430, \u0430 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u0438\u043d\u043e\u0439 \u0441\u0435\u0437\u043e\u043d\u0430 \u2014 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0435\u0431\u0430\u043d\u0438\u0439. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0437\u043e\u043d\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 \u0441\u0435\u0437\u043e\u043d\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 7 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c), \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c 7 \u0441\u0435\u0437\u043e\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043f\u043e \u0448\u0442\u0443\u043a\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0434\u043d\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/506\/e73\/88f\/506e7388fa05aa5f0a4beed3b91be622.svg\" alt=\"$ \\ell_x = \\alpha(y_x - s_{x-L}) + (1-\\alpha)(\\ell_{x-1} + b_{x-1})\\\\ b_x = \\beta(\\ell_x - \\ell_{x-1}) + (1-\\beta)b_{x-1}\\\\ s_x = \\gamma(y_x - \\ell_x) + (1-\\gamma)s_{x-L}\\\\ \\hat{y}_{x+m} = \\ell_x + mb_x + s_{x-L+1+(m-1)modL} $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u044f\u0434\u0430 \u0437\u0430 \u0432\u044b\u0447\u0435\u0442\u043e\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0442\u0440\u0435\u043d\u0434 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0430 \u0441\u0435\u0437\u043e\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u044f\u0434\u0430 \u0437\u0430 \u0432\u044b\u0447\u0435\u0442\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u044f \u0438 \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0441\u0435\u0437\u043e\u043d\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0430\u044f \u0437\u0430 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a, \u0442\u043e \u0438 \u0443\u0441\u0440\u0435\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a\u0430\u043c\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u0438\u0439 \u0438 \u043e\u0446\u0435\u043d\u043a\u0443 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0442\u0440\u0435\u043d\u0434\u0430 \u0438 \u0441\u0435\u0437\u043e\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/www.itl.nist.gov\/div898\/handbook\/pmc\/section4\/pmc435.htm\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u043c\u0435\u044f \u0441\u0435\u0437\u043e\u043d\u043d\u0443\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0435 \u043d\u0430 \u043e\u0434\u0438\u043d, \u0438 \u0434\u0430\u0436\u0435 \u043d\u0435 \u043d\u0430 \u0434\u0432\u0430, \u0430 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 $m$ \u0448\u0430\u0433\u043e\u0432 \u0432\u043f\u0435\u0440\u0451\u0434, \u0447\u0442\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0440\u0430\u0434\u043e\u0432\u0430\u0442\u044c. <\/p>\n<p>  <\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0440\u043e\u0439\u043d\u043e\u0433\u043e \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u043f\u043e \u0444\u0430\u043c\u0438\u043b\u0438\u044f\u043c \u0435\u0451 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 \u2014 \u0427\u0430\u0440\u043b\u044c\u0437\u0430 \u0425\u043e\u043b\u044c\u0442\u0430 \u0438 \u0435\u0433\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430 \u041f\u0438\u0442\u0435\u0440\u0430 \u0412\u0438\u043d\u0442\u0435\u0440\u0441\u0430.<br \/>  \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u043c\u0435\u0442\u043e\u0434 \u0411\u0440\u0443\u0442\u043b\u0430\u0433\u0430 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432:<\/p>\n<p>  <\/p>\n<p><math>$$display$$ \\hat y_{max_x}=\\ell_{x\u22121}+b_{x\u22121}+s_{x\u2212T}+m\u22c5d_{t\u2212T}\\\\ \\hat y_{min_x}=\\ell_{x\u22121}+b_{x\u22121}+s_{x\u2212T}-m\u22c5d_{t\u2212T}\\\\ d_t=\\gamma\u2223y_t\u2212\\hat y_t\u2223+(1\u2212\\gamma)d_{t\u2212T}, $$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0433\u0434\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d6e\/fa6\/3e8\/d6efa63e85f9db56a07a7dec46768de8.svg\" alt=\"$T$\" data-tex=\"inline\"\/><\/math> \u2014 \u0434\u043b\u0438\u043d\u0430 \u0441\u0435\u0437\u043e\u043d\u0430, <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b59\/99c\/bd8\/b5999cbd87881cf38f84f9b0b73a8284.svg\" alt=\"$d$\" data-tex=\"inline\"\/><\/math> \u2014 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0437 \u0442\u0440\u043e\u0439\u043d\u043e\u0433\u043e \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043c\u0435\u0442\u043e\u0434\u0435 \u0438 \u043e \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a \u043f\u043e\u0438\u0441\u043a\u0443 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c <a href=\"https:\/\/fedcsis.org\/proceedings\/2012\/pliks\/118.pdf\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0425\u043e\u043b\u044c\u0442\u0430-\u0412\u0438\u043d\u0442\u0435\u0440\u0441\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">class HoltWinters:      &quot;&quot;&quot;     \u041c\u043e\u0434\u0435\u043b\u044c \u0425\u043e\u043b\u044c\u0442\u0430-\u0412\u0438\u043d\u0442\u0435\u0440\u0441\u0430 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0411\u0440\u0443\u0442\u043b\u0430\u0433\u0430 \u0434\u043b\u044f \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439     https:\/\/fedcsis.org\/proceedings\/2012\/pliks\/118.pdf      # series - \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434     # slen - \u0434\u043b\u0438\u043d\u0430 \u0441\u0435\u0437\u043e\u043d\u0430     # alpha, beta, gamma - \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u0425\u043e\u043b\u044c\u0442\u0430-\u0412\u0438\u043d\u0442\u0435\u0440\u0441\u0430     # n_preds - \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439     # scaling_factor - \u0437\u0430\u0434\u0430\u0451\u0442 \u0448\u0438\u0440\u0438\u043d\u0443 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u043f\u043e \u0411\u0440\u0443\u0442\u043b\u0430\u0433\u0443 (\u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 2 \u0434\u043e 3)      &quot;&quot;&quot;      def __init__(self, series, slen, alpha, beta, gamma, n_preds, scaling_factor=1.96):         self.series = series         self.slen = slen         self.alpha = alpha         self.beta = beta         self.gamma = gamma         self.n_preds = n_preds         self.scaling_factor = scaling_factor      def initial_trend(self):         sum = 0.0         for i in range(self.slen):             sum += float(self.series[i+self.slen] - self.series[i]) \/ self.slen         return sum \/ self.slen        def initial_seasonal_components(self):         seasonals = {}         season_averages = []         n_seasons = int(len(self.series)\/self.slen)         # \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u0435\u0437\u043e\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0435         for j in range(n_seasons):             season_averages.append(sum(self.series[self.slen*j:self.slen*j+self.slen])\/float(self.slen))         # \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f         for i in range(self.slen):             sum_of_vals_over_avg = 0.0             for j in range(n_seasons):                 sum_of_vals_over_avg += self.series[self.slen*j+i]-season_averages[j]             seasonals[i] = sum_of_vals_over_avg\/n_seasons         return seasonals         def triple_exponential_smoothing(self):         self.result = []         self.Smooth = []         self.Season = []         self.Trend = []         self.PredictedDeviation = []         self.UpperBond = []         self.LowerBond = []          seasonals = self.initial_seasonal_components()          for i in range(len(self.series)+self.n_preds):             if i == 0: # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442                 smooth = self.series[0]                 trend = self.initial_trend()                 self.result.append(self.series[0])                 self.Smooth.append(smooth)                 self.Trend.append(trend)                 self.Season.append(seasonals[i%self.slen])                  self.PredictedDeviation.append(0)                  self.UpperBond.append(self.result[0] +                                        self.scaling_factor *                                        self.PredictedDeviation[0])                  self.LowerBond.append(self.result[0] -                                        self.scaling_factor *                                        self.PredictedDeviation[0])                  continue             if i &gt;= len(self.series): # \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c                 m = i - len(self.series) + 1                 self.result.append((smooth + m*trend) + seasonals[i%self.slen])                  # \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c                 self.PredictedDeviation.append(self.PredictedDeviation[-1]*1.01)               else:                 val = self.series[i]                 last_smooth, smooth = smooth, self.alpha*(val-seasonals[i%self.slen]) + (1-self.alpha)*(smooth+trend)                 trend = self.beta * (smooth-last_smooth) + (1-self.beta)*trend                 seasonals[i%self.slen] = self.gamma*(val-smooth) + (1-self.gamma)*seasonals[i%self.slen]                 self.result.append(smooth+trend+seasonals[i%self.slen])                  # \u041e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u0411\u0440\u0443\u0442\u043b\u0430\u0433\u0430                 self.PredictedDeviation.append(self.gamma * np.abs(self.series[i] - self.result[i])                                                 + (1-self.gamma)*self.PredictedDeviation[-1])              self.UpperBond.append(self.result[-1] +                                    self.scaling_factor *                                    self.PredictedDeviation[-1])              self.LowerBond.append(self.result[-1] -                                    self.scaling_factor *                                    self.PredictedDeviation[-1])              self.Smooth.append(smooth)             self.Trend.append(trend)             self.Season.append(seasonals[i % self.slen])<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2 id=\"kross-validaciya-na-vremennyh-ryadah-podbor-parametrov\">\u041a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u0430\u0445, \u043f\u043e\u0434\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043e \u043d\u0435 \u0440\u0443\u0447\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439. <\/p>\n<p>  <\/p>\n<p>\u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442, \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0443\u044e\u044e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c: <a href=\"https:\/\/en.wikipedia.org\/wiki\/Root-mean-square_deviation\">RMSE<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mean_absolute_error\">MAE<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mean_absolute_percentage_error\">MAPE<\/a> \u0438 \u0434\u0440., \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0434\u0433\u043e\u043d\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0434 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0417\u0430\u0442\u0435\u043c \u0431\u0443\u0434\u0435\u043c \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u043f\u0440\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438\u0441\u043a\u0430\u0442\u044c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442, \u043c\u0435\u043d\u044f\u0442\u044c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043d\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u0431\u043e\u0434\u0440\u043e \u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430 \u043e\u0448\u0438\u0431\u043a\u0438. <\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0437\u0430\u0433\u0432\u043e\u0437\u0434\u043a\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434 \u0438\u043c\u0435\u0435\u0442, \u043a\u0430\u043a \u043d\u0438 \u043f\u0430\u0440\u0430\u0434\u043e\u043a\u0441\u0430\u043b\u044c\u043d\u043e, \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0432 \u0444\u043e\u043b\u0434\u0430\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u0440\u044f\u0434\u0430 \u0431\u0435\u0437 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043d\u0435\u043b\u044c\u0437\u044f, \u0438\u043d\u0430\u0447\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0445\u0438\u0442\u0440\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u044f \u0442\u0430\u043a \u0438 \u043d\u0435 \u043d\u0430\u0448\u0435\u043b, \u043d\u043e \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 <a href=\"https:\/\/stats.stackexchange.com\/questions\/14099\/using-k-fold-cross-validation-for-time-series-model-selection\">CrossValidated<\/a>, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0432\u0441\u0451, \u043a\u0440\u043e\u043c\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u0416\u0438\u0437\u043d\u0438, \u0412\u0441\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0438 \u0412\u0441\u0435\u0433\u043e \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 &quot;cross-validation on a rolling basis&quot;, \u0447\u0442\u043e \u043d\u0435 \u0434\u043e\u0441\u043b\u043e\u0432\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043a\u0430\u043a \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u043c \u043e\u043a\u043d\u0435.<\/p>\n<p>  <\/p>\n<p>\u0421\u0443\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430 \u2014 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043e\u0431\u0443\u0447\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043e\u0442\u0440\u0435\u0437\u043a\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430, \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9b6\/547\/e8d\/9b6547e8d3f9c2d6f92fbc781ac55660.svg\" alt=\"$t$\" data-tex=\"inline\"\/><\/math>, \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/26f\/0db\/851\/26f0db8513cd2e8711a414e8f7cb98f1.svg\" alt=\"$t+n$\" data-tex=\"inline\"\/><\/math> \u0448\u0430\u0433\u043e\u0432 \u0432\u043f\u0435\u0440\u0435\u0434 \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443. \u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0434\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/26f\/0db\/851\/26f0db8513cd2e8711a414e8f7cb98f1.svg\" alt=\"$t+n$\" data-tex=\"inline\"\/><\/math> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c \u0441 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/26f\/0db\/851\/26f0db8513cd2e8711a414e8f7cb98f1.svg\" alt=\"$t+n$\" data-tex=\"inline\"\/><\/math> \u0434\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f2e\/fe0\/20b\/f2efe020b68541ece98dad0973ac993d.svg\" alt=\"$t+2*n$\" data-tex=\"inline\"\/><\/math>, \u0442\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0434\u0432\u0438\u0433\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043e\u0442\u0440\u0435\u0437\u043e\u043a \u0440\u044f\u0434\u0430 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0443\u043f\u0440\u0451\u043c\u0441\u044f \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0444\u043e\u043b\u0434\u043e\u0432, \u0441\u043a\u043e\u043b\u044c\u043a\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/17e\/d16\/be1\/17ed16be17023e4cd19584781c333593.svg\" alt=\"$n$\" data-tex=\"inline\"\/><\/math> \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u043c\u0435\u0436\u0434\u0443 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u043c \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u043c \u0438 \u0432\u0441\u0435\u0439 \u0434\u043b\u0438\u043d\u043e\u0439 \u0440\u044f\u0434\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f5c\/7cd\/b39\/f5c7cdb39ccd4ba68378ca232d20d864.png\"\/>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0440\u044f\u0434\u0443<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from sklearn.model_selection import TimeSeriesSplit  def timeseriesCVscore(x):     # \u0432\u0435\u043a\u0442\u043e\u0440 \u043e\u0448\u0438\u0431\u043e\u043a     errors = []      values = data.values     alpha, beta, gamma = x      # \u0437\u0430\u0434\u0430\u0451\u043c \u0447\u0438\u0441\u043b\u043e \u0444\u043e\u043b\u0434\u043e\u0432 \u0434\u043b\u044f \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438     tscv = TimeSeriesSplit(n_splits=3)       # \u0438\u0434\u0435\u043c \u043f\u043e \u0444\u043e\u043b\u0434\u0430\u043c, \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u0441\u0442\u0440\u043e\u0438\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443     for train, test in tscv.split(values):          model = HoltWinters(series=values[train], slen = 24*7, alpha=alpha, beta=beta, gamma=gamma, n_preds=len(test))         model.triple_exponential_smoothing()          predictions = model.result[-len(test):]         actual = values[test]         error = mean_squared_error(predictions, actual)         errors.append(error)      # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0443 \u043e\u0448\u0438\u0431\u043e\u043a      return np.mean(np.array(errors))<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0441\u0435\u0437\u043e\u043d\u0430 24*7 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u2014 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0440\u044f\u0434\u0435 \u043e\u0442\u0447\u0435\u0442\u043b\u0438\u0432\u043e \u0432\u0438\u0434\u043d\u0430 \u0434\u043d\u0435\u0432\u043d\u0430\u044f \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c, (\u043e\u0442\u0441\u044e\u0434\u0430 24), \u0438 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u2014 \u043f\u043e \u0431\u0443\u0434\u043d\u044f\u043c \u043d\u0438\u0436\u0435, \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u2014 \u0432\u044b\u0448\u0435, (\u043e\u0442\u0441\u044e\u0434\u0430 7), \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e \u0441\u0435\u0437\u043e\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f 24*7.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043c\u043e\u0434\u0435\u043b\u0438 \u0425\u043e\u043b\u044c\u0442\u0430-\u0412\u0438\u043d\u0442\u0435\u0440\u0441\u0430, \u043a\u0430\u043a \u0438 \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f, \u0435\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 0 \u0434\u043e 1, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 Truncated Newton conjugate gradient.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">%%time data = dataset.Users[:-500] # \u043e\u0442\u043b\u043e\u0436\u0438\u043c \u0447\u0430\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f  # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 x = [0, 0, 0]   # \u041c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b opt = minimize(timeseriesCVscore, x0=x, method=&quot;TNC&quot;, bounds = ((0, 1), (0, 1), (0, 1)))  # \u0418\u0437 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0431\u0435\u0440\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 alpha_final, beta_final, gamma_final = opt.x print(alpha_final, beta_final, gamma_final)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Out: (0.0066342670643441681, 0.0, 0.046765204289672901)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8bb\/e73\/0e9\/8bbe730e90adaf07435b47deee6a1b38.svg\" alt=\"$\\alpha$\" data-tex=\"inline\"\/><\/math>, <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f39\/05b\/5cf\/f3905b5cfab08d98b2d380d5ea75c66c.svg\" alt=\"$\\beta$\" data-tex=\"inline\"\/><\/math> \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/27a\/7f7\/456\/27a7f745625a176ecd60ed7599231bf2.svg\" alt=\"$\\gamma$\" data-tex=\"inline\"\/><\/math> \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 5 \u0434\u043d\u0435\u0439 \u0432\u043f\u0435\u0440\u0451\u0434 (128 \u0447\u0430\u0441\u043e\u0432)<\/p>\n<p>  <\/p>\n<pre><code class=\"python\"># \u041f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438,  data = dataset.Users model = HoltWinters(data[:-128], slen = 24*7, alpha = alpha_final, beta = beta_final, gamma = gamma_final, n_preds = 128, scaling_factor = 2.56) model.triple_exponential_smoothing()<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def plotHoltWinters():     Anomalies = np.array([np.NaN]*len(data))     Anomalies[data.values&lt;model.LowerBond] = data.values[data.values&lt;model.LowerBond]     plt.figure(figsize=(25, 10))     plt.plot(model.result, label = &quot;Model&quot;)     plt.plot(model.UpperBond, &quot;r--&quot;, alpha=0.5, label = &quot;Up\/Low confidence&quot;)     plt.plot(model.LowerBond, &quot;r--&quot;, alpha=0.5)     plt.fill_between(x=range(0,len(model.result)), y1=model.UpperBond, y2=model.LowerBond, alpha=0.5, color = &quot;grey&quot;)     plt.plot(data.values, label = &quot;Actual&quot;)     plt.plot(Anomalies, &quot;o&quot;, markersize=10, label = &quot;Anomalies&quot;)     plt.axvspan(len(data)-128, len(data), alpha=0.5, color='lightgrey')     plt.grid(True)     plt.axis('tight')     plt.legend(loc=&quot;best&quot;, fontsize=13);  plotHoltWinters()<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/259\/db7\/042\/259db7042a6d4bd7b48960cb7a89ef9e.png\"\/>  <\/p>\n<p>\u0421\u0443\u0434\u044f \u043f\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0443, \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043e\u043f\u0438\u0441\u0430\u043b\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434, \u0443\u043b\u043e\u0432\u0438\u0432 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0438 \u0434\u043d\u0435\u0432\u043d\u0443\u044e \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u0438 \u0434\u0430\u0436\u0435 \u0441\u043c\u043e\u0433\u043b\u0430 \u043f\u043e\u0439\u043c\u0430\u0442\u044c \u0430\u043d\u043e\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f, \u0432\u044b\u0448\u0435\u0434\u0448\u0438\u0435 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435, \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0435\u0437\u043a\u043e \u0440\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0440\u044f\u0434\u0430, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e \u043a \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c, &quot;\u0437\u0430\u0431\u044b\u0432\u0430\u044f&quot; \u043f\u0440\u043e\u0448\u043b\u043e\u0435. \u0422\u0430\u043a\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0438 \u0431\u0435\u0437 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0442\u0440\u0430\u0442 \u043d\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0443-\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u043e \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439 \u0434\u0430\u0436\u0435 \u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0448\u0443\u043c\u043d\u044b\u0445 \u0440\u044f\u0434\u0430\u0445.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d93\/461\/61a\/d9346161a1d643188effd795c2bb65b6.png\"\/>  <\/p>\n<h1 id=\"ekonometricheskiy-podhod\">\u042d\u043a\u043e\u043d\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434<\/h1>\n<p>  <\/p>\n<h2 id=\"stacionarnost-edinichnye-korni\">\u0421\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c, \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u0440\u043d\u0438<\/h2>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e, \u0441\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u0430\u043a\u043e\u043c \u0432\u0430\u0436\u043d\u043e\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430, \u043a\u0430\u043a <a href=\"https:\/\/ru.wikipedia.org\/wiki\/\u0421\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c\"><strong>\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c<\/strong><\/a>.<br \/>  \u041f\u043e\u0434 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0435 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0438\u0445 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a \u0441 \u0442\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u0441\u0442\u0432\u043e \u043c\u0430\u0442\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f, \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u0441\u0442\u0432\u043e \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438 (\u043e\u043d\u0430 \u0436\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/\u0413\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c\">\u0433\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c<\/a>) \u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0432\u0430\u0440\u0438\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c\u0438). \u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u044d\u0442\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u0445, \u0432\u0437\u044f\u0442\u044b\u0445 \u0438\u0437 \u043f\u043e\u0441\u0442\u0430 <a href=\"http:\/\/www.seanabu.com\/2016\/03\/22\/time-series-seasonal-ARIMA-model-in-python\/\">Sean Abu<\/a>:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434 \u0441\u043f\u0440\u0430\u0432\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0433\u043e \u043c\u0430\u0442\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0440\u0430\u0441\u0442\u0451\u0442<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/20c\/9d8\/a63\/20c9d8a633ec436f91dccd4aedcc6940.png\"\/>  <\/p>\n<ul>\n<li>\u0417\u0434\u0435\u0441\u044c \u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0441 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0435\u0439 \u2014 \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0440\u044f\u0434\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0430\u0440\u044c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u0435\u0440\u0438\u043e\u0434\u0430<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b88\/eec\/a67\/b88eeca676d642449cab135273fd5a95.png\"\/>  <\/p>\n<ul>\n<li>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u044f\u0434\u0430 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0431\u043b\u0438\u0436\u0435 \u0434\u0440\u0443\u0433 \u043a\u043e \u0434\u0440\u0443\u0433\u0443, \u043e\u0431\u0440\u0430\u0437\u0443\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u043b\u0430\u0441\u0442\u0435\u0440, \u0430 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u0441\u0442\u0432\u043e \u043a\u043e\u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0439<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/2f6\/1ee\/cb2\/2f61eecb20714352840748b826e38680.png\"\/>  <\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u0430? \u041f\u043e \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u043c\u0443 \u0440\u044f\u0434\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u0435\u0433\u043e \u0431\u0443\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0445 \u0442\u0435\u043a\u0443\u0449\u0438\u0445. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u044e\u0442 \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u044d\u0442\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0430\u0442\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0438\u043b\u0438 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u043c\u0438. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b\u043c\u0438 \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432, \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f, \u043d\u043e \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e (\u0438 \u043d\u0443\u0436\u043d\u043e) \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c\u044e, \u043d\u0443\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0435\u0451 \u0432 \u043b\u0438\u0446\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0435\u0451 \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0431\u0435\u043b\u043e\u043c\u0443 \u0448\u0443\u043c\u0443 \u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c\u0443 \u0431\u043b\u0443\u0436\u0434\u0430\u043d\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c \u043a\u0430\u043a \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0435 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0438 \u0431\u0435\u0437 \u0441\u043c\u0441.<\/p>\n<p>  <\/p>\n<p>\u0413\u0440\u0430\u0444\u0438\u043a \u0431\u0435\u043b\u043e\u0433\u043e \u0448\u0443\u043c\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">white_noise = np.random.normal(size=1000) with plt.style.context('bmh'):       plt.figure(figsize=(15, 5))     plt.plot(white_noise)<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ef6\/a74\/fec\/ef6a74fec1434b05b31ad66c5b633cc0.png\"\/>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043f\u043e\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c, \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u0435\u043d, \u043a\u043e\u043b\u0435\u0431\u043b\u0435\u0442\u0441\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u043d\u0443\u043b\u044f \u0441 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435\u043c \u0432 1. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u0433\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c41\/40c\/0c4\/c4140c0c4a78627a38c4e2dce9d4e856.svg\" alt=\"$x_t = \\rho x_{t-1} + e_t$\" data-tex=\"inline\"\/><\/math><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def plotProcess(n_samples=1000, rho=0):     x = w = np.random.normal(size=n_samples)     for t in range(n_samples):         x[t] = rho * x[t-1] + w[t]      with plt.style.context('bmh'):           plt.figure(figsize=(10, 3))         plt.plot(x)         plt.title(&quot;Rho {}\\n Dickey-Fuller p-value: {}&quot;.format(rho, round(sm.tsa.stattools.adfuller(x)[1], 3)))  for rho in [0, 0.6, 0.9, 1]:     plotProcess(rho=rho)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b12\/1aa\/ba6\/b121aaba61b34e1087f56a0b7cf0c377.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/76b\/5fc\/4b7\/76b5fc4b760c4af18911be835c9ad35d.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c49\/1f2\/399\/c491f23996a2450c88b20e2d970f309a.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/599\/a58\/960\/599a589608f14951bbddf00b86a0a27c.png\"\/>  <\/p>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0439 \u0431\u0435\u043b\u044b\u0439 \u0448\u0443\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0440\u043e\u0438\u043b\u0441\u044f \u0440\u0430\u043d\u044c\u0448\u0435. \u041d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/634\/9ab\/78b\/6349ab78b770ddade060e646f0b61656.svg\" alt=\"$\\rho$\" data-tex=\"inline\"\/><\/math> \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u043e\u0441\u044c \u0434\u043e 0.6, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0441\u0442\u0430\u043b\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0446\u0438\u043a\u043b\u044b, \u043d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u043c \u043e\u043d \u0431\u044b\u0442\u044c \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b. \u0422\u0440\u0435\u0442\u0438\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u0432\u0441\u0451 \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043d\u043e \u0432\u0441\u0451 \u0435\u0449\u0451 \u043a\u043e\u043b\u0435\u0431\u043b\u0435\u0442\u0441\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u043d\u0435\u0433\u043e. \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/634\/9ab\/78b\/6349ab78b770ddade060e646f0b61656.svg\" alt=\"$\\rho$\" data-tex=\"inline\"\/><\/math> \u0440\u0430\u0432\u043d\u043e\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0434\u0430\u043b\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0431\u043b\u0443\u0436\u0434\u0430\u043d\u0438\u044f \u2014 \u0440\u044f\u0434 \u043d\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u0435\u043d.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u043e \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u0440\u044f\u0434 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c41\/40c\/0c4\/c4140c0c4a78627a38c4e2dce9d4e856.svg\" alt=\"$x_t = \\rho x_{t-1} + e_t$\" data-tex=\"inline\"\/><\/math> \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u0441\u0440\u0435\u0434\u043d\u0435\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e. \u0415\u0441\u043b\u0438 \u0432\u044b\u0447\u0435\u0441\u0442\u044c \u0438\u0437 \u043b\u0435\u0432\u043e\u0439 \u0438 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8c3\/30b\/a30\/8c330ba300d9cd8372666a5ba631a589.svg\" alt=\"$x_{t-1}$\" data-tex=\"inline\"\/><\/math>, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/00d\/9f2\/5e6\/00d9f25e62a9c3884ad81a029aa5f6ae.svg\" alt=\"$x_t - x_{t-1} = (\\rho - 1) x_{t-1} + e_t$\" data-tex=\"inline\"\/><\/math>, \u0433\u0434\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0432\u0430 \u2014 \u043f\u0435\u0440\u0432\u044b\u0435 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/790\/52c\/63e\/79052c63e038e59b4580a62b68a8c4ba.svg\" alt=\"$\\rho=1$\" data-tex=\"inline\"\/><\/math>, \u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u0434\u0443\u0442 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0439 \u0431\u0435\u043b\u044b\u0439 \u0448\u0443\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/183\/7e7\/f33\/1837e7f33a768dffe7e6b7d262df79e0.svg\" alt=\"$e_t$\" data-tex=\"inline\"\/><\/math>. \u042d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442 \u043b\u0451\u0433 \u0432 \u043e\u0441\u043d\u043e\u0432\u0443 \u0442\u0435\u0441\u0442\u0430 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/\u0422\u0435\u0441\u0442_\u0414\u0438\u043a\u0438_\u2014_\u0424\u0443\u043b\u043b\u0435\u0440\u0430\">\u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430<\/a> \u043d\u0430 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u0440\u044f\u0434\u0430 (\u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u043d\u044f). \u0415\u0441\u043b\u0438 \u0438\u0437 \u043d\u0435\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u043f\u0435\u0440\u0432\u044b\u043c\u0438 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0443\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0439, \u0442\u043e \u043e\u043d \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430. \u041d\u0443\u043b\u0435\u0432\u0430\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430 \u0442\u0435\u0441\u0442\u0430 \u2014 \u0440\u044f\u0434 \u043d\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u0435\u043d, \u043e\u0442\u0432\u0435\u0440\u0433\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0445 \u0442\u0440\u0435\u0445 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u0445, \u0438 \u043f\u0440\u0438\u043d\u044f\u043b\u0430\u0441\u044c \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c. \u0421\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0435\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c (\u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u0440\u043d\u0435\u0439), \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0439 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0430\u0433\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0411\u043e\u0440\u043e\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u2014 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0442\u0440\u0435\u043d\u0434\u0430 \u0438 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438, \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0411\u043e\u043a\u0441\u0430-\u041a\u043e\u043a\u0441\u0430 \u0438\u043b\u0438 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c.<\/p>\n<p>  <\/p>\n<h2 id=\"izbavlyaemsya-ot-nestacionarnosti-i-stroim-sarima\">\u0418\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u043d\u0435\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u0442\u0440\u043e\u0438\u043c SARIMA<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c ARIMA \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043e\u043d\u043b\u0430\u0439\u043d\u0430 \u0438\u0433\u0440\u043e\u043a\u043e\u0432, \u043f\u0440\u043e\u0439\u0434\u044f \u0432\u0441\u0435 <del>\u043a\u0440\u0443\u0433\u0438 \u0430\u0434\u0430<\/del> \u0441\u0442\u0430\u0434\u0438\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0440\u044f\u0434\u0430 \u043a \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443. \u041f\u0440\u043e \u0441\u0430\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0443\u0436\u0435 \u043d\u0435 \u0440\u0430\u0437 \u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u2014 <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>, <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>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0439 \u043d\u0435 \u0431\u0443\u0434\u0443.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def tsplot(y, lags=None, figsize=(12, 7), style='bmh'):     if not isinstance(y, pd.Series):         y = pd.Series(y)     with plt.style.context(style):             fig = plt.figure(figsize=figsize)         layout = (2, 2)         ts_ax = plt.subplot2grid(layout, (0, 0), colspan=2)         acf_ax = plt.subplot2grid(layout, (1, 0))         pacf_ax = plt.subplot2grid(layout, (1, 1))          y.plot(ax=ts_ax)         ts_ax.set_title('Time Series Analysis Plots')         smt.graphics.plot_acf(y, lags=lags, ax=acf_ax, alpha=0.5)         smt.graphics.plot_pacf(y, lags=lags, ax=pacf_ax, alpha=0.5)          print(&quot;\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430: p=%f&quot; % sm.tsa.stattools.adfuller(y)[1])          plt.tight_layout()     return   tsplot(dataset.Users, lags=30)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"python\">Out: \u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430: p=0.190189<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/3cd\/91f\/a88\/3cd91fa88d2244ab9ed28b6dd4556f9b.png\"\/>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c, \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0440\u044f\u0434 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u043c \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430 \u043d\u0435 \u043e\u0442\u0432\u0435\u0440\u0433 \u043d\u0443\u043b\u0435\u0432\u0443\u044e \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0443 \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u043d\u044f. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u0435\u043e\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0411\u043e\u043a\u0441\u0430-\u041a\u043e\u043a\u0441\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def invboxcox(y,lmbda):     # \u043e\u0431\u0440\u0430\u0431\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0411\u043e\u043a\u0441\u0430-\u041a\u043e\u043a\u0441\u0430     if lmbda == 0:         return(np.exp(y))     else:         return(np.exp(np.log(lmbda*y+1)\/lmbda))  data = dataset.copy() data['Users_box'], lmbda = scs.boxcox(data.Users+1) # \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0434\u0438\u043d\u0438\u0446\u0443, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0440\u044f\u0434\u0435 \u0435\u0441\u0442\u044c \u043d\u0443\u043b\u0438 tsplot(data.Users_box, lags=30) print(&quot;\u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0411\u043e\u043a\u0441\u0430-\u041a\u043e\u043a\u0441\u0430: %f&quot; % lmbda)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Out: \u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430: p=0.079760      \u041e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0411\u043e\u043a\u0441\u0430-\u041a\u043e\u043a\u0441\u0430: 0.587270<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ab2\/1c2\/bda\/ab21c2bda16e4e5184139c4d94ce76d4.png\"\/>  <\/p>\n<p>\u0423\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043d\u0435 \u043e\u0442\u0432\u0435\u0440\u0433\u0430\u0435\u0442 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0443 \u043e \u043d\u0435\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u0438 \u0440\u044f\u0434\u0430. \u0410 \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044f\u0432\u043d\u043e \u043d\u0430\u043c\u0435\u043a\u0430\u0435\u0442 \u043d\u0430 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u043c\u0441\u044f \u0440\u044f\u0434\u0435. \u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0441\u0435\u0437\u043e\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">data['Users_box_season'] = data.Users_box - data.Users_box.shift(24*7) tsplot(data.Users_box_season[24*7:], lags=30)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Out: \u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430: p=0.002571<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/00f\/0f3\/f0c\/00f0f3f0c7da4c33a66597165bac9a5a.png\"\/>  <\/p>\n<p>\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u0432\u0435\u0440\u0433\u0430\u0435\u0442 \u043d\u0443\u043b\u0435\u0432\u0443\u044e \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0443 \u043e \u043d\u0435\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0441\u0451 \u0435\u0449\u0451 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u0445\u043e\u0440\u043e\u0448\u043e \u0438\u0437-\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u043b\u0430\u0433\u043e\u0432. \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0447\u0430\u0441\u0442\u043d\u043e\u0439 \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0438\u043c \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u043b\u0430\u0433, \u0441\u0442\u043e\u0438\u0442 \u0432\u0437\u044f\u0442\u044c \u0435\u0449\u0435 \u043f\u0435\u0440\u0432\u044b\u0435 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0440\u044f\u0434 \u043a \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">data['Users_box_season_diff'] = data.Users_box_season - data.Users_box_season.shift(1) tsplot(data.Users_box_season_diff[24*7+1:], lags=30)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Out: \u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430: p=0.000000<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b37\/ba3\/2fc\/b37ba32fc1ce4b21946fff6eae07c454.png\"\/>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0439 \u0440\u044f\u0434, \u043f\u043e \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0438 \u0447\u0430\u0441\u0442\u043d\u043e\u0439 \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u043a\u0438\u043d\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f SARIMA \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0430 \u0437\u0430\u0431\u044b\u0432, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u0438 \u0441\u0435\u0437\u043e\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u044f Q = 1, P = 4, q = 3, p = 4<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">ps = range(0, 5) d=1 qs = range(0, 4) Ps = range(0, 5) D=1 Qs = range(0, 1)  from itertools import product  parameters = product(ps, qs, Ps, Qs) parameters_list = list(parameters) len(parameters_list)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Out: 100<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u043e\u043c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">%%time results = [] best_aic = float(&quot;inf&quot;)  for param in tqdm(parameters_list):     #try except \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f     try:         model=sm.tsa.statespace.SARIMAX(data.Users_box, order=(param[0], d, param[1]),                                          seasonal_order=(param[3], D, param[3], 24*7)).fit(disp=-1)     #\u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443     except ValueError:         print('wrong parameters:', param)         continue     aic = model.aic     #\u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043b\u0443\u0447\u0448\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, aic, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b     if aic &lt; best_aic:         best_model = model         best_aic = aic         best_param = param     results.append([param, model.aic])  warnings.filterwarnings('default')  result_table = pd.DataFrame(results) result_table.columns = ['parameters', 'aic'] print(result_table.sort_values(by = 'aic', ascending=True).head())<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u0433\u043e\u043d\u044f\u0435\u043c \u0432 \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">%%time best_model = sm.tsa.statespace.SARIMAX(data.Users_box, order=(4, d, 3),                                          seasonal_order=(4, D, 1, 24)).fit(disp=-1) print(best_model.summary())                                        <\/code><\/pre>\n<p>  <\/p>\n<pre><code>                                 Statespace Model Results                                  ========================================================================================== Dep. Variable:                          Users_box   No. Observations:                 2625 Model:             SARIMAX(4, 1, 3)x(4, 1, 1, 24)   Log Likelihood              -12547.157 Date:                            Sun, 23 Apr 2017   AIC                          25120.315 Time:                                    02:06:39   BIC                          25196.662 Sample:                                         0   HQIC                         25147.964                                            - 2625                                          Covariance Type:                              opg                                          ==============================================================================                  coef    std err          z      P&gt;|z|      [0.025      0.975] ------------------------------------------------------------------------------ ar.L1          0.6794      0.108      6.310      0.000       0.468       0.890 ar.L2         -0.0810      0.181     -0.448      0.654      -0.435       0.273 ar.L3          0.3255      0.137      2.371      0.018       0.056       0.595 ar.L4         -0.2154      0.028     -7.693      0.000      -0.270      -0.161 ma.L1         -0.5086      0.106     -4.784      0.000      -0.717      -0.300 ma.L2         -0.0673      0.170     -0.395      0.693      -0.401       0.267 ma.L3         -0.3490      0.117     -2.976      0.003      -0.579      -0.119 ar.S.L24       0.1023      0.012      8.377      0.000       0.078       0.126 ar.S.L48      -0.0686      0.021     -3.219      0.001      -0.110      -0.027 ar.S.L72       0.1971      0.009     21.573      0.000       0.179       0.215 ar.S.L96      -0.1217      0.013     -9.279      0.000      -0.147      -0.096 ma.S.L24      -0.9983      0.045    -22.085      0.000      -1.087      -0.910 sigma2       873.4159     36.206     24.124      0.000     802.454     944.378 =================================================================================== Ljung-Box (Q):                      130.47   Jarque-Bera (JB):           1194707.99 Prob(Q):                              0.00   Prob(JB):                         0.00 Heteroskedasticity (H):               1.40   Skew:                             2.65 Prob(H) (two-sided):                  0.00   Kurtosis:                       107.88 ===================================================================================  Warnings: [1] Covariance matrix calculated using the outer product of gradients (complex-step).<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">tsplot(best_model.resid[24:], lags=30)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Out: \u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u0414\u0438\u043a\u0438-\u0424\u0443\u043b\u043b\u0435\u0440\u0430: p=0.000000<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/804\/e8a\/436\/804e8a436ffc4382b73d91ac070d5dfa.png\"\/>  <\/p>\n<p>\u0427\u0442\u043e \u0436, \u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b, \u044f\u0432\u043d\u044b\u0445 \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0439 \u043d\u0435\u0442, \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">data[&quot;arima_model&quot;] = invboxcox(best_model.fittedvalues, lmbda) forecast = invboxcox(best_model.predict(start = data.shape[0], end = data.shape[0]+100), lmbda) forecast = data.arima_model.append(forecast).values[-500:] actual = data.Users.values[-400:] plt.figure(figsize=(15, 7)) plt.plot(forecast, color='r', label=&quot;model&quot;) plt.title(&quot;SARIMA model\\n Mean absolute error {} users&quot;.format(round(mean_absolute_error(data.dropna().Users, data.dropna().arima_model)))) plt.plot(actual, label=&quot;actual&quot;) plt.legend() plt.axvspan(len(actual), len(forecast), alpha=0.5, color='lightgrey') plt.grid(True)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/268\/37c\/27d\/26837c27d817434abff69088fe23cf2f.png\"\/>  <\/p>\n<p>\u0412 \u0444\u0438\u043d\u0430\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437, \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0448\u0438\u0431\u0430\u043b\u0430\u0441\u044c \u043d\u0430 1.3 K \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0438 \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0442\u0430\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442\u044c.<\/p>\n<p>  <\/p>\n<h1 id=\"lineynye-i-ne-ochen-modeli-na-vremennyh-ryadah\">\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u0430\u0445<\/h1>\n<p>  <\/p>\n<p>\u0421\u043d\u043e\u0432\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043b\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435. \u0427\u0430\u0441\u0442\u043e \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438, \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0443\u044f\u0441\u044c \u043e\u0434\u043d\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043e\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0449\u0438\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c \u2013 <a href=\"http:\/\/lurkmore.to\/\u0411\u044b\u0441\u0442\u0440\u043e,_\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e,_\u043d\u0435\u0434\u043e\u0440\u043e\u0433\u043e\"><em>\u0431\u044b\u0441\u0442\u0440\u043e, \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u043e<\/em><\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0430\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u043e\u0433\u0443\u0442 \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u0434\u043b\u044f &quot;\u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d-\u0440\u0435\u0448\u0435\u043d\u0438\u0439&quot;, \u0442\u0430\u043a \u043a\u0430\u043a \u043b\u0438\u0431\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u0430\u0442\u0440\u0430\u0442 \u043f\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, SARIMA), \u043b\u0438\u0431\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f (\u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2013 SARIMA), \u043b\u0438\u0431\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0447\u0430\u0441\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043e\u043f\u044f\u0442\u044c SARIMA), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438\u0437 \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043e \u043d\u0438\u043c \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u0438\u043b\u0438 \u043d\u0430\u0432\u0435\u0441\u0438\u0442\u044c \u0440\u0435\u0448\u0430\u044e\u0448\u0438\u0439 \u043b\u0435\u0441. \u0414\u0435\u0448\u0435\u0432\u043e \u0438 \u0441\u0435\u0440\u0434\u0438\u0442\u043e.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043d\u044b\u043c \u0442\u0435\u043e\u0440\u0438\u0435\u0439, \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0413\u0430\u0443\u0441\u0441\u0430-\u041c\u0430\u0440\u043a\u043e\u0432\u0430, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0443\u043d\u043a\u0442 \u043f\u0440\u043e \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a, \u043e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0435\u0440\u0435\u0434\u043a\u043e \u0432\u044b\u0440\u0443\u0447\u0430\u0435\u0442 \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e.<\/p>\n<p>  <\/p>\n<h2 id=\"izvlechenie-priznakov-feature-exctraction\">\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 (Feature exctraction)<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0432\u0440\u043e\u0434\u0435 \u043b\u0430\u0433\u043e\u0432 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043c\u044f. \u041f\u0440\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438\u0437 \u043d\u0438\u0445 \u0443\u0436\u0435 \u0437\u0434\u043e\u0440\u043e\u0432\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 <a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/325422\/#vremennye-ryady-veb-i-prochee\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439<\/a> \u043a\u0443\u0440\u0441\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u2013 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u043c. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u0442\u044c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043c\u043c\u0438-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u043e\u0442\u0435\u0440\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u0430 \u0432 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0432\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430-\u043b\u044f &quot;0 \u0447\u0430\u0441\u043e\u0432 &lt; 23 \u0447\u0430\u0441\u0430&quot;, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2013 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438 \u0438\u043b\u0438 \u0447\u0430\u0441 \u0434\u043d\u044f \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0438\u0433\u0440\u043e\u043a\u043e\u0432, \u043d\u0430\u0445\u043e\u0434\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u0432 \u044d\u0442\u043e\u0442 \u0434\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438 \u0438\u043b\u0438 \u0447\u0430\u0441 \u043e\u043d\u043b\u0430\u0439\u043d. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0430\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u0447\u0435\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 (\u0438\u043b\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u043e\u043b\u0434\u0430 \u043f\u0440\u0438 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438), \u0438\u043d\u0430\u0447\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u043d\u0430\u0440\u043e\u043a\u043e\u043c \u043f\u0440\u0438\u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def code_mean(data, cat_feature, real_feature):     &quot;&quot;&quot;     \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0433\u0434\u0435 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 cat_feature,      \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 - \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u043f\u043e real_feature     &quot;&quot;&quot;     return dict(data.groupby(cat_feature)[real_feature].mean())<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0435\u0433\u043e \u0447\u0430\u0441, \u0434\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0438\u043c\u0435\u044e\u0449\u0438\u0439\u0441\u044f \u0432 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u0435 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 <code>datetime<\/code>, \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e <code>hour<\/code> \u0438 <code>weekday<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">data = pd.DataFrame(dataset) data.columns = [&quot;y&quot;]  data.index = data.index.to_datetime() data[&quot;hour&quot;] = data.index.hour data[&quot;weekday&quot;] = data.index.weekday data['is_weekend'] = data.weekday.isin([5,6])*1 data.head()<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Out:<\/code><\/pre>\n<p>  <\/p>\n<table border=\"1\">\n<thead>\n<tr>\n<th><\/th>\n<th>y<\/th>\n<th>hour<\/th>\n<th>weekday<\/th>\n<th>is_weekend<\/th>\n<\/tr>\n<tr>\n<th>Time<\/th>\n<th><\/th>\n<th><\/th>\n<th><\/th>\n<th><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>2017-01-01 00:00:00<\/th>\n<td>34002<\/td>\n<td>0<\/td>\n<td>6<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<th>2017-01-01 01:00:00<\/th>\n<td>37947<\/td>\n<td>1<\/td>\n<td>6<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<th>2017-01-01 02:00:00<\/th>\n<td>41517<\/td>\n<td>2<\/td>\n<td>6<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<th>2017-01-01 03:00:00<\/th>\n<td>44476<\/td>\n<td>3<\/td>\n<td>6<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<th>2017-01-01 04:00:00<\/th>\n<td>46234<\/td>\n<td>4<\/td>\n<td>6<\/td>\n<td>1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u043f\u043e \u0434\u043d\u044f\u043c \u043d\u0435\u0434\u0435\u043b\u0438<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">code_mean(data, 'weekday', &quot;y&quot;)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Out: {0: 38730.143229166664,  1: 38632.828125,  2: 38128.518229166664,  3: 39519.035135135135,  4: 41505.152777777781,  5: 43717.708333333336,  6: 43392.143603133161}<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u0434\u043b\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435\/\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u0432 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u043c \u043f\u043e \u0440\u044f\u0434\u0443 \u043e\u043a\u043d\u0435, \u043c\u0435\u0434\u0438\u0430\u043d\u044b, \u0447\u0438\u0441\u043b\u043e \u043f\u0438\u043a\u043e\u0432, \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u044d\u0442\u0438\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0432\u0448\u0430\u044f\u0441\u044f \u0432 \u043a\u0443\u0440\u0441\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"https:\/\/github.com\/blue-yonder\/tsfresh\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 tsfresh<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0432\u0441\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0440\u0430\u0437\u0431\u0438\u0442\u044b\u0435 \u043d\u0430 \u0442\u0440\u0435\u0439\u043d \u0438 \u0442\u0435\u0441\u0442 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b \u0438 \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def prepareData(data, lag_start=5, lag_end=20, test_size=0.15):      data = pd.DataFrame(data.copy())     data.columns = [&quot;y&quot;]      # \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u0435, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u044b\u0439 \u043e\u0442\u0440\u0435\u0437\u043e\u043a     test_index = int(len(data)*(1-test_size))      # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043b\u0430\u0433\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432     for i in range(lag_start, lag_end):         data[&quot;lag_{}&quot;.format(i)] = data.y.shift(i)      data.index = data.index.to_datetime()     data[&quot;hour&quot;] = data.index.hour     data[&quot;weekday&quot;] = data.index.weekday     data['is_weekend'] = data.weekday.isin([5,6])*1      # \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043b\u0438\u043a\u0430     data['weekday_average'] = map(code_mean(data[:test_index], 'weekday', &quot;y&quot;).get, data.weekday)     data[&quot;hour_average&quot;] = map(code_mean(data[:test_index], 'hour', &quot;y&quot;).get, data.hour)      # \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438      data.drop([&quot;hour&quot;, &quot;weekday&quot;], axis=1, inplace=True)      data = data.dropna()     data = data.reset_index(drop=True)      # \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0432\u0435\u0441\u044c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u0443\u044e \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443     X_train = data.loc[:test_index].drop([&quot;y&quot;], axis=1)     y_train = data.loc[:test_index][&quot;y&quot;]     X_test = data.loc[test_index:].drop([&quot;y&quot;], axis=1)     y_test = data.loc[test_index:][&quot;y&quot;]      return X_train, X_test, y_train, y_test<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2 id=\"lineynaya-regressiya-vs-xgboost\">\u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f vs XGBoost<\/h2>\n<p>  <\/p>\n<p>\u041e\u0431\u0443\u0447\u0438\u043c \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043b\u0430\u0433\u0438 \u0431\u0443\u0434\u0435\u043c \u0431\u0440\u0430\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0434\u0432\u0435\u043d\u0430\u0434\u0446\u0430\u0442\u043e\u0433\u043e, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u0430 12 \u0447\u0430\u0441\u043e\u0432 \u0432\u043f\u0435\u0440\u0451\u0434, \u0438\u043c\u0435\u044f \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043f\u043e\u043b \u0434\u043d\u044f.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from sklearn.linear_model import LinearRegression  X_train, X_test, y_train, y_test = prepareData(dataset.Users, test_size=0.3, lag_start=12, lag_end=48) lr = LinearRegression() lr.fit(X_train, y_train) prediction = lr.predict(X_test) plt.figure(figsize=(15, 7)) plt.plot(prediction, &quot;r&quot;, label=&quot;prediction&quot;) plt.plot(y_test.values, label=&quot;actual&quot;) plt.legend(loc=&quot;best&quot;) plt.title(&quot;Linear regression\\n Mean absolute error {} users&quot;.format(round(mean_absolute_error(prediction, y_test)))) plt.grid(True);<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a96\/a70\/f76\/a96a70f761d4427c988b92014308f7f7.png\"\/>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u0434\u0430\u0436\u0435 \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0448\u0438\u0431\u0430\u0435\u0442\u0441\u044f, \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c, \u043d\u0430 3K \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0447\u0430\u0441, \u0438 \u044d\u0442\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0432\u044b\u0431\u0440\u043e\u0441 \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0440\u044f\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043e\u0446\u0435\u043d\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438, \u0442\u043e\u043c\u0443 \u0436\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443, \u0447\u0442\u043e \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0440\u0430\u043d\u0435\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 (\u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u043c\u0438), \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0432 \u043f\u043e\u0441\u0442\u0435 <a href=\"http:\/\/francescopochetti.com\/pythonic-cross-validation-time-series-pandas-scikit-learn\/\">Pythonic Cross Validation on Time Series<\/a><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def performTimeSeriesCV(X_train, y_train, number_folds, model, metrics):     print('Size train set: {}'.format(X_train.shape))      k = int(np.floor(float(X_train.shape[0]) \/ number_folds))     print('Size of each fold: {}'.format(k))      errors = np.zeros(number_folds-1)      # loop from the first 2 folds to the total number of folds         for i in range(2, number_folds + 1):         print('')         split = float(i-1)\/i         print('Splitting the first ' + str(i) + ' chunks at ' + str(i-1) + '\/' + str(i) )          X = X_train[:(k*i)]         y = y_train[:(k*i)]         print('Size of train + test: {}'.format(X.shape)) # the size of the dataframe is going to be k*i          index = int(np.floor(X.shape[0] * split))          # folds used to train the model                 X_trainFolds = X[:index]                 y_trainFolds = y[:index]          # fold used to test the model         X_testFold = X[(index + 1):]         y_testFold = y[(index + 1):]          model.fit(X_trainFolds, y_trainFolds)         errors[i-2] = metrics(model.predict(X_testFold), y_testFold)      # the function returns the mean of the errors on the n-1 folds         return errors.mean()<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"python\">%%time performTimeSeriesCV(X_train, y_train, 5, lr, mean_absolute_error)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">Size train set: (1838, 39) Size of each fold: 367  Splitting the first 2 chunks at 1\/2 Size of train + test: (734, 39)  Splitting the first 3 chunks at 2\/3 Size of train + test: (1101, 39)  Splitting the first 4 chunks at 3\/4 Size of train + test: (1468, 39)  Splitting the first 5 chunks at 4\/5 Size of train + test: (1835, 39) CPU times: user 59.5 ms, sys: 7.02 ms, total: 66.5 ms Wall time: 18.9 ms  Out: 4613.17893150896 <\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430 5 \u0444\u043e\u043b\u0434\u0430\u0445 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 4.6 K \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u043e\u0446\u0435\u043d\u043a\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c XGBoost&#8230;<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/754\/a9a\/26e\/754a9a26e59648de9fe2487241a27c43.jpg\"\/>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0441 XGBoost<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import xgboost as xgb  def XGB_forecast(data, lag_start=5, lag_end=20, test_size=0.15, scale=1.96):      # \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435     X_train, X_test, y_train, y_test = prepareData(dataset.Users, lag_start, lag_end, test_size)     dtrain = xgb.DMatrix(X_train, label=y_train)     dtest = xgb.DMatrix(X_test)      # \u0437\u0430\u0434\u0430\u0451\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b     params = {         'objective': 'reg:linear',         'booster':'gblinear'     }     trees = 1000      # \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u043c \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0441 \u043c\u0435\u0442\u0440\u0438\u043a\u043e\u0439 rmse     cv = xgb.cv(params, dtrain, metrics = ('rmse'), verbose_eval=False, nfold=10, show_stdv=False, num_boost_round=trees)      # \u043e\u0431\u0443\u0447\u0430\u0435\u043c xgboost \u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432, \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u043c \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438     bst = xgb.train(params, dtrain, num_boost_round=cv['test-rmse-mean'].argmin())      # \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u0440\u0438\u0432\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438     #cv.plot(y=['test-mae-mean', 'train-mae-mean'])      # \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438     deviation = cv.loc[cv['test-rmse-mean'].argmin()][&quot;test-rmse-mean&quot;]      # \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u0435\u043b\u0430 \u0441\u0435\u0431\u044f \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u043e\u0442\u0440\u0435\u0437\u043a\u0435 \u0440\u044f\u0434\u0430     prediction_train = bst.predict(dtrain)     plt.figure(figsize=(15, 5))     plt.plot(prediction_train)     plt.plot(y_train)     plt.axis('tight')     plt.grid(True)      # \u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c     prediction_test = bst.predict(dtest)     lower = prediction_test-scale*deviation     upper = prediction_test+scale*deviation      Anomalies = np.array([np.NaN]*len(y_test))     Anomalies[y_test&lt;lower] = y_test[y_test&lt;lower]      plt.figure(figsize=(15, 5))     plt.plot(prediction_test, label=&quot;prediction&quot;)     plt.plot(lower, &quot;r--&quot;, label=&quot;upper bond \/ lower bond&quot;)     plt.plot(upper, &quot;r--&quot;)     plt.plot(list(y_test), label=&quot;y_test&quot;)     plt.plot(Anomalies, &quot;ro&quot;, markersize=10)     plt.legend(loc=&quot;best&quot;)     plt.axis('tight')     plt.title(&quot;XGBoost Mean absolute error {} users&quot;.format(round(mean_absolute_error(prediction_test, y_test))))     plt.grid(True)     plt.legend()<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"python\">XGB_forecast(dataset, test_size=0.2, lag_start=5, lag_end=30)<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/3d0\/683\/7f4\/3d06837f4571472a9a42502096728542.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/85d\/1ea\/f35\/85d1eaf35af841868d5f426afaf3cc77.png\"\/>  <\/p>\n<p>\u0422\u0435 \u0436\u0435 3 K \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0435, \u0438 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043f\u043e\u0439\u043c\u0430\u043d\u043d\u044b\u0435 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443, \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u043e\u0437\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044e, \u043e\u0442\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0430\u0433\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u0443\u0445\u043e\u0434\u0438\u0442\u044c \u0432\u0433\u043b\u0443\u0431\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0438 \u0442.\u0434.<\/p>\n<p>  <\/p>\n<h1 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438 \u043a \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0438\u043b\u0438 \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0441\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u043e\u0439 \u043f\u0443\u043b\u0438 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0437\u0430\u0434\u0430\u0447 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c. \u041c\u0435\u0442\u043e\u0434\u044b, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0432 60-\u0435 \u0433\u043e\u0434\u044b \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0432\u0435\u043a\u0430, (\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 19-\u0433\u043e), \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430\u0440\u0430\u0432\u043d\u0435 \u0441 \u043d\u0435\u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 LSTM \u0438\u043b\u0438 RNN. \u041e\u0442\u0447\u0430\u0441\u0442\u0438 \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u0430\u043a \u0438 \u043b\u044e\u0431\u0430\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0430\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u2014 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u043a\u0430\u044f \u0438 \u0443\u0436 \u0442\u043e\u0447\u043d\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043e\u0431\u0438\u043b\u0438\u0435 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441\u0432\u043e\u0451. \u041d\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0440\u043e\u043b\u044c \u0438\u0433\u0440\u0430\u0435\u0442 \u0438 \u0431\u0430\u043b\u0430\u043d\u0441 \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438 \u0442\u0440\u0443\u0434\u043e\u0437\u0430\u0442\u0440\u0430\u0442\u0430\u043c\u0438. \u041d\u0435 \u0440\u0430\u0437 \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0432\u0448\u0430\u044f\u0441\u044f \u0437\u0434\u0435\u0441\u044c SARIMA-\u043c\u043e\u0434\u0435\u043b\u044c \u0445\u043e\u0442\u044f \u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0434\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0430\u0441\u0430 <del>\u0442\u0430\u043d\u0446\u0435\u0432 \u0441 \u0431\u0443\u0431\u043d\u043e\u043c<\/del> \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441 \u0440\u044f\u0434\u043e\u043c, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0443\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u043e\u0440\u0443\u0434\u0438\u0442\u044c \u0437\u0430 10 \u043c\u0438\u043d\u0443\u0442, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<p>  <\/p>\n<h1 id=\"domashnee-zadanie\">\u0414\u043e\u043c\u0430\u0448\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0412 \u043d\u043e\u0432\u043e\u043c \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0438, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u043c <a href=\"https:\/\/habrahabr.ru\/users\/miptgirl\/\" class=\"user_link\">miptgirl<\/a> (\u041c\u0430\u0440\u0438\u0435\u0439 \u041c\u0430\u043d\u0441\u0443\u0440\u043e\u0432\u043e\u0439), \u0432\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0438\u043b\u044b \u0432 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432 \u0432\u0438\u043a\u0438-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b <a href=\"https:\/\/en.wikipedia.org\/wiki\/Machine_learning\">Machine Learning<\/a> \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Facebook Prophet, (\u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u041c\u0430\u0440\u0438\u044f \u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b\u0430 \u0432 <a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/323730\/\">\u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0432<\/a>), \u0438 SARIMA-\u043c\u043e\u0434\u0435\u043b\u0438. <a href=\"https:\/\/github.com\/Yorko\/mlcourse_open\/blob\/master\/jupyter_notebooks\/topic9_time_series\/hw9_time_series.ipynb\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 jupyter-\u043d\u043e\u0443\u0442\u0431\u0443\u043a<\/a> \u0441 \u0434\u043e\u043c\u0430\u0448\u043d\u0438\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0435\u043c \u0438 <a href=\"https:\/\/goo.gl\/forms\/kfjRQaUHuYwQBtWz2\">\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0432\u0435\u0431-\u0444\u043e\u0440\u043c\u0443<\/a> \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u0432. <\/p>\n<p>  <\/p>\n<h1 id=\"poleznye-resursy\">\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/h1>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/people.duke.edu\/~rnau\/411home.htm\">\u041e\u043d\u043b\u0430\u0439\u043d \u0443\u0447\u0435\u0431\u043d\u0438\u043a<\/a> \u043a\u0443\u0440\u0441\u0430 \u043f\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u043e\u043c\u0443 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u0430 Duke \u2014 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u044b \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f, \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 ARIMA \u043c\u043e\u0434\u0435\u043b\u0438 <\/li>\n<li>\u0421\u0442\u0430\u0442\u044c\u044f <a href=\"https:\/\/bmcbioinformatics.biomedcentral.com\/articles\/10.1186\/1471-2105-15-276\">Comparison of ARIMA and Random Forest time series models for prediction of avian influenza H5N1 outbreaks<\/a> \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0435\u043c\u043d\u043e\u0433\u0438\u0445, \u0433\u0434\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430 \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043f\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432<\/li>\n<li>\u0421\u0442\u0430\u0442\u044c\u044f <a href=\"http:\/\/www.blackarbs.com\/blog\/time-series-analysis-in-python-linear-models-to-garch\/11\/1\/2016\">Time Series Analysis (TSA) in Python \u2014 Linear Models to GARCH<\/a> \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 ARIMA \u0438 \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 (Brian Christopher)<\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 <a href=\"https:\/\/github.com\/Yorko\/mlcourse_open\">GitHub-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a> \u043a\u0443\u0440\u0441\u0430<br \/>  \u0432 \u0432\u0438\u0434\u0435 <a href=\"https:\/\/github.com\/Yorko\/mlcourse_open\/blob\/master\/jupyter_notebooks\/topic9_time_series\/topic9_time_series_python.ipynb\">\u0442\u0435\u0442\u0440\u0430\u0434\u043a\u0438<\/a> Jupyter.<\/em><\/p>\n<p><cut\/><br \/> \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\/327242\/\"> https:\/\/habrahabr.ru\/post\/327242\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0434\u043d\u044f!<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043d\u0430\u0448 \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u0443\u0440\u0441\u0430 \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0438 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u0430\u0445. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/234\/dcd\/2fc\/234dcd2fca894e80bc4c753e67bf613f.jpg\" width=\"250\" align=\"right\"\/>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 Python, \u043a\u0430\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f; \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0434\u0432\u043e\u0439\u043d\u043e\u0435 \u0438 \u0442\u0440\u043e\u0439\u043d\u043e\u0435 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0437\u0432\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435; \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e \u0432\u0430\u0441; \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c SARIMA \u0438 \u043d\u0435 \u0443\u043c\u0435\u0440\u0435\u0442\u044c; \u0438 \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c xgboost-\u043e\u043c. \u0418 \u0432\u0441\u0451 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0438\u0437 \u0441\u0443\u0440\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/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-285430","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285430","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=285430"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285430\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=285430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=285430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=285430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}