{"id":350605,"date":"2023-07-21T15:01:27","date_gmt":"2023-07-21T15:01:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=350605"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=350605","title":{"rendered":"<span>\u0423\u043b\u0443\u0447\u0448\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b Facebook* Prophet \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e LightGBM \u0438 Optuna<\/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 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u0445 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 <em>Facebook Prophet<\/em>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0443\u0434\u0435\u043b\u044f\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c, \u043a\u0430\u043a denoising \u0438\u043b\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, box-cox), \u0430 \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u0443\u044e\u0441\u044c \u043d\u0430 \u0434\u0432\u0443\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e, \u043d\u0435 \u0432\u043d\u043e\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>\u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u043e\u0431\u0437\u043e\u0440\u044b <em>Prophet<\/em> (<a href=\"https:\/\/habr.com\/ru\/companies\/ods\/articles\/323730\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c\u0441\u044f \u043a\u0440\u0430\u0442\u043a\u0438\u043c \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c. <em>Prophet<\/em> \u2014 \u044d\u0442\u043e \u0430\u0434\u0434\u0438\u0442\u0438\u0432\u043d\u0430\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c (GAM) \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0442\u0440\u0435\u043d\u0434, \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043a\u0438 \u0438 \u0442.\u0434.). \u0414\u0430\u0436\u0435 \u0441\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u043b\u0438\u0437\u0430 <em>Prophet<\/em> \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043b\u0443\u0447\u0448\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (univariate forecasting).<\/p>\n<p>\u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 Prophet \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b, \u043d\u043e \u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043a\u0430\u043a\u00a0\u0434\u043b\u044f\u00a0\u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f\u00a0\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0438\u0434\u0435\u044f: \u00ab\u041f\u043e\u0447\u0435\u043c\u0443\u00a0\u0431\u044b \u043d\u0435\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u00a0\u043a\u0430\u043a\u043e\u0439\u2011\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438?\u00bb. \u042d\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430\u00a0\u0441\u0442\u0435\u043a\u0438\u043d\u0433, \u0433\u0434\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0435\u0440\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u0430-\u043c\u043e\u0434\u0435\u043b\u044c\u044e. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0438 \u0438\u043d\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 Microsoft Azure ML.<\/p>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u2014 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 Prophet&#8217;\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0448\u043a\u0430\u043b\u0430\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 (\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043b\u0438 \u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0445). \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043c\u043e\u0436\u043d\u043e \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0443\u043c\u043c\u0443, \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0438\u043b\u0438 \u043c\u0435\u0434\u0438\u0430\u043d\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 Prophet \u043d\u0430 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0430-\u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u043b\u044e\u0434\u0438\u0439, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u0432\u0441\u0435\u0445 \u0442\u0440\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u00ab\u0412\u0430\u043d\u0438\u043b\u044c\u043d\u044b\u0439\u00bb Prophet<\/p>\n<\/li>\n<li>\n<p>Prophet + LightGBM<\/p>\n<\/li>\n<li>\n<p>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 Prophet \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c LightGBM \u0438 \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u0442\u0438\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u044f\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0430 \u0441 2014 \u043f\u043e 2016 \u0433\u043e\u0434\u044b \u0432 \u0440\u0430\u0437\u0440\u0435\u0437\u0435 \u0434\u043d\u044f (<a href=\"https:\/\/www.kaggle.com\/datasets\/bobnau\/daily-website-visitors\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>). \u0414\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u0440\u043e\u043c\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 30 \u0434\u043d\u0435\u0439, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043e\u0431\u0449\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u2014 <em>Page.Loads<\/em>.<\/p>\n<pre><code class=\"python\">import pandas as pd   data['ds'] = pd.to_datetime(data['Date']) data = data.drop('Date', axis=1) data = data.rename(columns={'Page.Loads': 'y'}) data['y'] = data['y'].str.replace(',', '').astype(float) data = data[['ds', 'y']]  train_series = data[data.ds &lt; (data.ds.max() - timedelta(days=30))].copy() test_series = data[data.ds >= (data.ds.max() - timedelta(days=30))].copy()<\/code><\/pre>\n<p>Prophet \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0433\u0434\u0435 \u043c\u0435\u0442\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <strong><em>ds<\/em><\/strong>, \u0430 \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u2014 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <strong><em>y<\/em><\/strong>.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434. \u041c\u044b \u0432\u0438\u0434\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u0430 \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0448\u0443\u043c\u0430. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u0435\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u044f\u0434 \u0438 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0430\u043d\u0430\u043b\u0438\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0440\u0430\u0437\u0443.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/36a\/798\/ce2\/36a798ce24ed6ef8ab1a8f2922ac1c78.png\" alt=\"\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434\" title=\"\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434\" width=\"1938\" height=\"522\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/36a\/798\/ce2\/36a798ce24ed6ef8ab1a8f2922ac1c78.png\"\/><\/p>\n<div><figcaption>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/407\/1b9\/36c\/4071b936c02a66d08d65f97b8ff687bd.png\" alt=\"\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\" title=\"\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\" width=\"1930\" height=\"582\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/407\/1b9\/36c\/4071b936c02a66d08d65f97b8ff687bd.png\"\/><\/p>\n<div><figcaption>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c<\/figcaption><\/div>\n<\/figure>\n<h2>Vanilla Prophet<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0443\u0447\u0438\u043c Prophet \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0438 \u043e\u0446\u0435\u043d\u0438\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f. \u041f\u0440\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <em>suppress_stdout_stderr<\/em> \u0434\u043b\u044f \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043b\u043e\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 C-\u0448\u043d\u044b\u0439 \u0431\u044d\u043a\u044d\u043d\u0434. \u041a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u044f \u043f\u043e\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 Issues \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c GitHub <em>Prophet<\/em> (<a href=\"https:\/\/github.com\/facebook\/prophet\/issues\/223#issuecomment-310497971\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>).<\/p>\n<pre><code class=\"python\">import prophet import numpy as np from sklearn.metrics import mean_squared_error, mean_absolute_percentage_error   fb = prophet.Prophet()  with suppress_stdout_stderr():     fb.fit(train_series)  predictions = fb.make_future_dataframe(periods=len(test_series), freq='D') forecast = fb.predict(predictions)  v_fb_df = test_series.copy() v_fb_df = v_fb_df.merge(forecast[['ds', 'yhat']], on='ds', how='left')<\/code><\/pre>\n<pre><code class=\"python\">np.sqrt(mean_squared_error(v_fb_df['y'], v_fb_df['yhat']))  >>> 512.2325266529127<\/code><\/pre>\n<pre><code class=\"python\">mean_absolute_percentage_error(v_fb_df['y'], v_fb_df['yhat'])  >>> 0.1360530885720578<\/code><\/pre>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b: RMSE = 512.23, MAPE = 0.136. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043d\u0438\u0436\u0435, \u043c\u043e\u0434\u0435\u043b\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0443\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043d\u0438\u0436\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u0430 \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b94\/087\/3d1\/b940873d100df5366729f4b2b786774b.png\" alt=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438\" title=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438\" width=\"1934\" height=\"594\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b94\/087\/3d1\/b940873d100df5366729f4b2b786774b.png\"\/><\/p>\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<h2>Prophet + LGBM<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>LightGBM<\/em>. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <em>LightGBM<\/em>, \u0430 \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u043d\u0430\u0434 \u043d\u0438\u043c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <em>Optuna<\/em>. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 <em>Optuna<\/em>, \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0437\u0430 \u0440\u0430\u0437 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043f\u043e\u0438\u0441\u043a\u0430. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u0435\u043d\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d, \u043d\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Grid Search, \u0433\u0434\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0441 <code>p_1\u00a0* p_2\u00a0* p_3<\/code> \u0434\u043e <code>p_1 + p_2 + p_3<\/code>, \u0433\u0434\u0435 <code>p_n<\/code> \u2014 \u044d\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<pre><code class=\"python\">import optuna import optuna.integration.lightgbm as lgb from optuna.integration.lightgbm import Dataset import pandas as pd import numpy as np   class OptunaLGBMRegressor:     \"\"\"     A wrapper class for the LightGBM Regressor with Optuna for hyperparameters tuning     \"\"\"      def __init__(         self,         n_estimators: int,         learning_rate: float = 0.01,         metric: str = 'rmse',         cat_columns: str = 'auto',         seed: int = 42     ):         \"\"\"         Initializes a new instance of the OptunaLGBMRegressor class         \"\"\"         self.params = {             \"n_estimators\": n_estimators,             \"objective\": \"regression\",             \"verbosity\": -1,             \"metric\": metric,             \"learning_rate\": learning_rate,             \"boosting_type\": 'gbdt',             \"random_state\": seed         }         self.cat_columns = cat_columns         self.model = None         self.features = None         self.is_fitted_ = False      def _to_datasets(         self, x_train: pd.DataFrame, y_train: np.ndarray, x_val: pd.DataFrame, y_val: np.ndarray     ) -> (Dataset, Dataset):         \"\"\"         Converts Pandas DataFrames to LightGBM Datasets         \"\"\"         self.features = list(x_train.columns)         X_val = x_val[self.features].copy()         dtrain = Dataset(x_train, label=y_train, categorical_feature=self.cat_columns)         dval = Dataset(X_val, label=y_val, categorical_feature=self.cat_columns)          return dtrain, dval           def fit(self, X_train: pd.DataFrame, y_train: np.ndarray, X_val: pd.DataFrame, y_val: np.ndarray) -> None:         dtrain, dval = self._to_datasets(X_train, y_train, X_val, y_val)                  self.model = lgb.tuner.train(             self.params,             dtrain,             valid_sets=[dtrain, dval],             verbose_eval=0,             early_stopping_rounds=150         )                  self.is_fitted_ = True      def predict(self, X_test: pd.DataFrame) -> np.ndarray:         assert self.is_fitted_, 'Model is not fitted!'         return self.model.predict(X_test[self.features], num_iteration=self.model.best_iteration) <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043e\u0431\u0443\u0447\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 <em>Prophet<\/em>, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440\u044b, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c out-of-time \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0437\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0434\u0430\u0442\u044b \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 (Time Series Split), \u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0447\u0430\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0438\u043b\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440\u044b. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 \u043e\u0434\u0438\u043d \u0433\u043e\u0434, \u043c\u044b \u043e\u0431\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0441\u044f\u0446\u0430\u0445, \u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043d\u0430 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0432\u0438\u0434\u0435\u043b\u0430. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0430\u0448 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (random split), \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439, \u0447\u0442\u043e \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043d\u0435\u0432\u0435\u0440\u043d\u043e. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435, \u043d\u043e \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f.<\/p>\n<pre><code class=\"python\">from sklearn.model_selection import train_test_split   gbt_data = train_series.merge(forecast, on='ds', how='left') train_gbt, val_gbt = train_test_split(gbt_data, test_size=0.15, random_state=42)  lgbm = OptunaLGBMRegressor(n_estimators=300, learning_rate=0.03, metric='mape', seed=42)  lgbm.fit(     train_gbt.drop(['ds', 'y'], 1), train_gbt.y.values,     val_gbt.drop(['ds', 'y'], 1), val_gbt.y.values )  test_gbt = test_series.merge(forecast, on='ds', how='left') preds = lgbm.predict(test_gbt.drop(['ds', 'y'], 1))  forecast_df = test_gbt[['ds', 'y', 'yhat']].copy() forecast_df['gbt_yhat'] = preds<\/code><\/pre>\n<pre><code class=\"python\">np.sqrt(mean_squared_error(forecast_df['y'], forecast_df['gbt_yhat']))  >>> 461.3712552827671<\/code><\/pre>\n<pre><code class=\"python\">mean_absolute_percentage_error(forecast_df['y'], forecast_df['gbt_yhat'])  >>> 0.11717199190922199<\/code><\/pre>\n<p>\u041e\u0431\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c LightGBM \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043d\u0430\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c RMSE \u0434\u043e 461.4 \u0438 MAPE \u0434\u043e 0.117. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0435 \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 Prophet \u0441 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c\u044e <em>LightGBM<\/em> \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/630\/b26\/836\/630b26836aa94b820e0b9b3bc4415ab1.png\" alt=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 (LGBM \u2014 \u0437\u0435\u043b\u0451\u043d\u044b\u0439)\" title=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 (LGBM \u2014 \u0437\u0435\u043b\u0451\u043d\u044b\u0439)\" width=\"1924\" height=\"568\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/630\/b26\/836\/630b26836aa94b820e0b9b3bc4415ab1.png\"\/><\/p>\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 (LGBM \u2014 \u0437\u0435\u043b\u0451\u043d\u044b\u0439)<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u0435\u043b!<\/p>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e <em>Prophet<\/em> \u0438 <em>LightGBM<\/em>, \u043c\u044b \u0432 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043c\u0435\u0440\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0433\u0440\u0430\u043d\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043b\u0438 \u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u043c\u0438\u043d\u0443\u0442\u043d\u044b\u0445 \u0438\u043b\u0438 \u0434\u043d\u0435\u0432\u043d\u044b\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u044d\u0442\u043e \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u043e\u0442\u043d\u043e\u0441\u0442\u044f\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0443\u0447\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u0430 <em>Prophet<\/em> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u00ab\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u043e\u0441\u0442\u044c\u00a0\u2014 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00bb.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u044f\u0434\u044b \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u0434\u0438\u043d \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u0430\u043b\u044f\u0442\u044c \u043d\u0435\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>(\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043a\u043e\u0432, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 (\u0434\u043b\u044f \u043d\u0443\u0436\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u044b) \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <em>holidays<\/em>).<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439, \u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0440\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0440\u0443\u0442\u0438\u043d\u0443 \u043f\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <em>Prophet<\/em>.<\/p>\n<pre><code class=\"python\">import re import pandas as pd from typing import Optional from itertools import product from tqdm import tqdm from holidays.holiday_base import HolidayBase from prophet import Prophet   class ProphetsEnsemble:     \"\"\"An ensemble of Prophet models with different aggregation functions and frequencies.\"\"\"      def __init__(self, freq: str, levels: list, agg_fn: list, holidays_getter: HolidayBase = None):         \"\"\"Initializes an ensemble of Prophet models.\"\"\"         self.freq = freq         self.levels = ['_'.join(x) for x in product(levels, agg_fn)]         self.h_getter = holidays_getter         self.prophets_ = dict()         self.is_fitted_ = False          @staticmethod     def _resample(data: pd.DataFrame, freq: str, how: str) -> pd.DataFrame:         \"\"\"Resamples a time series DataFrame.\"\"\"         if how not in ['median', 'mean', 'sum']:             raise NotImplementedError(f'Unknown function {how}. Only [median, mean, sum] are supported.')          return data.set_index('ds').resample(freq).agg(how).reset_index(drop=False)      @staticmethod     def _merge_key_gen(x, level: str) -> str:         \"\"\"Generates a key for merging DataFrames based on the frequency.\"\"\"         freq = re.sub('[\\d]', '', level.split('_')[0])         if freq == 'H':             return f'{x.year}-{x.month}-{x.day}-{x.hour}'         elif freq in ['D', 'M']:             return f'{x.year}-{x.month}-{x.day}' if freq == 'D' else f'{x.year}-{x.month}'         elif freq == 'W':             return f'{x.year}-{x.week}'         raise NotImplementedError(f'Only [H, D, W, M] are supported. {freq} was recieved as input!')          def _get_holidays(self, data: pd.DataFrame) -> Optional[pd.DataFrame]:         \"\"\"Extracts holidays from the data.\"\"\"         if self.h_getter is None:             return None         holidays = data[['ds']].copy()         holidays['holiday'] = holidays['ds'].apply(self.h_getter.get)         return holidays.dropna()          def _fit_level(self, data: pd.DataFrame, level: str) -> None:         \"\"\"Fits a Prophet model for a specific aggregation level.\"\"\"         resampled = self._resample(data, *level.split('_')) if level != self.freq else data.copy()         fb = Prophet(holidays=self._get_holidays(resampled))         with suppress_stdout_stderr():             fb.fit(resampled)         self.prophets_[level] = fb              def _predict_level(self, periods: int, level: str) -> pd.DataFrame:         \"\"\"Makes predictions for a specific aggregation level.\"\"\"         fb = self.prophets_[level]         df = fb.make_future_dataframe(periods=periods, freq=level.split('_')[0])         forecasts = fb.predict(df)         forecasts.columns = [f'{x}_{level}' for x in forecasts.columns]         return forecasts          def _combine_levels(self, base_df: pd.DataFrame, data: pd.DataFrame, level: str) -> pd.DataFrame:         \"\"\"Combines predictions from different aggregation levels.\"\"\"         key = lambda x: self._merge_key_gen(x, level)         return (             base_df.assign(key=base_df['ds'].apply(key))             .merge(data.assign(key=data[f'ds_{level}'].apply(key)), on='key', how='left')             .drop(['key', f'ds_{level}'], axis=1)         )          @staticmethod     def _drop_redundant(data: pd.DataFrame) -> pd.DataFrame:         \"\"\"Drops redundant features from the DataFrame.\"\"\"         redundant = [col for col in data.columns if col != 'ds' and 'yhat' not in col and len(data[col].unique()) == 1]         return data.drop(redundant, axis=1)          def fit(self, data: pd.DataFrame) -> None:         \"\"\"Fits the Prophet models for all aggregation levels.\"\"\"         for level in tqdm([self.freq] + self.levels, 'Fitting prophets...'):             self._fit_level(data, level)         self.is_fitted_ = True                  def forecast(self, periods: int) -> pd.DataFrame:         \"\"\"Makes forecasts for all aggregation levels and combines them.\"\"\"         assert self.is_fitted_, 'Model is not fitted'         forecasts = [self._predict_level(periods, level) for level in tqdm([self.freq] + self.levels, 'Forecasting...')]                  forecast = forecasts[0].rename(columns={f'ds_{self.freq}': 'ds'})         for level, fore in zip(self.levels, forecasts[1:]):             forecast = self._combine_levels(forecast, fore, level)                      return self._drop_redundant(forecast)<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c <em>LightGBM<\/em>+<em>Optuna<\/em>.<\/p>\n<pre><code class=\"python\">pe = ProphetsEnsemble(freq='D', levels=['W', 'M'], agg_fn=['mean', 'median']) pe.fit(train_series) pe_forecast = pe.forecast(len(test_series))  gbt_data = train_series.merge(pe_forecast, on='ds', how='left') train_gbt, val_gbt = train_test_split(gbt_data, test_size=0.15, random_state=42)  lgbm = OptunaLGBMRegressor(n_estimators=300, learning_rate=0.03, metric='mape', seed=42)  lgbm.fit(     train_gbt.drop(['ds', 'y'], 1), train_gbt.y.values,     val_gbt.drop(['ds', 'y'], 1), val_gbt.y.values )  test_gbt = test_series.merge(pe_forecast, on='ds', how='left') preds = lgbm.predict(test_gbt.drop(['ds', 'y'], 1)) forecast_df['pe_yhat'] = preds<\/code><\/pre>\n<pre><code class=\"python\">np.sqrt(mean_squared_error(forecast_df['y'], forecast_df['pe_yhat']))  >>> 429.81662049975967<\/code><\/pre>\n<pre><code class=\"python\">mean_absolute_percentage_error(forecast_df['y'], forecast_df['pe_yhat'])  >>> 0.09649907311310414<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043c\u0435\u0442\u043e\u0434 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u0435\u0449\u0435 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439. \u041d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0438\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u0430 \u0437\u0430\u043d\u0438\u0436\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0435, \u0430 \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0431\u043b\u0438\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u043a \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7e8\/afe\/ecc\/7e8afeecce48edc14bb133c9ded39907.png\" alt=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 (\u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u2014 \u043a\u0440\u0430\u0441\u043d\u044b\u0439)\" title=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 (\u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u2014 \u043a\u0440\u0430\u0441\u043d\u044b\u0439)\" width=\"1926\" height=\"578\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7e8\/afe\/ecc\/7e8afeecce48edc14bb133c9ded39907.png\"\/><\/p>\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 (\u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u2014 \u043a\u0440\u0430\u0441\u043d\u044b\u0439)<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u043d\u0430 \u043e\u0434\u0438\u043d \u0448\u0430\u0433 \u0432\u043f\u0435\u0440\u0451\u0434 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u043c, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u0435\u0431\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442.<\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432. \u041f\u043e\u043b\u043d\u044b\u0439 \u043d\u043e\u0443\u0442\u0431\u0443\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435: <a href=\"https:\/\/github.com\/andreychubin95\/prophet_improvement\" rel=\"noopener noreferrer nofollow\">GitHub<\/a>.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<p><sub>* Facebook \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Meta, \u043f\u0440\u0438\u0437\u043d\u0430\u043d\u043d\u043e\u0439 \u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0438\u0441\u0442\u0441\u043a\u043e\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u043e\u0439 \u0432 \u0420\u0424<\/sub>  <\/p>\n<\/p>\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\/749604\/\"> https:\/\/habr.com\/ru\/articles\/749604\/<\/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 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u0445 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 <em>Facebook Prophet<\/em>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0443\u0434\u0435\u043b\u044f\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c, \u043a\u0430\u043a denoising \u0438\u043b\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, box-cox), \u0430 \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u0443\u044e\u0441\u044c \u043d\u0430 \u0434\u0432\u0443\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e, \u043d\u0435 \u0432\u043d\u043e\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>\u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u043e\u0431\u0437\u043e\u0440\u044b <em>Prophet<\/em> (<a href=\"https:\/\/habr.com\/ru\/companies\/ods\/articles\/323730\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c\u0441\u044f \u043a\u0440\u0430\u0442\u043a\u0438\u043c \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c. <em>Prophet<\/em> \u2014 \u044d\u0442\u043e \u0430\u0434\u0434\u0438\u0442\u0438\u0432\u043d\u0430\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c (GAM) \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0442\u0440\u0435\u043d\u0434, \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043a\u0438 \u0438 \u0442.\u0434.). \u0414\u0430\u0436\u0435 \u0441\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u043b\u0438\u0437\u0430 <em>Prophet<\/em> \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043b\u0443\u0447\u0448\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (univariate forecasting).<\/p>\n<p>\u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 Prophet \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b, \u043d\u043e \u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043a\u0430\u043a\u00a0\u0434\u043b\u044f\u00a0\u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f\u00a0\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0438\u0434\u0435\u044f: \u00ab\u041f\u043e\u0447\u0435\u043c\u0443\u00a0\u0431\u044b \u043d\u0435\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u00a0\u043a\u0430\u043a\u043e\u0439\u2011\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438?\u00bb. \u042d\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430\u00a0\u0441\u0442\u0435\u043a\u0438\u043d\u0433, \u0433\u0434\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0435\u0440\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u0430-\u043c\u043e\u0434\u0435\u043b\u044c\u044e. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0438 \u0438\u043d\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 Microsoft Azure ML.<\/p>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u2014 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 Prophet&#8217;\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0448\u043a\u0430\u043b\u0430\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 (\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043b\u0438 \u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0445). \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043c\u043e\u0436\u043d\u043e \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0443\u043c\u043c\u0443, \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0438\u043b\u0438 \u043c\u0435\u0434\u0438\u0430\u043d\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 Prophet \u043d\u0430 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0430-\u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u043b\u044e\u0434\u0438\u0439, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u0432\u0441\u0435\u0445 \u0442\u0440\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u00ab\u0412\u0430\u043d\u0438\u043b\u044c\u043d\u044b\u0439\u00bb Prophet<\/p>\n<\/li>\n<li>\n<p>Prophet + LightGBM<\/p>\n<\/li>\n<li>\n<p>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 Prophet \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c LightGBM \u0438 \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u0442\u0438\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u044f\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0430 \u0441 2014 \u043f\u043e 2016 \u0433\u043e\u0434\u044b \u0432 \u0440\u0430\u0437\u0440\u0435\u0437\u0435 \u0434\u043d\u044f (<a href=\"https:\/\/www.kaggle.com\/datasets\/bobnau\/daily-website-visitors\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>). \u0414\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u0440\u043e\u043c\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 30 \u0434\u043d\u0435\u0439, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043e\u0431\u0449\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u2014 <em>Page.Loads<\/em>.<\/p>\n<pre><code class=\"python\">import pandas as pd   data['ds'] = pd.to_datetime(data['Date']) data = data.drop('Date', axis=1) data = data.rename(columns={'Page.Loads': 'y'}) data['y'] = data['y'].str.replace(',', '').astype(float) data = data[['ds', 'y']]  train_series = data[data.ds &lt; (data.ds.max() - timedelta(days=30))].copy() test_series = data[data.ds >= (data.ds.max() - timedelta(days=30))].copy()<\/code><\/pre>\n<p>Prophet \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0433\u0434\u0435 \u043c\u0435\u0442\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <strong><em>ds<\/em><\/strong>, \u0430 \u0446\u0435\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u2014 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <strong><em>y<\/em><\/strong>.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434. \u041c\u044b \u0432\u0438\u0434\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u0430 \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0448\u0443\u043c\u0430. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u0435\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u044f\u0434 \u0438 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0430\u043d\u0430\u043b\u0438\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0440\u0430\u0437\u0443.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\">\n<div><figcaption>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c<\/figcaption><\/div>\n<\/figure>\n<h2>Vanilla Prophet<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0443\u0447\u0438\u043c Prophet \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0438 \u043e\u0446\u0435\u043d\u0438\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f. \u041f\u0440\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <em>suppress_stdout_stderr<\/em> \u0434\u043b\u044f \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043b\u043e\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 C-\u0448\u043d\u044b\u0439 \u0431\u044d\u043a\u044d\u043d\u0434. \u041a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u044f \u043f\u043e\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 Issues \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c GitHub <em>Prophet<\/em> (<a href=\"https:\/\/github.com\/facebook\/prophet\/issues\/223#issuecomment-310497971\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>).<\/p>\n<pre><code class=\"python\">import prophet import numpy as np from sklearn.metrics import mean_squared_error, mean_absolute_percentage_error   fb = prophet.Prophet()  with suppress_stdout_stderr():     fb.fit(train_series)  predictions = fb.make_future_dataframe(periods=len(test_series), freq='D') forecast = fb.predict(predictions)  v_fb_df = test_series.copy() v_fb_df = v_fb_df.merge(forecast[['ds', 'yhat']], on='ds', how='left')<\/code><\/pre>\n<pre><code class=\"python\">np.sqrt(mean_squared_error(v_fb_df['y'], v_fb_df['yhat']))  >>> 512.2325266529127<\/code><\/pre>\n<pre><code class=\"python\">mean_absolute_percentage_error(v_fb_df['y'], v_fb_df['yhat'])  >>> 0.1360530885720578<\/code><\/pre>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b: RMSE = 512.23, MAPE = 0.136. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043d\u0438\u0436\u0435, \u043c\u043e\u0434\u0435\u043b\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0443\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043d\u0438\u0436\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u0430 \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<h2>Prophet + LGBM<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>LightGBM<\/em>. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <em>LightGBM<\/em>, \u0430 \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u043d\u0430\u0434 \u043d\u0438\u043c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <em>Optuna<\/em>. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 <em>Optuna<\/em>, \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0437\u0430 \u0440\u0430\u0437 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043f\u043e\u0438\u0441\u043a\u0430. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u0435\u043d\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d, \u043d\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Grid Search, \u0433\u0434\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0441 <code>p_1\u00a0* p_2\u00a0* p_3<\/code> \u0434\u043e <code>p_1 + p_2 + p_3<\/code>, \u0433\u0434\u0435 <code>p_n<\/code> \u2014 \u044d\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<pre><code class=\"python\">import optuna import optuna.integration.lightgbm as lgb from optuna.integration.lightgbm import Dataset import pandas as pd import numpy as np   class OptunaLGBMRegressor:     \"\"\"     A wrapper class for the LightGBM Regressor with Optuna for hyperparameters tuning     \"\"\"      def __init__(         self,         n_estimators: int,         learning_rate: float = 0.01,         metric: str = 'rmse',         cat_columns: str = 'auto',         seed: int = 42     ):         \"\"\"         Initializes a new instance of the OptunaLGBMRegressor class         \"\"\"         self.params = {             \"n_estimators\": n_estimators,             \"objective\": \"regression\",             \"verbosity\": -1,             \"metric\": metric,             \"learning_rate\": learning_rate,             \"boosting_type\": 'gbdt',             \"random_state\": seed         }         self.cat_columns = cat_columns         self.model = None         self.features = None         self.is_fitted_ = False      def _to_datasets(         self, x_train: pd.DataFrame, y_train: np.ndarray, x_val: pd.DataFrame, y_val: np.ndarray     ) -> (Dataset, Dataset):         \"\"\"         Converts Pandas DataFrames to LightGBM Datasets         \"\"\"         self.features = list(x_train.columns)         X_val = x_val[self.features].copy()         dtrain = Dataset(x_train, label=y_train, categorical_feature=self.cat_columns)         dval = Dataset(X_val, label=y_val, categorical_feature=self.cat_columns)          return dtrain, dval           def fit(self, X_train: pd.DataFrame, y_train: np.ndarray, X_val: pd.DataFrame, y_val: np.ndarray) -> None:         dtrain, dval = self._to_datasets(X_train, y_train, X_val, y_val)                  self.model = lgb.tuner.train(             self.params,             dtrain,             valid_sets=[dtrain, dval],             verbose_eval=0,             early_stopping_rounds=150         )                  self.is_fitted_ = True      def predict(self, X_test: pd.DataFrame) -> np.ndarray:         assert self.is_fitted_, 'Model is not fitted!'         return self.model.predict(X_test[self.features], num_iteration=self.model.best_iteration) <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043e\u0431\u0443\u0447\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 <em>Prophet<\/em>, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440\u044b, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c out-of-time \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0437\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0434\u0430\u0442\u044b \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 (Time Series Split), \u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0447\u0430\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0438\u043b\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440\u044b. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 \u043e\u0434\u0438\u043d \u0433\u043e\u0434, \u043c\u044b \u043e\u0431\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0441\u044f\u0446\u0430\u0445, \u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043d\u0430 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0432\u0438\u0434\u0435\u043b\u0430. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0430\u0448 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (random split), \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439, \u0447\u0442\u043e \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043d\u0435\u0432\u0435\u0440\u043d\u043e. \u042f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435, \u043d\u043e \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f.<\/p>\n<pre><code class=\"python\">from sklearn.model_selection import train_test_split   gbt_data = train_series.merge(forecast, on='ds', how='left') train_gbt, val_gbt = train_test_split(gbt_data, test_size=0.15, random_state=42)  lgbm = OptunaLGBMRegressor(n_estimators=300, learning_rate=0.03, metric='mape', seed=42)  lgbm.fit(     train_gbt.drop(['ds', 'y'], 1), train_gbt.y.values,     val_gbt.drop(['ds', 'y'], 1), val_gbt.y.values )  test_gbt = test_series.merge(forecast, on='ds', how='left') preds = lgbm.predict(test_gbt.drop(['ds', 'y'], 1))  forecast_df = test_gbt[['ds', 'y', 'yhat']].copy() forecast_df['gbt_yhat'] = preds<\/code><\/pre>\n<pre><code class=\"python\">np.sqrt(mean_squared_error(forecast_df['y'], forecast_df['gbt_yhat']))  >>> 461.3712552827671<\/code><\/pre>\n<pre><code class=\"python\">mean_absolute_percentage_error(forecast_df['y'], forecast_df['gbt_yhat'])  >>> 0.11717199190922199<\/code><\/pre>\n<p>\u041e\u0431\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c LightGBM \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043d\u0430\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c RMSE \u0434\u043e 461.4 \u0438 MAPE \u0434\u043e 0.117. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0435 \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 Prophet \u0441 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c\u044e <em>LightGBM<\/em> \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 (LGBM \u2014 \u0437\u0435\u043b\u0451\u043d\u044b\u0439)<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u0435\u043b!<\/p>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e <em>Prophet<\/em> \u0438 <em>LightGBM<\/em>, \u043c\u044b \u0432 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043c\u0435\u0440\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0433\u0440\u0430\u043d\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0435\u0433\u043e<\/p>\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-350605","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350605","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=350605"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350605\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}