{"id":379242,"date":"2024-06-19T21:00:54","date_gmt":"2024-06-19T21:00:54","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=379242"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=379242","title":{"rendered":"<span>SARIMAX vs \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: \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043f\u043e\u0431\u0435\u0436\u0434\u0430\u0435\u0442<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412<a href=\"https:\/\/habr.com\/ru\/articles\/821231\/\" rel=\"noopener noreferrer nofollow\"> \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u043f\u043e\u0441\u0442\u0435 <\/a>\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430 \u043f\u0440\u043e \u0441\u0432\u043e\u0438 \u043c\u0443\u0447\u0435\u043d\u0438\u044f \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u043a\u043e\u0439 ARIMA. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0435\u0440\u0438\u0438 \u0438\u0437\u0434\u0435\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432 \u043d\u0430\u0434 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438, SARIMAX \u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0414\u043b\u044f\u00a0\u043d\u0430\u0447\u0430\u043b\u0430 \u0445\u043e\u0447\u0443 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0441\u044f\u043a\u0438 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u043f\u0440\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0432\u0435\u0449\u0438. \u041c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0430\u0431\u0437\u0430\u0446, \u0435\u0441\u043b\u0438 \u0412\u044b \u0438 \u0442\u0430\u043a \u0448\u0430\u0440\u0438\u0442\u0435 \u0432 \u043e\u0441\u043d\u043e\u0432\u0430\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432. <\/p>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u043d\u0443\u0434\u043d\u0430\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>\u0413\u0430\u0443\u0441\u0441\u043e\u0432(\u0441\u043a\u0438\u0439) \u043f\u0440\u043e\u0446\u0435\u0441\u0441:<\/strong> \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u03bet \u0434\u043b\u044f\u00a0\u043b\u044e\u0431\u044b\u0445 t1,. . ., tn \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 (\u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u043c\u0438), \u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u03bet \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u043c.<\/p>\n<p>\u041a\u0430\u043a \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0432 <a href=\"https:\/\/habr.com\/ru\/articles\/821231\/#comment_26929487\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445<\/a> \u043a \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u043f\u043e\u0441\u0442\u0443, \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u043e\u0441\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0437\u0430\u0448\u0438\u0442\u0430 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f. \u041d\u0435 \u0440\u0438\u0441\u043a\u043d\u0443 \u043b\u0435\u0437\u0442\u044c \u0432\u0433\u043b\u0443\u0431\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043d\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043a\u0440\u0430\u0439\u043d\u0435 \u0446\u0435\u043d\u043d\u043e\u0435. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u044f \u0441\u0442\u0430\u043b\u0430 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435, \u043d\u043e \u0438 \u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 (residuals). \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/articles\/760550\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0417\u0430 \u043d\u0430\u0432\u043e\u0434\u043a\u0443 \u0441\u043f\u0430\u0441\u0438\u0431\u043e @adeshere.<\/p>\n<p><strong>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434:<\/strong> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0432\u043e\u00a0\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0432\u00a0\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438.\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u044f\u0434\u044b \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430\u00a0\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0435 \u0438 \u043d\u0435\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0435, \u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u00a0\u043d\u0438\u043c\u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e\u00a0\u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0431\u0430\u0437\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/education.yandex.ru\/handbook\/ml\/article\/analitika-vremennyh-ryadov\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u042f\u043d\u0434\u0435\u043a\u0441\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u0443\u0447\u0435\u0431\u043d\u0438\u043a\u0430 \u043f\u043e\u00a0ML\u00a0\u2014 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043a\u043e\u0434\u0430. \u041c\u043d\u0435, \u043a\u0430\u043a \u043d\u043e\u0432\u0438\u0447\u043a\u0443, \u0431\u044b\u043b\u043e \u043a\u0440\u0430\u0439\u043d\u0435 \u0442\u044f\u0436\u0435\u043b\u043e \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443 \u0438 \u043a\u043e\u0434 \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0430.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u043e\u0447\u0438\u0435 \u043a\u043e\u0441\u044f\u043a\u0438 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445 <a href=\"https:\/\/habr.com\/ru\/articles\/821231\/comments\/#comment_26928277\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438<\/a>, \u0447\u0442\u043e ACF \u0438 PACF \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u042f \u0432 \u044d\u0442\u043e\u043c \u0443\u0431\u0435\u0434\u0438\u043b\u0430\u0441\u044c \u043d\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043f\u0435\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u043f\u044b\u0442\u0435, \u043d\u043e \u0435\u0449\u0451 \u0440\u0430\u0437 \u044d\u0442\u043e \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u0437 R, \u043c\u043e\u0434\u0435\u043b\u044c ARCH, Pycaret \u0438 fbprophet.<\/p>\n<\/div>\n<\/details>\n<h2>\u0414\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0437\u0430 2.5 \u0433\u043e\u0434\u0430 \u043f\u043e \u0434\u043d\u044f\u043c, \u0434\u043b\u044f \u043f\u0430\u0440\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u044f \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0430 \u0441\u043a\u043b\u0435\u0438\u0442\u044c \u0435\u0451 \u0432 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0438\u043b\u0438 \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0444\u0438\u0437\u0438\u043a\u0438 \u0437\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0442\u0443\u0442 \u043d\u0435 \u043b\u0435\u0436\u0438\u0442. \u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043d\u043e\u0441\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0441\u044f\u0446 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0430\u0432\u0430\u043b\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438. \u0418 \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u0449\u0451 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u043e\u043b\u043e\u043d\u043a\u0443 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b4e\/05e\/dd4\/b4e05edd4d163b41274828906703978a.png\" alt=\"\u041a\u0430\u043a\u043e\u0439-\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434 \u0431\u044b\u043b \u0443 \u043c\u0435\u043d\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435\" title=\"\u041a\u0430\u043a\u043e\u0439-\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434 \u0431\u044b\u043b \u0443 \u043c\u0435\u043d\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435\" width=\"1808\" height=\"890\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b4e\/05e\/dd4\/b4e05edd4d163b41274828906703978a.png\"\/><\/p>\n<div><figcaption>\u041a\u0430\u043a\u043e\u0439-\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434 \u0431\u044b\u043b \u0443 \u043c\u0435\u043d\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435<\/figcaption><\/div>\n<\/figure>\n<h2>SARIMA<\/h2>\n<p>\u041d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c SARIMA \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043d\u0430\u0434\u0435\u0436\u0434\u044b, \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 ARIMA \u043e\u043d\u0430 \u043c\u043e\u0433\u043b\u0430 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u0441 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0443 \u043d\u0435\u0451 \u0434\u0435\u043b\u0430 \u043e\u0431\u0441\u0442\u043e\u044f\u043b\u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u043b\u0443\u0447\u0448\u0435. \u0412 \u0438\u0442\u043e\u0433\u0435 \u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u043f\u043e \u0434\u043d\u044f\u043c.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u043c \u0440\u044f\u0434\u043e\u043c, \u044f \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439:<\/p>\n<pre><code class=\"python\"> diff1 = df.copy(deep=True)  diff1['1'] = df['1'].diff() diff1['2'] = df['2'].diff() diff1.dropna(inplace=True)<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u043f\u0440\u043e\u0431\u043d\u044b\u0439 \u0442\u044b\u0447\u043e\u043a \u043f\u0430\u043b\u044c\u0446\u0435\u043c \u0432 \u043d\u0435\u0431\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\">from statsmodels.tsa.statespace.sarimax import SARIMAX # Ensure the SARIMAX model is initialized properly with your training data and exogenous variables model = SARIMAX(diff1['1'][:962], exog=diff1['2'][:962], order=(1, 1, 1), seasonal_order=(1, 0, 1, 12))  # Fit the model result = model.fit(disp=False) # Forecast using the correct steps and aligned exogenous data forecast = result.get_forecast(steps=len(df_test), exog=forecast_exog) predictions = result.forecast(len(df_test), exog=forecast_exog) # predictions predictions = pd.Series(predictions.values, index=df_test.index) # If the forecast returns NaNs, check alignment and data quality forecast_df = pd.DataFrame({     'predicted_mean': forecast.predicted_mean,     'lower_ci': forecast.conf_int().iloc[:, 0],     'upper_ci': forecast.conf_int().iloc[:, 1] }, index=df_test.index)<\/code><\/pre>\n<p>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Optuna:<\/p>\n<pre><code class=\"python\"> #Generate all different combinations of p, d and q triplets #Generate all different combinations of p, d, q and s triplets import itertools import optuna  p = range(1, 3)  # Smaller range for non-seasonal AR component d = range(0, 2) q = range(0, 3) P = range(0, 2)  # Smaller range for seasonal AR component D = range(0, 2) Q = range(0, 2) s = 12  pdq = list(itertools.product(p, d, q)) pdqs = [(x[0], x[1], x[2], s) for x in list(itertools.product(P, D, Q))] #%% def objective_sarima(trial):     non_seasonal_order = trial.suggest_categorical('non_seasonal_order', pdq)     seasonal_order = trial.suggest_categorical('seasonal_order', pdqs)     trend = trial.suggest_categorical('trend', ['n', 'c', 't', 'ct', None])          # # Generate predictions     # predictions = mdl.forecast(len(df_test))     model = SARIMAX(diff1['1'][:962], exog=diff1['2'][:962], order=non_seasonal_order, seasonal_order=seasonal_order)     # Fit the model     result = model.fit(disp=True)     # Forecast using the correct steps and aligned exogenous data     forecast = result.get_forecast(steps=len(df_test), exog=forecast_exog)     predictions = result.forecast(len(df_test), exog=forecast_exog)     # predictions     predictions = pd.Series(predictions.values, index=df_test.index)     # If the forecast returns NaNs, check alignment and data quality     forecast_df = pd.DataFrame({         'predicted_mean': forecast.predicted_mean,         'lower_ci': forecast.conf_int().iloc[:, 0],         'upper_ci': forecast.conf_int().iloc[:, 1]     }, index=df_test.index)     # Calculate residuals and error metric     residuals = diff1['1'] - predictions     mse = np.sqrt(np.mean(residuals**2))     return mse  study=optuna.create_study(direction=\"minimize\") study.optimize(objective_sarima,n_trials=10)<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u044f \u043d\u0430 \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u0447\u0430\u0441\u0442\u044c\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0430. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0443\u0441\u0442\u0440\u0430\u0448\u0430\u044e\u0449\u0435:<\/p>\n<pre><code class=\"python\">plt.figure(figsize=(10, 6)) plt.plot(df_test['1'], label='Actual Future', marker='o', color='green') plt.plot(forecast_df['predicted_mean'], label='Forecasted', marker='o', color='red') plt.fill_between(forecast_df.index, forecast_df['lower_ci'], forecast_df['upper_ci'], color='red', alpha=0.2) plt.title('Forecasted vs Actual Counts') plt.xlabel('Date') plt.ylabel('Count') plt.legend() plt.grid(True) plt.xticks(rotation=45) plt.tight_layout() plt.show()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e12\/985\/6fe\/e129856fe4bc74832fd93a3713fbf5e8.png\" alt=\"\u041d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0435 \u0440\u044f\u0434\u044b: \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439\" title=\"\u041d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0435 \u0440\u044f\u0434\u044b: \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439\" width=\"1814\" height=\"928\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e12\/985\/6fe\/e129856fe4bc74832fd93a3713fbf5e8.png\"\/><\/p>\n<div><figcaption>\u041d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0435 \u0440\u044f\u0434\u044b: \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044f \u0441\u0440\u0430\u0432\u043d\u0438\u043b\u0430 \u0435\u0449\u0451 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u043e\u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u044f\u0434 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438. \u041c\u0435\u043d\u044f \u043f\u0440\u043e\u0441\u0438\u043b\u0438 \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u0432\u0441\u0451 \u0441 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u043e\u0439-\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c, \u0442\u0430\u043a \u0447\u0442\u043e \u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043c\u043e\u043d\u0441\u0442\u0440\u0443\u043e\u0437\u043d\u044b\u0439. \u0422\u0443\u0442 \u0432\u0430\u0436\u043d\u043e \u043e\u043f\u044f\u0442\u044c-\u0442\u0430\u043a\u0438 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u043a\u043e\u0434\u0435 \u043d\u043e\u0441\u0438\u0442 \u0438\u043c\u044f offset. \u0418\u043d\u0430\u0447\u0435 \u044d\u0442\u043e \u0447\u0435\u0445\u043e\u0432\u0441\u043a\u043e\u0435 \u0440\u0443\u0436\u044c\u0451 \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0442 \u0432 \u043d\u043e\u0433\u0443.<\/p>\n<pre><code class=\"python\">#integral constant! offset = int(list(dataset_sends['count_offers'])[-len(df_test)]) print(offset) inverted_forecast = pd.Series(forecast_df['predicted_mean']).cumsum() inverted_forecast = pd.DataFrame(forecast_df['predicted_mean']) inverted_true = pd.DataFrame(list(dataset_sends['count_offers'][-len(df_test):]), index=range(0, len(df_test)))  inverted_forecast = inverted_forecast + offset inverted_forecast = pd.DataFrame(list(inverted_forecast['predicted_mean'][-len(df_test):]), index=range(0, len(df_test))) dates = pd.DataFrame(list(dataset_sends['date'][-len(df_test):]), index=range(0, len(df_test)))  df_merged = pd.concat([inverted_forecast, inverted_true, dates], axis=1)  df_merged.columns = ['predicted_mean', 'count_offers', 'date']  df_merged.dropna(inplace=True) df_merged['1'] = df_merged['1'].apply(int) df_merged['predicted_mean'] = df_merged['predicted_mean'].apply(int) # Absolute Error df_merged['error'] = abs(df_merged['count_offers'] - df_merged['predicted_mean']) df_merged['date'] = pd.to_datetime(df_merged['date']) # Set 'date' column as the index df_merged.set_index('date', inplace=True)  # Group by week and sum the other columns df_merged = df_merged.resample('W').sum()  # Reset index to make 'date' a column again df_merged.reset_index(inplace=True) # Relative Error df_merged['relative_error, %'] = abs(df_merged['count_offers'] - df_merged['predicted_mean']) \/ df_merged['count_offers'] * 100 df_merged.dropna(inplace=True)   display(df_merged[-17:-1]) plt.plot(df_merged.index, df_merged['count_offers'], label='count_offers') # Plot 'predicted_mean' plt.plot(df_merged.index, df_merged['predicted_mean'], label='predicted_mean')  # Set labels and title plt.xlabel('Time') plt.ylabel('Count') plt.title('Comparison of count_offers and predicted_mean') plt.legend()  # Show plot plt.show()<\/code><\/pre>\n<p>\u0423\u0432\u044b, \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443 \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u0438\u0437-\u0437\u0430 NDA, \u0438 \u0442\u0430\u043a \u0445\u043e\u0436\u0443 \u043f\u043e \u043e\u0444\u0438\u0433\u0435\u043d\u043d\u043e \u0442\u043e\u043d\u043a\u043e\u043c\u0443 \u043b\u044c\u0434\u0443:)<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/952\/1a6\/b65\/9521a6b65030e02fb38109c29dd96534.png\" alt=\"\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c\" title=\"\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c\" width=\"952\" height=\"718\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/952\/1a6\/b65\/9521a6b65030e02fb38109c29dd96534.png\"\/><\/p>\n<div><figcaption>\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c<\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0412\u044b\u0432\u043e\u0434:<\/strong> \u0445\u043e\u0442\u044f \u044f \u0438 \u043f\u0438\u0442\u0430\u043b\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043d\u0430\u0434\u0435\u0436\u0434\u044b, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 SARIMA \u043c\u0435\u043d\u044f \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u043b. \u0418 \u044f \u043f\u043e\u0448\u043b\u0430 \u0433\u0443\u0433\u043b\u0438\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435, \u0447\u0442\u043e \u0435\u0449\u0451 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043b\u044e\u0434\u0438 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432.<\/p>\n<h2>\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<\/h2>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 <a href=\"https:\/\/education.yandex.ru\/handbook\/ml\/article\/analitika-vremennyh-ryadov\" rel=\"noopener noreferrer nofollow\">\u0443\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0442<\/a> \u0432 \u042f\u043d\u0434\u0435\u043a\u0441-\u0443\u0447\u0435\u0431\u043d\u0438\u043a\u0435 \u043f\u043e ML, \u043d\u043e \u0443\u0434\u0435\u043b\u044f\u044e\u0442 \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u043a\u0430\u043a \u043c\u043e\u0434\u0435\u043b\u044f\u043c ARIMA\/SARIMA. \u0410 \u0432\u043e\u0442 \u043c\u043d\u0435 \u043e\u043d \u0434\u0430\u043b \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u043a\u043b\u0430\u0441\u0441\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0442\u043e\u0436\u0435 \u044e\u0437\u0430\u043b\u0430 \u043f\u0430\u043a\u0435\u0442\u043d\u0443\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c, \u043b\u0435\u0436\u0430\u0449\u0438\u043c\u0438 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 aust. \u0422\u0430\u043a\u0436\u0435 \u0440\u0443\u043a\u0430\u043c\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043f\u0435\u0440\u0438\u043e\u0434 \u0432 40 \u0434\u043d\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u043b\u0430 \u0440\u0443\u0447\u043a\u0430\u043c\u0438, \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432. \u041d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0442\u0430\u043a:)<\/p>\n<pre><code class=\"python\">import pandas as pd import numpy as np import matplotlib.pyplot as plt from datetime import datetime import statsmodels.api as sm from pandas.plotting import register_matplotlib_converters from statsmodels.tsa.holtwinters import SimpleExpSmoothing from statsmodels.tsa.holtwinters import ExponentialSmoothing from sklearn.metrics import mean_squared_error,mean_absolute_error import warnings from statsmodels.tsa.holtwinters import SimpleExpSmoothing, Holt warnings.filterwarnings('ignore')  period = 40 fit1 = ExponentialSmoothing(     aust,     seasonal_periods=period,     trend=\"add\",     seasonal=\"add\",     use_boxcox=True,     initialization_method=\"estimated\", ).fit() fit2 = ExponentialSmoothing(     aust,     seasonal_periods=period,     trend=\"add\",     seasonal=\"mul\",     use_boxcox=True,     initialization_method=\"estimated\", ).fit() fit3 = ExponentialSmoothing(     aust,     seasonal_periods=period,     trend=\"add\",     seasonal=\"add\",     damped_trend=True,     use_boxcox=True,     initialization_method=\"estimated\", ).fit() fit4 = ExponentialSmoothing(     aust,     seasonal_periods=period,     trend=\"add\",     seasonal=\"mul\",     damped_trend=True,     use_boxcox=True,     initialization_method=\"estimated\", ).fit() results = pd.DataFrame(     index=[r\"$\\alpha$\", r\"$\\beta$\", r\"$\\phi$\", r\"$\\gamma$\", r\"$l_0$\", \"$b_0$\", \"SSE\"] ) params = [     \"smoothing_level\",     \"smoothing_trend\",     \"damping_trend\",     \"smoothing_seasonal\",     \"initial_level\",     \"initial_trend\", ] results[\"Additive\"] = [fit1.params[p] for p in params] + [fit1.sse] results[\"Multiplicative\"] = [fit2.params[p] for p in params] + [fit2.sse] results[\"Additive Dam\"] = [fit3.params[p] for p in params] + [fit3.sse] results[\"Multiplica Dam\"] = [fit4.params[p] for p in params] + [fit4.sse]    ax = train_data.plot(marker=\"o\",     color=\"black\",     title=\"Forecasts from Holt-Winters' multiplicative method\", )  ax.set_xlim(1697587200000000000, 1713139200000000000) ax.set_ylim(0, 20) ax.set_ylabel(\"counts\") ax.set_xlabel(\"Year\")  fit1.fittedvalues.plot(style=\"--\",marker=\"o\", color=\"red\", ax=ax) fit2.fittedvalues.plot(style=\"--\", marker=\"o\",color=\"green\", ax=ax) fit3.fittedvalues.plot(style=\"--\", marker=\"o\",color=\"blue\", ax=ax) fit4.fittedvalues.plot(style=\"--\", marker=\"o\",color=\"green\", ax=ax)   forecast1 = fit1.forecast(121).rename(\"Holt-Winters (add-add-seasonal)\") forecast2 = fit2.forecast(121).rename(\"Holt-Winters (add-mul-seasonal)\") forecast3 = fit3.forecast(121).rename(\"Holt-Winters (add-add-seasonal heuristic)\") forecast4 = fit4.forecast(121).rename(\"Holt-Winters (add-mul-seasonal heuristic)\")  predictions1 = pd.Series(forecast1.values, index=test_data.index) predictions2 = pd.Series(forecast2.values, index=test_data.index) predictions3 = pd.Series(forecast3.values, index=test_data.index) predictions4 = pd.Series(forecast4.values, index=test_data.index)  predictions1.dropna(inplace=True) predictions2.dropna(inplace=True) predictions3.dropna(inplace=True) predictions4.dropna(inplace=True)  print(\"1mean absolute error : \",round(mean_absolute_error(test_data[:len(predictions1)], predictions1), 5)) print(\"1mean squared error : \",round(mean_squared_error(test_data[:len(predictions1)], predictions1), 5)) print(\"1Root mean squared error : \",round(mean_squared_error(test_data[:len(predictions1)], predictions1,squared=False), 5))  print(\"2mean absolute error : \",round(mean_absolute_error(test_data[:len(predictions2)], predictions2),5)) print(\"2mean squared error : \",round(mean_squared_error(test_data[:len(predictions2)], predictions2),5)) print(\"2Root mean squared error : \",round(mean_squared_error(test_data[:len(predictions2)], predictions2,squared=False),5))  print(\"3mean absolute error : \",round(mean_absolute_error(test_data[:len(predictions3)], predictions3),5)) print(\"3mean squared error : \",round(mean_squared_error(test_data[:len(predictions3)], predictions3),5)) print(\"3Root mean squared error : \",round(mean_squared_error(test_data[:len(predictions3)], predictions3,squared=False),5))  # print(\"4mean absolute error : \",round(mean_absolute_error(test_data[:len(predictions4)], predictions4),5)) # print(\"4mean squared error : \",round(mean_squared_error(test_data[:len(predictions4)], predictions4),5)) # print(\"4Root mean squared error : \",round(mean_squared_error(test_data[:len(predictions4)], predictions4,squared=False),5))  forecast1.plot(ax=ax, style=\"--\", marker=\"o\", color=\"green\", legend=True, figsize=(20, 10)) forecast2.plot(ax=ax, style=\"--\", marker=\"o\", color=\"red\", legend=True) forecast3.plot(ax=ax, style=\"--\", marker=\"o\", color=\"blue\", legend=True) forecast4.plot(ax=ax, style=\"--\", marker=\"o\", color=\"yellow\", legend=True)  plt.plot(predictions1, marker=\"o\", color = \"green\") plt.plot(predictions2, marker=\"o\", color = \"red\") plt.plot(predictions3, marker=\"o\", color = \"blue\") plt.plot(predictions4, marker=\"o\", color = \"yellow\") plt.plot(test_data, marker=\"o\", color = 'black') plt.plot(train_data, marker=\"o\", color = 'black') # Show the plot plt.show()  print(\"Figure 7.6: Forecasting.\") # results<\/code><\/pre>\n<p>\u041a\u043e\u0434 \u0442\u043e\u0436\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u043e\u043d\u0441\u0442\u0440\u0443\u043e\u0437\u043d\u043e, \u044f \u043d\u0430\u0434\u0435\u044f\u043b\u0430\u0441\u044c \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c, \u043d\u043e \u043f\u043e\u0441\u044b\u043f\u0430\u043b\u0438\u0441\u044c \u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u044f \u0437\u0430\u0431\u0438\u043b\u0430. <\/p>\n<p>\u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u044f \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0430 \u043f\u043e-\u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u0438 \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u044e\u0434\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0441 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u044b\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c. \u041c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0451 \u0432 \u0446\u0438\u0444\u0438\u0440\u044c\u043a\u0438 \u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0430\u043b\u044b\u043c:<\/p>\n<pre><code class=\"python\">aust['date'] = pd.to_numeric(pd.to_datetime(aust['date']))<\/code><\/pre>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0443 \u043c\u0435\u043d\u044f \u043f\u0440\u043e\u043f\u0430\u043b\u0430, \u043d\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0431\u044b\u043b\u0430 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0442\u0430\u043a\u0430\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/674\/b70\/cd5\/674b70cd579783e422af1e11f1e22fc2.png\" width=\"2402\" height=\"1284\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/674\/b70\/cd5\/674b70cd579783e422af1e11f1e22fc2.png\"\/><\/figure>\n<p>\u0417\u0430\u0442\u0435\u043c \u044f \u0432\u0437\u044f\u043b\u0430 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u0442\u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u043d\u043e\u0441\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443<\/p>\n<pre><code class=\"python\">combined_predictions = pd.DataFrame({     'predictions1': predictions1,     'predictions2': predictions2,     'predictions3': predictions3,     'predictions4': predictions4 }) # Calculate the average prediction across all models average_prediction = combined_predictions.mean(axis=1)  from sklearn.metrics import mean_absolute_percentage_error plt.figure(figsize=(15, 5)) plt.plot(average_prediction, marker=\"o\", color = \"red\") plt.plot(test_data, marker=\"o\", color = 'black') plt.ylim(0, 20)  plt.show() print(\"mean absolute error : \",round(mean_absolute_error(test_data, average_prediction),5)) print(\"mean squared error : \",round(mean_squared_error(test_data, average_prediction),5)) print(\"Root mean squared error : \",round(mean_squared_error(test_data, average_prediction,squared=False),5)) print(\"mean relative error\", round(mean_absolute_percentage_error(test_data, average_prediction)), \"%\")<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6aa\/94e\/a49\/6aa94ea49f941d1967e4993d26fbaccd.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\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\u0440\u0430\u0441\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u2014 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f, \u0447\u0451\u0440\u043d\u044b\u0435 \u2014 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\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\u0440\u0430\u0441\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u2014 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f, \u0447\u0451\u0440\u043d\u044b\u0435 \u2014 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\" width=\"2432\" height=\"1832\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6aa\/94e\/a49\/6aa94ea49f941d1967e4993d26fbaccd.png\"\/><\/p>\n<div><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\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: <br \/>\u043a\u0440\u0430\u0441\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u2014 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f, \u0447\u0451\u0440\u043d\u044b\u0435 \u2014 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0412\u044b\u0432\u043e\u0434:<\/strong> <br \/>1. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0442\u0430\u043a\u0443\u044e \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0437-\u0437\u0430 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u043e \u044d\u0442\u043e \u043f\u0438\u0441\u0430\u043b\u0438 \u0441\u0440\u0435\u0434\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/821231\/comments\/#comment_26929477\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u043e\u0432<\/a> \u043a \u043f\u0440\u043e\u0448\u043b\u043e\u043c\u0443 \u043f\u043e\u0441\u0442\u0443.<br \/>2. \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0448\u043a\u0430\u043b\u0443 \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0451 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e. \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0431\u044b\u043b\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u2014 \u043d\u0435 \u0437\u043d\u0430\u044e.<\/p>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044d\u0442\u043e\u0439 &#171;\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439&#187; \u0441\u0435\u0440\u0438\u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430 FEDOT. \u0418 \u0435\u0441\u043b\u0438 \u0443\u0441\u043f\u0435\u044e \u043f\u043e\u0442\u0435\u0441\u0442\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u043d\u0435\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445 \u2014 \u0442\u043e\u0436\u0435 \u043d\u0430\u043f\u0438\u0448\u0443.<\/p>\n<div class=\"persona\"><img decoding=\"async\" class=\"image persona__image\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/11d\/e14\/442\/11de14442440f207b6a8449ad3749443.jpg\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/11d\/e14\/442\/11de14442440f207b6a8449ad3749443.jpg\" data-blurred=\"true\"\/><\/p>\n<h5 class=\"persona__heading\">\u0415\u0440\u043c\u0430\u043a \u041c\u0430\u0440\u0438\u043d\u0430<\/h5>\n<p>\u0410\u043d\u0430\u043b\u0438\u0442\u0438\u043a, SENSE IT<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><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:\/\/habr.com\/ru\/articles\/822987\/\"> https:\/\/habr.com\/ru\/articles\/822987\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412<a href=\"https:\/\/habr.com\/ru\/articles\/821231\/\" rel=\"noopener noreferrer nofollow\"> \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u043f\u043e\u0441\u0442\u0435 <\/a>\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430 \u043f\u0440\u043e \u0441\u0432\u043e\u0438 \u043c\u0443\u0447\u0435\u043d\u0438\u044f \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u043a\u043e\u0439 ARIMA. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0435\u0440\u0438\u0438 \u0438\u0437\u0434\u0435\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432 \u043d\u0430\u0434 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438, SARIMAX \u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0414\u043b\u044f\u00a0\u043d\u0430\u0447\u0430\u043b\u0430 \u0445\u043e\u0447\u0443 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0441\u044f\u043a\u0438 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u043f\u0440\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0432\u0435\u0449\u0438. \u041c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0430\u0431\u0437\u0430\u0446, \u0435\u0441\u043b\u0438 \u0412\u044b \u0438 \u0442\u0430\u043a \u0448\u0430\u0440\u0438\u0442\u0435 \u0432 \u043e\u0441\u043d\u043e\u0432\u0430\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432. <\/p>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u043d\u0443\u0434\u043d\u0430\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p><strong>\u0413\u0430\u0443\u0441\u0441\u043e\u0432(\u0441\u043a\u0438\u0439) \u043f\u0440\u043e\u0446\u0435\u0441\u0441:<\/strong> \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u03bet \u0434\u043b\u044f\u00a0\u043b\u044e\u0431\u044b\u0445 t1,. . ., tn \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 (\u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u043c\u0438), \u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u03bet \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u043c.<\/p>\n<p>\u041a\u0430\u043a \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0432 <a href=\"https:\/\/habr.com\/ru\/articles\/821231\/#comment_26929487\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445<\/a> \u043a \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u043f\u043e\u0441\u0442\u0443, \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u043e\u0441\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0437\u0430\u0448\u0438\u0442\u0430 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f. \u041d\u0435 \u0440\u0438\u0441\u043a\u043d\u0443 \u043b\u0435\u0437\u0442\u044c \u0432\u0433\u043b\u0443\u0431\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043d\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043a\u0440\u0430\u0439\u043d\u0435 \u0446\u0435\u043d\u043d\u043e\u0435. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u044f \u0441\u0442\u0430\u043b\u0430 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435, \u043d\u043e \u0438 \u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 (residuals). \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/articles\/760550\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0417\u0430 \u043d\u0430\u0432\u043e\u0434\u043a\u0443 \u0441\u043f\u0430\u0441\u0438\u0431\u043e @adeshere.<\/p>\n<p><strong>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434:<\/strong> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0432\u043e\u00a0\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0432\u00a0\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438.\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u044f\u0434\u044b \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430\u00a0\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0435 \u0438 \u043d\u0435\u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0435, \u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u00a0\u043d\u0438\u043c\u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e\u00a0\u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0431\u0430\u0437\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/education.yandex.ru\/handbook\/ml\/article\/analitika-vremennyh-ryadov\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u042f\u043d\u0434\u0435\u043a\u0441\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u0443\u0447\u0435\u0431\u043d\u0438\u043a\u0430 \u043f\u043e\u00a0ML\u00a0\u2014 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043a\u043e\u0434\u0430. \u041c\u043d\u0435, \u043a\u0430\u043a \u043d\u043e\u0432\u0438\u0447\u043a\u0443, \u0431\u044b\u043b\u043e \u043a\u0440\u0430\u0439\u043d\u0435 \u0442\u044f\u0436\u0435\u043b\u043e \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443 \u0438 \u043a\u043e\u0434 \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0430.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u043e\u0447\u0438\u0435 \u043a\u043e\u0441\u044f\u043a\u0438 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445 <a href=\"https:\/\/habr.com\/ru\/articles\/821231\/comments\/#comment_26928277\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438<\/a>, \u0447\u0442\u043e ACF \u0438 PACF \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u042f \u0432 \u044d\u0442\u043e\u043c \u0443\u0431\u0435\u0434\u0438\u043b\u0430\u0441\u044c \u043d\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043f\u0435\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u043f\u044b\u0442\u0435, \u043d\u043e \u0435\u0449\u0451 \u0440\u0430\u0437 \u044d\u0442\u043e \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u0437 R, \u043c\u043e\u0434\u0435\u043b\u044c ARCH, Pycaret \u0438 fbprophet.<\/p>\n<\/div>\n<\/details>\n<h2>\u0414\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0437\u0430 2.5 \u0433\u043e\u0434\u0430 \u043f\u043e \u0434\u043d\u044f\u043c, \u0434\u043b\u044f \u043f\u0430\u0440\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u044f \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0430 \u0441\u043a\u043b\u0435\u0438\u0442\u044c \u0435\u0451 \u0432 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0438\u043b\u0438 \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0444\u0438\u0437\u0438\u043a\u0438 \u0437\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0442\u0443\u0442 \u043d\u0435 \u043b\u0435\u0436\u0438\u0442. \u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043d\u043e\u0441\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0441\u044f\u0446 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0430\u0432\u0430\u043b\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438. \u0418 \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u0449\u0451 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u043e\u043b\u043e\u043d\u043a\u0443 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041a\u0430\u043a\u043e\u0439-\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434 \u0431\u044b\u043b \u0443 \u043c\u0435\u043d\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435<\/figcaption><\/div>\n<\/figure>\n<h2>SARIMA<\/h2>\n<p>\u041d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c SARIMA \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043d\u0430\u0434\u0435\u0436\u0434\u044b, \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 ARIMA \u043e\u043d\u0430 \u043c\u043e\u0433\u043b\u0430 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u0441 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0443 \u043d\u0435\u0451 \u0434\u0435\u043b\u0430 \u043e\u0431\u0441\u0442\u043e\u044f\u043b\u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u043b\u0443\u0447\u0448\u0435. \u0412 \u0438\u0442\u043e\u0433\u0435 \u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u043f\u043e \u0434\u043d\u044f\u043c.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u043c \u0440\u044f\u0434\u043e\u043c, \u044f \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439:<\/p>\n<pre><code class=\"python\"> diff1 = df.copy(deep=True)  diff1['1'] = df['1'].diff() diff1['2'] = df['2'].diff() diff1.dropna(inplace=True)<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u043f\u0440\u043e\u0431\u043d\u044b\u0439 \u0442\u044b\u0447\u043e\u043a \u043f\u0430\u043b\u044c\u0446\u0435\u043c \u0432 \u043d\u0435\u0431\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\">from statsmodels.tsa.statespace.sarimax import SARIMAX # Ensure the SARIMAX model is initialized properly with your training data and exogenous variables model = SARIMAX(diff1['1'][:962], exog=diff1['2'][:962], order=(1, 1, 1), seasonal_order=(1, 0, 1, 12))  # Fit the model result = model.fit(disp=False) # Forecast using the correct steps and aligned exogenous data forecast = result.get_forecast(steps=len(df_test), exog=forecast_exog) predictions = result.forecast(len(df_test), exog=forecast_exog) # predictions predictions = pd.Series(predictions.values, index=df_test.index) # If the forecast returns NaNs, check alignment and data quality forecast_df = pd.DataFrame({     'predicted_mean': forecast.predicted_mean,     'lower_ci': forecast.conf_int().iloc[:, 0],     'upper_ci': forecast.conf_int().iloc[:, 1] }, index=df_test.index)<\/code><\/pre>\n<p>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Optuna:<\/p>\n<pre><code class=\"python\"> #Generate all different combinations of p, d and q triplets #Generate all different combinations of p, d, q and s triplets import itertools import optuna  p = range(1, 3)  # Smaller range for non-seasonal AR component d = range(0, 2) q = range(0, 3) P = range(0, 2)  # Smaller range for seasonal AR component D = range(0, 2) Q = range(0, 2) s = 12  pdq = list(itertools.product(p, d, q)) pdqs = [(x[0], x[1], x[2], s) for x in list(itertools.product(P, D, Q))] #%% def objective_sarima(trial):     non_seasonal_order = trial.suggest_categorical('non_seasonal_order', pdq)     seasonal_order = trial.suggest_categorical('seasonal_order', pdqs)     trend = trial.suggest_categorical('trend', ['n', 'c', 't', 'ct', None])          # # Generate predictions     # predictions = mdl.forecast(len(df_test))     model = SARIMAX(diff1['1'][:962], exog=diff1['2'][:962], order=non_seasonal_order, seasonal_order=seasonal_order)     # Fit the model     result = model.fit(disp=True)     # Forecast using the correct steps and aligned exogenous data     forecast = result.get_forecast(steps=len(df_test), exog=forecast_exog)     predictions = result.forecast(len(df_test), exog=forecast_exog)     # predictions     predictions = pd.Series(predictions.values, index=df_test.index)     # If the forecast returns NaNs, check alignment and data quality     forecast_df = pd.DataFrame({         'predicted_mean': forecast.predicted_mean,         'lower_ci': forecast.conf_int().iloc[:, 0],         'upper_ci': forecast.conf_int().iloc[:, 1]     }, index=df_test.index)     # Calculate residuals and error metric     residuals = diff1['1'] - predictions     mse = np.sqrt(np.mean(residuals**2))     return mse  study=optuna.create_study(direction=\"minimize\") study.optimize(objective_sarima,n_trials=10)<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u044f \u043d\u0430 \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u0447\u0430\u0441\u0442\u044c\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0430. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0443\u0441\u0442\u0440\u0430\u0448\u0430\u044e\u0449\u0435:<\/p>\n<pre><code class=\"python\">plt.figure(figsize=(10, 6)) plt.plot(df_test['1'], label='Actual Future', marker='o', color='green') plt.plot(forecast_df['predicted_mean'], label='Forecasted', marker='o', color='red') plt.fill_between(forecast_df.index, forecast_df['lower_ci'], forecast_df['upper_ci'], color='red', alpha=0.2) plt.title('Forecasted vs Actual Counts') plt.xlabel('Date') plt.ylabel('Count') plt.legend() plt.grid(True) plt.xticks(rotation=45) plt.tight_layout() plt.show()<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u041d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u0435 \u0440\u044f\u0434\u044b: \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044f \u0441\u0440\u0430\u0432\u043d\u0438\u043b\u0430 \u0435\u0449\u0451 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u043e\u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u044f\u0434 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438. \u041c\u0435\u043d\u044f \u043f\u0440\u043e\u0441\u0438\u043b\u0438 \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u0432\u0441\u0451 \u0441 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u043e\u0439-\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c, \u0442\u0430\u043a \u0447\u0442\u043e \u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043c\u043e\u043d\u0441\u0442\u0440\u0443\u043e\u0437\u043d\u044b\u0439. \u0422\u0443\u0442 \u0432\u0430\u0436\u043d\u043e \u043e\u043f\u044f\u0442\u044c-\u0442\u0430\u043a\u0438 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u043a\u043e\u0434\u0435 \u043d\u043e\u0441\u0438\u0442 \u0438\u043c\u044f offset. \u0418\u043d\u0430\u0447\u0435 \u044d\u0442\u043e \u0447\u0435\u0445\u043e\u0432\u0441\u043a\u043e\u0435 \u0440\u0443\u0436\u044c\u0451 \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0442 \u0432 \u043d\u043e\u0433\u0443.<\/p>\n<pre><code class=\"python\">#integral constant! offset = int(list(dataset_sends['count_offers'])[-len(df_test)]) print(offset) inverted_forecast = pd.Series(forecast_df['predicted_mean']).cumsum() inverted_forecast = pd.DataFrame(forecast_df['predicted_mean']) inverted_true = pd.DataFrame(list(dataset_sends['count_offers'][-len(df_test):]), index=range(0, len(df_test)))  inverted_forecast = inverted_forecast + offset inverted_forecast = pd.DataFrame(list(inverted_forecast['predicted_mean'][-len(df_test):]), index=range(0, len(df_test))) dates = pd.DataFrame(list(dataset_sends['date'][-len(df_test):]), index=range(0, len(df_test)))  df_merged = pd.concat([inverted_forecast, inverted_true, dates], axis=1)  df_merged.columns = ['predicted_mean', 'count_offers', 'date']  df_merged.dropna(inplace=True) df_merged['1'] = df_merged['1'].apply(int) df_merged['predicted_mean'] = df_merged['predicted_mean'].apply(int) # Absolute Error df_merged['error'] = abs(df_merged['count_offers'] - df_merged['predicted_mean']) df_merged['date'] = pd.to_datetime(df_merged['date']) # Set 'date' column as the index df_merged.set_index('date', inplace=True)  # Group by week and sum the other columns df_merged = df_merged.resample('W').sum()  # Reset index to make 'date' a column again df_merged.reset_index(inplace=True) # Relative Error df_merged['relative_error, %'] = abs(df_merged['count_offers'] - df_merged['predicted_mean']) \/ df_merged['count_offers'] * 100 df_merged.dropna(inplace=True)   display(df_merged[-17:-1]) plt.plot(df_merged.index, df_merged['count_offers'], label='count_offers') # Plot 'predicted_mean' plt.plot(df_merged.index, df_merged['predicted_mean'], label='predicted_mean')  # Set labels and title plt.xlabel('Time') plt.ylabel('Count') plt.title('Comparison of count_offers and predicted_mean') plt.legend()  # Show plot plt.show()<\/code><\/pre>\n<p>\u0423\u0432\u044b, \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443 \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u0438\u0437-\u0437\u0430 NDA, \u0438 \u0442\u0430\u043a \u0445\u043e\u0436\u0443 \u043f\u043e \u043e\u0444\u0438\u0433\u0435\u043d\u043d\u043e \u0442\u043e\u043d\u043a\u043e\u043c\u0443 \u043b\u044c\u0434\u0443:)<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c<\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0412\u044b\u0432\u043e\u0434:<\/strong> \u0445\u043e\u0442\u044f \u044f \u0438 \u043f\u0438\u0442\u0430\u043b\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043d\u0430\u0434\u0435\u0436\u0434\u044b, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 SARIMA \u043c\u0435\u043d\u044f \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u043b. \u0418 \u044f \u043f\u043e\u0448\u043b\u0430 \u0433\u0443\u0433\u043b\u0438\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435, \u0447\u0442\u043e \u0435\u0449\u0451 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043b\u044e\u0434\u0438 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432.<\/p>\n<h2>\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<\/h2>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 <a href=\"https:\/\/education.yandex.ru\/handbook\/ml\/article\/analitika-vremennyh-ryadov\" rel=\"noopener noreferrer nofollow\">\u0443\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0442<\/a> \u0432 \u042f\u043d\u0434\u0435\u043a\u0441-\u0443\u0447\u0435\u0431\u043d\u0438\u043a\u0435 \u043f\u043e ML, \u043d\u043e \u0443\u0434\u0435\u043b\u044f\u044e\u0442 \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u043a\u0430\u043a \u043c\u043e\u0434\u0435\u043b\u044f\u043c ARIMA\/SARIMA. \u0410 \u0432\u043e\u0442 \u043c\u043d\u0435 \u043e\u043d \u0434\u0430\u043b \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u043a\u043b\u0430\u0441\u0441\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u0442\u043e\u0436\u0435 \u044e\u0437\u0430\u043b\u0430 \u043f\u0430\u043a\u0435\u0442\u043d\u0443\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c, \u043b\u0435\u0436\u0430\u0449\u0438\u043c\u0438 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 aust. \u0422\u0430\u043a\u0436\u0435 \u0440\u0443\u043a\u0430\u043c\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043f\u0435\u0440\u0438\u043e\u0434 \u0432 40 \u0434\u043d\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u043b\u0430 \u0440\u0443\u0447\u043a\u0430\u043c\u0438, \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432. \u041d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0442\u0430\u043a:)<\/p>\n<pre><code class=\"python\">import pandas as pd import numpy as np import matplotlib.pyplot as plt from datetime import datetime import statsmodels.api as sm from pandas.plotting import register_matplotlib_converters from statsmodels.tsa.holtwinters import SimpleExpSmoothing from statsmodels.tsa.holtwinters import ExponentialSmoothing from sklearn.metrics import mean_squared_error,mean_absolute_error import warnings from statsmodels.tsa.holtwinters import SimpleExpSmoothing, Holt warnings.filterwarnings('ignore')  period = 40 fit1 = ExponentialSmoothing(     aust,     seasonal_periods=period,     trend=\"add\",     seasonal=\"add\",     use_boxcox=True,     initialization_method=\"estimated\", ).fit() fit2 = ExponentialSmoothing(     aust,     seasonal_periods=period,     trend=\"add\",     seasonal=\"mul\",     use_boxcox=True,     initialization_method=\"estimated\", ).fit() fit3 = ExponentialSmoothing(     aust,     seasonal_periods=period,     trend=\"add\",     seasonal=\"add\",     damped_trend=True,     use_boxcox=True,     initialization_method=\"estimated\", ).fit() fit4 = ExponentialSmoothing(     aust,     seasonal_periods=period,     trend=\"add\",     seasonal=\"mul\",     damped_trend=True,     use_boxcox=True,     initialization_method=\"estimated\", ).fit() results = pd.DataFrame( <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-379242","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379242","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=379242"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379242\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=379242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=379242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=379242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}