{"id":370500,"date":"2024-05-21T04:26:41","date_gmt":"2024-05-21T04:26:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=370500"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T04:26:41","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=370500","title":{"rendered":"<span>\u0421\u0442\u0435\u043a\u0438\u043d\u0433 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u0432 ML. \u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 Python<\/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<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4b5\/1d6\/9fe\/4b51d69fe6be1cc5fe8231b5a4da7cab.png\" width=\"746\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4b5\/1d6\/9fe\/4b51d69fe6be1cc5fe8231b5a4da7cab.png\"\/><\/figure>\n<p>\u0421\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0430\u043d\u0441\u0430\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0442 \u0434\u0432\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043a\u0430\u043a\u00a0<em>\u0441\u0442\u0435\u043a\u0438\u043d\u0433<\/em>\u00a0(stacked generalization) \u0438\u00a0<em>\u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433<\/em>, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u044b\u0445, \u043d\u043e \u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u043d \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437.<\/p>\n<p>\u0421\u0442\u0435\u043a\u0438\u043d\u0433 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u043e\u0447\u0435\u043d\u044c \u0441\u0445\u043e\u0436\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u043e\u0434\u043d\u0430\u043a\u043e \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0435\u0441\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<blockquote>\n<p><em>\u041d\u043e\u0443\u0442\u0431\u0443\u043a \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0430\u00a0<\/em><a href=\"https:\/\/www.kaggle.com\/code\/egazakharenko\/stacking-blending-in-ml-from-scratch-in-python\" rel=\"noopener noreferrer nofollow\"><strong><em>Kaggle<\/em><\/strong><\/a><em>\u00a0(eng) \u0438\u00a0<\/em><a href=\"https:\/\/github.com\/egaoharu-kensei\/ML-algorithms-from-scratch.-Course-for-beginners\/blob\/main\/Notebooks%20%5Brus%5D\/ML-%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC%D1%8B%20%D1%81%20%D0%BD%D1%83%D0%BB%D1%8F\/11%29%20%D0%A1%D1%82%D0%B5%D0%BA%D0%B8%D0%BD%D0%B3%20%26%20%D0%91%D0%BB%D0%B5%D0%BD%D0%B4%D0%B8%D0%BD%D0%B3.ipynb\" rel=\"noopener noreferrer nofollow\"><strong><em>GitHub<\/em><\/strong><\/a><em>\u00a0(rus).<\/em>  <\/p>\n<\/blockquote>\n<h4>Stacking<\/h4>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439. \u0414\u0430\u043b\u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e k-fold \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 k \u0444\u043e\u043b\u0434\u043e\u0432. \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 k-1 \u0444\u043e\u043b\u0434\u0430\u0445 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u043c\u0441\u044f. \u0414\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u043e\u043b\u0434\u0430 \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 k-fold \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043a\u0430\u043a \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a. \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0448\u0430\u0433\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u0440\u0433\u0435\u0442 <em>y_train<\/em> \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u043e\u0432\u044b\u043c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u043c. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0451\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440.<\/p>\n<p>\u041d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 (\u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445) \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u0430\u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ea4\/164\/e53\/ea4164e53a87ddf18692fdd5424d0446.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430\" title=\"\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430\" width=\"1815\" height=\"959\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ea4\/164\/e53\/ea4164e53a87ddf18692fdd5424d0446.png\"\/><\/p>\n<div><figcaption><strong>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430<\/strong><\/figcaption><\/div>\n<\/figure>\n<h4>Blending<\/h4>\n<p>\u0411\u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430. \u0422\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 2 \u0447\u0430\u0441\u0442\u0438: \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u0443\u044e \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e hold-out \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438. \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043a\u0430\u043a \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c, \u0442\u0430\u043a \u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435. \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0448\u0430\u0433 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438: \u043a \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u043c \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u0440\u0433\u0435\u0442\u00a0<em>y_val<\/em>\u00a0\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e, \u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e.<\/p>\n<p>\u041d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 (\u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445) \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u0430\u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dff\/5d7\/285\/dff5d7285fd775b9d9eae386d9523b98.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433\u0430\" title=\"\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433\u0430\" width=\"1203\" height=\"511\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dff\/5d7\/285\/dff5d7285fd775b9d9eae386d9523b98.png\"\/><\/p>\n<div><figcaption><strong>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433\u0430<\/strong><\/figcaption><\/div>\n<\/figure>\n<h4>\u0411\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438<\/h4>\n<p>\u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433\u0430 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f\u00a0<strong>\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u0430\u044f \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0434\u0440\u0430\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u041d\u0435\u0442\u0440\u0443\u0434\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043d\u0430\u0431\u043e\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438. \u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 scikit-learn \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u00a0<em>joblib<\/em>, \u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u044f\u0434\u0435\u0440 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u00a0<em>n_jobs<\/em>\u00a0(\u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 -1 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u044f\u0434\u0440\u0430). \u0412 \u0440\u0443\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0438\u0436\u0435 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0415\u0449\u0451 \u0441\u0442\u043e\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0441\u0442\u0435\u043a\u0438\u043d\u0433 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c\u00a0<strong>\u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0439\u043d\u044b\u043c\u0438<\/strong>, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c, \u0430 \u0437\u0430\u0442\u0435\u043c \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435. \u0418\u043d\u043e\u0433\u0434\u0430 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0438\u043c\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u0441\u044f.<\/p>\n<blockquote>\n<p><em>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 scikit-learn \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c 1 \u0444\u043e\u043b\u0434 \u0434\u043b\u044f \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0434\u0430\u043b\u0451\u043d\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433.<\/em>  <\/p>\n<\/blockquote>\n<h4>\u0418\u043c\u043f\u043e\u0440\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/h4>\n<pre><code class=\"python\">import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.datasets import load_diabetes from sklearn.preprocessing import LabelEncoder from sklearn.metrics import accuracy_score, mean_absolute_percentage_error from sklearn.model_selection import train_test_split, cross_val_predict from sklearn.svm import SVC from sklearn.linear_model import RidgeCV, LogisticRegression from sklearn.ensemble import StackingClassifier, StackingRegressor from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor from sklearn.ensemble import GradientBoostingClassifier, GradientBoostingRegressor from joblib import Parallel, delayed from mlxtend.plotting import plot_decision_regions<\/code><\/pre>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u043d\u0443\u043b\u044f<\/h4>\n<pre><code class=\"python\">class Stacking:     def __init__(self, estimators, final_estimator, blending=False, cv=5, n_jobs=-1):         self.estimators = estimators         self.final_estimator = final_estimator         self.blending = blending         self.cv = cv         self.n_jobs = n_jobs      def _X_pred(self, estimator, data):         if self.blending:             X_train_v, y_train_v, X_val = data             return estimator.fit(X_train_v, y_train_v).predict(X_val)         else:             X_train, y_train = data             return cross_val_predict(estimator, X_train, y_train, cv=self.cv)      def _X_test_pred(self, estimator, data):         X_train, y_train, X_test = data          return estimator.fit(X_train, y_train).predict(X_test)      def _meta_data(self, X_train, y_train, X_test):         if self.blending:             #used hold-out cross-validation             X_train_v, X_val, y_train_v, y_val = train_test_split(X_train, y_train, random_state=0)             train_data = [X_train_v, y_train_v, X_val]             test_data = [X_train_v, y_train_v, X_test]             meta_y_train = y_val         else:             train_data = [X_train, y_train]             test_data = [X_train, y_train, X_test]             meta_y_train = y_train          cv_X_train_preds = (delayed(self._X_pred)(est, train_data) for est in self.estimators)         X_test_preds = (delayed(self._X_test_pred)(est, test_data) for est in self.estimators)          meta_X_train = pd.DataFrame(Parallel(n_jobs=self.n_jobs)(cv_X_train_preds))         meta_X_test = pd.DataFrame(Parallel(n_jobs=self.n_jobs)(X_test_preds))          return meta_X_train.T, meta_y_train, meta_X_test.T      def fit_predict(self, X_train, y_train, X_test):         # meta learner or blender         meta_X_train, meta_y_train, meta_X_test = self._meta_data(X_train, y_train, X_test)          return self.final_estimator.fit(meta_X_train, meta_y_train).predict(meta_X_test)<\/code><\/pre>\n<h4>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/h4>\n<pre><code class=\"python\">def decision_boundary_plot(X, y, X_train, y_train, clf, feature_indexes, title=None):     feature1_name, feature2_name = X.columns[feature_indexes]     X_feature_columns = X.values[:, feature_indexes]     X_train_feature_columns = X_train.values[:, feature_indexes]     clf.fit(X_train_feature_columns, y_train.values)      plot_decision_regions(X=X_feature_columns, y=y.values, clf=clf)     plt.xlabel(feature1_name)     plt.ylabel(feature2_name)     plt.title(title)<\/code><\/pre>\n<h4>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432<\/h4>\n<p>\u0414\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d <a href=\"https:\/\/www.kaggle.com\/datasets\/uciml\/glass\" rel=\"noopener noreferrer nofollow\">Glass Classification<\/a> \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0435\u0440\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f \u0441\u0442\u0435\u043a\u043b\u0430 \u043f\u043e \u0435\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Diabetes \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438\u0437 scikit-learn.<\/p>\n<pre><code class=\"python\">df_path = \"\/content\/drive\/MyDrive\/glass.csv\" glass_df = pd.read_csv(df_path) X1, y1 = glass_df.iloc[:, :-1], glass_df.iloc[:, -1] y1 = pd.Series(LabelEncoder().fit_transform(y1)) X1_train, X1_test, y1_train, y1_test = train_test_split(X1, y1, random_state=0) print(glass_df)             RI     Na    Mg    Al     Si     K    Ca    Ba   Fe  Type 0    1.52101  13.64  4.49  1.10  71.78  0.06  8.75  0.00  0.0     1 1    1.51761  13.89  3.60  1.36  72.73  0.48  7.83  0.00  0.0     1 2    1.51618  13.53  3.55  1.54  72.99  0.39  7.78  0.00  0.0     1 3    1.51766  13.21  3.69  1.29  72.61  0.57  8.22  0.00  0.0     1 4    1.51742  13.27  3.62  1.24  73.08  0.55  8.07  0.00  0.0     1 ..       ...    ...   ...   ...    ...   ...   ...   ...  ...   ... 209  1.51623  14.14  0.00  2.88  72.61  0.08  9.18  1.06  0.0     7 210  1.51685  14.92  0.00  1.99  73.06  0.00  8.40  1.59  0.0     7 211  1.52065  14.36  0.00  2.02  73.42  0.00  8.44  1.64  0.0     7 212  1.51651  14.38  0.00  1.94  73.61  0.00  8.48  1.57  0.0     7 213  1.51711  14.23  0.00  2.08  73.36  0.00  8.62  1.67  0.0     7  [214 rows x 10 columns]<\/code><\/pre>\n<pre><code class=\"python\">X2, y2 = load_diabetes(return_X_y=True, as_frame=True) X2_train, X2_test, y2_train, y2_test = train_test_split(X2, y2, random_state=0) print(X2, y2, sep='\\n')             age       sex       bmi        bp        s1        s2        s3  \\ 0    0.038076  0.050680  0.061696  0.021872 -0.044223 -0.034821 -0.043401    1   -0.001882 -0.044642 -0.051474 -0.026328 -0.008449 -0.019163  0.074412    2    0.085299  0.050680  0.044451 -0.005670 -0.045599 -0.034194 -0.032356    3   -0.089063 -0.044642 -0.011595 -0.036656  0.012191  0.024991 -0.036038    4    0.005383 -0.044642 -0.036385  0.021872  0.003935  0.015596  0.008142    ..        ...       ...       ...       ...       ...       ...       ...    437  0.041708  0.050680  0.019662  0.059744 -0.005697 -0.002566 -0.028674    438 -0.005515  0.050680 -0.015906 -0.067642  0.049341  0.079165 -0.028674    439  0.041708  0.050680 -0.015906  0.017293 -0.037344 -0.013840 -0.024993    440 -0.045472 -0.044642  0.039062  0.001215  0.016318  0.015283 -0.028674    441 -0.045472 -0.044642 -0.073030 -0.081413  0.083740  0.027809  0.173816                s4        s5        s6   0   -0.002592  0.019907 -0.017646   1   -0.039493 -0.068332 -0.092204   2   -0.002592  0.002861 -0.025930   3    0.034309  0.022688 -0.009362   4   -0.002592 -0.031988 -0.046641   ..        ...       ...       ...   437 -0.002592  0.031193  0.007207   438  0.034309 -0.018114  0.044485   439 -0.011080 -0.046883  0.015491   440  0.026560  0.044529 -0.025930   441 -0.039493 -0.004222  0.003064    [442 rows x 10 columns] 0      151.0 1       75.0 2      141.0 3      206.0 4      135.0        ...   437    178.0 438    104.0 439    132.0 440    220.0 441     57.0 Name: target, Length: 442, dtype: float64<\/code><\/pre>\n<h4>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432<\/h4>\n<p>\u041a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u0441\u0442\u0435\u043a\u0438\u043d\u0433 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0438 \u043d\u0435 \u0441\u0430\u043c\u044b\u0435 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0434\u0432\u0443\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c: \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u044f\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0442\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043b\u0430\u0431\u044b\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u0438\u043b\u044c\u043d\u044b\u0445, \u0447\u0442\u043e \u0441\u043d\u0438\u0437\u0438\u0442 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0432 \u0446\u0435\u043b\u043e\u043c; \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e, \u0447\u0442\u043e \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 stack_method=&#8217;predict_proba&#8217;, \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u044b\u0434\u0430\u0451\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043a \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0430\u043c\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043d\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438; \u0442\u0430\u043a\u0436\u0435 \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0448\u0443\u043c\u043e\u043c \u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438. \u041f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0434\u0431\u043e\u0440\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0451 \u0432\u044b\u0448\u0435.<\/p>\n<blockquote>\n<p><em>\u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u0442\u0435\u043a\u0438\u043d\u0433 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0447\u0435\u043c \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u0438\u0437-\u0437\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f k-fold \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438, \u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0437\u0430\u043c\u0435\u0442\u043d\u0430 \u043b\u0438\u0448\u044c \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/em><\/p>\n<\/blockquote>\n<p><strong>StackingClassifier &amp; BlendingClassifier<\/strong>  <\/p>\n<pre><code class=\"python\">estimators = [LogisticRegression(random_state=0, max_iter=10000),               GradientBoostingClassifier(random_state=0),               SVC(probability=True, random_state=0)]  estimator = RandomForestClassifier(random_state=0) stacking_clf = Stacking(estimators=estimators, final_estimator=estimator) stacking_pred_res = stacking_clf.fit_predict(X1_train, y1_train, X1_test) stacking_accuracy = accuracy_score(stacking_pred_res, y1_test) print(f'stacking_accuracy: {stacking_accuracy}') print(stacking_pred_res, '', sep='\\n')  blending_clf = Stacking(estimators=estimators, final_estimator=estimator, blending=True) blending_pred_res = blending_clf.fit_predict(X1_train, y1_train, X1_test) blending_accuracy = accuracy_score(blending_pred_res, y1_test) print(f'blending_accuracy: {blending_accuracy}') print(blending_pred_res)   stacking_accuracy: 0.6481481481481481 [5 0 1 4 1 1 0 1 1 1 1 0 1 1 1 5 0 1 0 0 3 0 5 5 0 0 5 0 0 1 0 0 1 0 1 0 0  0 0 5 3 4 1 0 1 1 0 1 0 1 0 4 5 0]  blending_accuracy: 0.6481481481481481 [5 0 1 4 1 1 0 1 1 1 1 0 1 1 1 5 0 1 0 1 5 1 5 5 1 0 5 0 1 1 0 0 1 0 0 0 0  0 0 5 3 5 1 0 1 1 0 1 0 1 0 4 5 0]<\/code><\/pre>\n<p><strong>StackingClassifier (scikit-learn)<\/strong> <strong>\u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0445 \u0433\u0440\u0430\u043d\u0438\u0446<\/strong><\/p>\n<pre><code class=\"python\">sk_estimators = [('lr', LogisticRegression(random_state=0, max_iter=10000)),                  ('gbc', GradientBoostingClassifier(random_state=0)),                  ('svc', SVC(probability=True, random_state=0))]  stack_methods = ('predict', 'predict_proba') estimator = RandomForestClassifier(random_state=0) sk_stacking_clf = StackingClassifier(estimators=sk_estimators, final_estimator=estimator)  feature_indexes = [1, 3] plt.figure(figsize=(12, 5))  for i, method in enumerate(stack_methods):     sk_stacking_clf.stack_method = method     sk_stacking_clf.fit(X1_train, y1_train)     sk_stacking_pred_res = sk_stacking_clf.predict(X1_test)     sk_stacking_accuracy = accuracy_score(sk_stacking_pred_res, y1_test)     print(f'sk_stacking_accuracy with a {method} method: {sk_stacking_accuracy}')     print(sk_stacking_pred_res)      plt.subplot(1, 2, i + 1)     plt.subplots_adjust(hspace=1.5)     title = f'StackingClassifier surface with a {method} method'     decision_boundary_plot(X1, y1, X1_train, y1_train, sk_stacking_clf, feature_indexes, title)   sk_stacking_accuracy with a predict method: 0.6481481481481481 [5 0 1 4 1 1 0 1 1 1 1 0 1 1 1 5 0 1 0 0 3 0 5 5 0 0 5 0 0 1 0 0 1 0 1 0 0  0 0 5 3 4 1 0 1 1 0 1 0 1 0 4 5 0]  sk_stacking_accuracy with a predict_proba method: 0.7592592592592593 [5 0 1 4 3 1 0 1 1 1 1 0 1 1 1 5 0 1 2 2 3 0 5 5 1 0 5 0 1 1 0 0 1 0 1 0 0  2 0 5 5 4 1 0 1 1 0 1 0 1 0 4 5 0]<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4c4\/0fe\/d62\/4c40fed623e782529d146a0687bf8b34.png\" alt=\"predict vs predict_proba method\" title=\"predict vs predict_proba method\" width=\"1006\" height=\"470\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4c4\/0fe\/d62\/4c40fed623e782529d146a0687bf8b34.png\"\/><\/p>\n<div><figcaption><strong>predict vs predict_proba method<\/strong><\/figcaption><\/div>\n<\/figure>\n<p><strong>StackingRegressor &amp; StackingRegressor (scikit-learn)<\/strong>  <\/p>\n<pre><code class=\"python\">reg_estimators = [RandomForestRegressor(random_state=0),                   GradientBoostingRegressor(random_state=0)]  stacking_reg = Stacking(estimators=reg_estimators, final_estimator=RidgeCV()) stacking_reg_pred_res = stacking_reg.fit_predict(X2_train, y2_train, X2_test) stacking_mape = mean_absolute_percentage_error(stacking_reg_pred_res, y2_test) print(f'stacking_regressor_mape {stacking_mape}') print(stacking_reg_pred_res, '', sep='\\n')  sk_reg_estimators = [('rfr', RandomForestRegressor(random_state=0)),                      ('gbr', GradientBoostingRegressor(random_state=0))]  sk_stacking_reg = StackingRegressor(estimators=sk_reg_estimators) sk_stacking_reg.fit(X2_train, y2_train) sk_stacking_reg_pred_res = sk_stacking_reg.predict(X2_test) sk_stacking_mape = mean_absolute_percentage_error(sk_stacking_reg_pred_res, y2_test) print(f'sk_stacking_regressor_mape {sk_stacking_mape}') print(sk_stacking_reg_pred_res)   stacking_regressor_mape 0.3294355656302654 [248.19759057 240.42764024 177.37191492 103.86233455 200.13250024  250.97352765  96.82048975 220.71264013 131.5200259  236.41159677  175.71519802 160.35569454 130.9100711   93.65232358 282.06237765   99.93621948 161.47206754  78.65895059 108.86806694 224.46260151  182.68564834 127.54111953 163.28785267 138.89063619 220.53939703  189.84079506 136.98136758  78.91556812 219.66245835 159.14526636  198.39205847  82.77579781 117.59833274 157.49622357 139.53979064  171.05953707 152.42297469 135.62774138  94.81503188 213.49660018  110.36059875 162.00479518 132.07261264 178.57636808 179.29614901   73.3945309  114.601665   131.93470279 100.32309962 252.57462411  146.00870076  61.92053404 170.56742259 157.92964414 243.28628037  205.27588938 180.79716523 114.89480581 120.80464762 172.87785542  243.4033502  151.64437003 130.09006375 100.99049563 249.91693845  153.00241663  87.45729779 230.20145421 215.78130712  90.82440238   88.24276622 143.91478174 110.89538069 134.84971688 130.50875598  177.97770535 121.87554552 221.70653117 261.76922106 197.7323525  125.88596841 191.96118205  71.8331337  240.12385544 129.00872186   89.92647528 151.49862554 202.71572059 105.9398957  150.37365076  103.92670222 108.23845662  87.0924303  168.01234827 106.55530568   93.81879887 232.8935379  238.29278058 136.22349466 154.71341867  157.80577109 114.83038143 159.25202218 100.13701043 236.14776543  143.92620712 235.19141566 269.14119287 113.39076553  86.51606237  251.53999411]  sk_stacking_regressor_mape 0.3294355656302654 [248.19759057 240.42764024 177.37191492 103.86233455 200.13250024  250.97352765  96.82048975 220.71264013 131.5200259  236.41159677  175.71519802 160.35569454 130.9100711   93.65232358 282.06237765   99.93621948 161.47206754  78.65895059 108.86806694 224.46260151  182.68564834 127.54111953 163.28785267 138.89063619 220.53939703  189.84079506 136.98136758  78.91556812 219.66245835 159.14526636  198.39205847  82.77579781 117.59833274 157.49622357 139.53979064  171.05953707 152.42297469 135.62774138  94.81503188 213.49660018  110.36059875 162.00479518 132.07261264 178.57636808 179.29614901   73.3945309  114.601665   131.93470279 100.32309962 252.57462411  146.00870076  61.92053404 170.56742259 157.92964414 243.28628037  205.27588938 180.79716523 114.89480581 120.80464762 172.87785542  243.4033502  151.64437003 130.09006375 100.99049563 249.91693845  153.00241663  87.45729779 230.20145421 215.78130712  90.82440238   88.24276622 143.91478174 110.89538069 134.84971688 130.50875598  177.97770535 121.87554552 221.70653117 261.76922106 197.7323525  125.88596841 191.96118205  71.8331337  240.12385544 129.00872186   89.92647528 151.49862554 202.71572059 105.9398957  150.37365076  103.92670222 108.23845662  87.0924303  168.01234827 106.55530568   93.81879887 232.8935379  238.29278058 136.22349466 154.71341867  157.80577109 114.83038143 159.25202218 100.13701043 236.14776543  143.92620712 235.19141566 269.14119287 113.39076553  86.51606237  251.53999411]<\/code><\/pre>\n<h4>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433\u0430<\/h4>\n<p><em><u>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/u><\/em>:<\/p>\n<ul>\n<li>\n<p>\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<p><em><u>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/u><\/em>:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0437-\u0437\u0430 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0434\u0431\u043e\u0440\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438<\/h4>\n<p>\u0421\u0442\u0430\u0442\u044c\u044f \u00abAn Interpretation of Stacking and Blending Approach in Machine Learning\u00bb, Divya Khyani, Soumya Jakkula, Sanjana Gowda N C, Anusha K J, Swetha K R.<\/p>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/ensemble.html#stacking\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.ensemble.StackingClassifier.html\" rel=\"noopener noreferrer nofollow\">StackingClassifier<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.ensemble.StackingRegressor.html\" rel=\"noopener noreferrer nofollow\">StackingRegressor<\/a>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0438\u0434\u0435\u043e: <a href=\"https:\/\/www.youtube.com\/watch?v=xtTyEoJ31Vg&amp;ab_channel=UnfoldDataScience\" rel=\"noopener noreferrer nofollow\">\u043e\u0434\u0438\u043d<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=TuIgtitqJho\" rel=\"noopener noreferrer nofollow\">\u0434\u0432\u0430<\/a>.<\/p>\n<hr\/>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/799725\/\" rel=\"noopener noreferrer nofollow\"><strong>? \u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0431\u0443\u0441\u0442\u0438\u043d\u0433<\/strong><\/a><strong>  |<\/strong> <strong> <\/strong><a href=\"https:\/\/habr.com\/ru\/articles\/799001\/\" rel=\"noopener noreferrer nofollow\"><strong>\u041c\u0435\u0442\u043e\u0434 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 ?<\/strong><\/a><\/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\/799483\/\"> https:\/\/habr.com\/ru\/articles\/799483\/<\/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<figure class=\"float full-width\"><\/figure>\n<p>\u0421\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0430\u043d\u0441\u0430\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0442 \u0434\u0432\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043a\u0430\u043a\u00a0<em>\u0441\u0442\u0435\u043a\u0438\u043d\u0433<\/em>\u00a0(stacked generalization) \u0438\u00a0<em>\u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433<\/em>, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u044b\u0445, \u043d\u043e \u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u043d \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437.<\/p>\n<p>\u0421\u0442\u0435\u043a\u0438\u043d\u0433 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u043e\u0447\u0435\u043d\u044c \u0441\u0445\u043e\u0436\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u043e\u0434\u043d\u0430\u043a\u043e \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0435\u0441\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<blockquote>\n<p><em>\u041d\u043e\u0443\u0442\u0431\u0443\u043a \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0430\u00a0<\/em><a href=\"https:\/\/www.kaggle.com\/code\/egazakharenko\/stacking-blending-in-ml-from-scratch-in-python\" rel=\"noopener noreferrer nofollow\"><strong><em>Kaggle<\/em><\/strong><\/a><em>\u00a0(eng) \u0438\u00a0<\/em><a href=\"https:\/\/github.com\/egaoharu-kensei\/ML-algorithms-from-scratch.-Course-for-beginners\/blob\/main\/Notebooks%20%5Brus%5D\/ML-%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC%D1%8B%20%D1%81%20%D0%BD%D1%83%D0%BB%D1%8F\/11%29%20%D0%A1%D1%82%D0%B5%D0%BA%D0%B8%D0%BD%D0%B3%20%26%20%D0%91%D0%BB%D0%B5%D0%BD%D0%B4%D0%B8%D0%BD%D0%B3.ipynb\" rel=\"noopener noreferrer nofollow\"><strong><em>GitHub<\/em><\/strong><\/a><em>\u00a0(rus).<\/em>  <\/p>\n<\/blockquote>\n<h4>Stacking<\/h4>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439. \u0414\u0430\u043b\u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e k-fold \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 k \u0444\u043e\u043b\u0434\u043e\u0432. \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 k-1 \u0444\u043e\u043b\u0434\u0430\u0445 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u043c\u0441\u044f. \u0414\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u043e\u043b\u0434\u0430 \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 k-fold \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043a\u0430\u043a \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a. \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0448\u0430\u0433\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u0440\u0433\u0435\u0442 <em>y_train<\/em> \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u043e\u0432\u044b\u043c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u043c. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0451\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440.<\/p>\n<p>\u041d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 (\u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445) \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u0430\u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437.<\/p>\n<figure class=\"full-width\">\n<div><figcaption><strong>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430<\/strong><\/figcaption><\/div>\n<\/figure>\n<h4>Blending<\/h4>\n<p>\u0411\u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430. \u0422\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 2 \u0447\u0430\u0441\u0442\u0438: \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u0443\u044e \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e hold-out \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438. \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043a\u0430\u043a \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c, \u0442\u0430\u043a \u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435. \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0448\u0430\u0433 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438: \u043a \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u043c \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u0440\u0433\u0435\u0442\u00a0<em>y_val<\/em>\u00a0\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e, \u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e.<\/p>\n<p>\u041d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 (\u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445) \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u0430\u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437.<\/p>\n<figure class=\"full-width\">\n<div><figcaption><strong>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433\u0430<\/strong><\/figcaption><\/div>\n<\/figure>\n<h4>\u0411\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438<\/h4>\n<p>\u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433\u0430 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f\u00a0<strong>\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u0430\u044f \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0434\u0440\u0430\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u041d\u0435\u0442\u0440\u0443\u0434\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043d\u0430\u0431\u043e\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438. \u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 scikit-learn \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u00a0<em>joblib<\/em>, \u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u044f\u0434\u0435\u0440 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u00a0<em>n_jobs<\/em>\u00a0(\u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 -1 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u044f\u0434\u0440\u0430). \u0412 \u0440\u0443\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0438\u0436\u0435 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0415\u0449\u0451 \u0441\u0442\u043e\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0441\u0442\u0435\u043a\u0438\u043d\u0433 \u0438 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c\u00a0<strong>\u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0439\u043d\u044b\u043c\u0438<\/strong>, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c, \u0430 \u0437\u0430\u0442\u0435\u043c \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435. \u0418\u043d\u043e\u0433\u0434\u0430 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0438\u043c\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u0441\u044f.<\/p>\n<blockquote>\n<p><em>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 scikit-learn \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u0441\u0442\u0435\u043a\u0438\u043d\u0433\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c 1 \u0444\u043e\u043b\u0434 \u0434\u043b\u044f \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0434\u0430\u043b\u0451\u043d\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u0431\u043b\u0435\u043d\u0434\u0438\u043d\u0433.<\/em>  <\/p>\n<\/blockquote>\n<h4>\u0418\u043c\u043f\u043e\u0440\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/h4>\n<pre><code class=\"python\">import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.datasets import load_diabetes from sklearn.preprocessing import LabelEncoder from sklearn.metrics import accuracy_score, mean_absolute_percentage_error from sklearn.model_selection import train_test_split, cross_val_predict from sklearn.svm import SVC from sklearn.linear_model import RidgeCV, LogisticRegression from sklearn.ensemble import StackingClassifier, StackingRegressor from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor from sklearn.ensemble import GradientBoostingClassifier, GradientBoostingRegressor from joblib import Parallel, delayed from mlxtend.plotting import plot_decision_regions<\/code><\/pre>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u043d\u0443\u043b\u044f<\/h4>\n<pre><code class=\"python\">class Stacking:     def __init__(self, estimators, final_estimator, blending=False, cv=5, n_jobs=-1):         self.estimators = estimators         self.final_estimator = final_estimator         self.blending = blending         self.cv = cv         self.n_jobs = n_jobs      def _X_pred(self, estimator, data):         if self.blending:             X_train_v, y_train_v, X_val = data             return estimator.fit(X_train_v, y_train_v).predict(X_val)         else:             X_train, y_train = data             return cross_val_predict(estimator, X_train, y_train, cv=self.cv)      def _X_test_pred(self, estimator, data):         X_train, y_train, X_test = data          return estimator.fit(X_train, y_train).predict(X_test)      def _meta_data(self, X_train, y_train, X_test):         if self.blending:             #used hold-out cross-validation             X_train_v, X_val, y_train_v, y_val = train_test_split(X_train, y_train, random_state=0)             train_data = [X_train_v, y_train_v, X_val]             test_data = [X_train_v, y_train_v, X_test]             meta_y_train = y_val         else:             train_data = [X_train, y_train]             test_data = [X_train, y_train, X_test]             meta_y_train = y_train          cv_X_train_preds = (delayed(self._X_pred)(est, train_data) for est in self.estimators)         X_test_preds = (delayed(self._X_test_pred)(est, test_data) for est in self.estimators)          meta_X_train = pd.DataFrame(Parallel(n_jobs=self.n_jobs)(cv_X_train_preds))         meta_X_test = pd.DataFrame(Parallel(n_jobs=self.n_jobs)(X_test_preds))          return meta_X_train.T, meta_y_train, meta_X_test.T      def fit_predict(self, X_train, y_train, X_test):         # meta learner or blender         meta_X_train, meta_y_train, meta_X_test = self._meta_data(X_train, y_train, X_test)          return self.final_estimator.fit(meta_X_train, meta_y_train).predict(meta_X_test)<\/code><\/pre>\n<h4>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/h4>\n<pre><code class=\"python\">def decision_boundary_plot(X, y, X_train, y_train, clf, feature_indexes, title=None):     feature1_name, feature2_name = X.columns[feature_indexes]     X_feature_columns = X.values[:, feature_indexes]     X_train_feature_columns = X_train.values[:, feature_indexes]     clf.fit(X_train_feature_columns, y_train.values)      plot_decision_regions(X=X_feature_columns, y=y.values, clf=clf)     plt.xlabel(feature1_name)     plt.ylabel(feature2_name)     plt.title(title)<\/code><\/pre>\n<h4>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432<\/h4>\n<p>\u0414\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d <a href=\"https:\/\/www.kaggle.com\/datasets\/uciml\/glass\" rel=\"noopener noreferrer nofollow\">Glass Classification<\/a> \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0435\u0440\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0438\u043f \u0441\u0442\u0435\u043a\u043b\u0430 \u043f\u043e \u0435\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Diabetes \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438\u0437 scikit-learn.<\/p>\n<pre><code class=\"python\">df_path = \"\/content\/drive\/MyDrive\/glass.csv\" glass_df = pd.read_csv(df_path) X1, y1 = glass_df.iloc[:, :-1], glass_df.iloc[:, -1] y1 = pd.Series(LabelEncoder().fit_transform(y1)) X1_train, X1_test, y1_train, y1_test = train_test_split(X1, y1, random_state=0) print(glass_df)             RI     Na    Mg    Al     Si     K    Ca    Ba   Fe  Type 0    1.52101  13.64  4.49  1.10  71.78  0.06  8.75  0.00  0.0     1 1    1.51761  13.89  3.60  1.36  72.73  0.48  7.83  0.00  0.0     1 2    1.51618  13.53  3.55  1.54  72.99  0.39  7.78  0.00  0.0     1 3    1.51766  13.21  3.69  1.29  72.61  0.57  8.22  0.00  0.0     1 4    1.51742  13.27  3.62  1.24  73.08  0.55  8.07  0.00  0.0     1 ..       ...    ...   ...   ...    ...   ...   ...   ...  ...   ... 209  1.51623  14.14  0.00  2.88  72.61  0.08  9.18  1.06  0.0     7 210  1.51685  14.92  0.00  1.99  73.06  0.00  8.40  1.59  0.0     7 211  1.52065  14.36  0.00  2.02  73.42  0.00  8.44  1.64  0.0     7 212  1.51651  14.38  0.00  1.94  73.61  0.00  8.48  1.57  0.0     7 213  1.51711  14.23  0.00  2.08  73.36  0.00  8.62  1.67  0.0     7  [214 rows x 10 columns]<\/code><\/pre>\n<pre><code class=\"python\">X2, y2 = load_diabetes(return_X_y=True, as_frame=True) X2_train, X2_test, y2_train, y2_test = train_test_split(X2, y2, random_state=0) print(X2, y2, sep='\\n')             age       sex       bmi        bp        s1        s2        s3  \\ 0    0.038076  0.050680  0.061696  0.021872 -0.044223 -0.034821 -0.043401    1   -0.001882 -0.044642 -0.051474 -0.026328 -0.008449 -0.019163  0.074412    2    0.085299  0.050680  0.044451 -0.005670 -0.045599 -0.034194 -0.032356    3   -0.089063 -0.044642 -0.011595 -0.036656  0.012191  0.024991 -0.036038    4    0.005383 -0.044642 -0.036385  0.021872  0.003935  0.015596  0.008142    ..        ...       ...       ...       ...       ...       ...       ...    437  0.041708  0.050680  0.019662  0.059744 -0.005697 -0.002566 -0.028674    438 -0.005515  0.050680 -0.015906 -0.067642  0.049341  0.079165 -0.028674    439  0.041708  0.050680 -0.015906  0.017293 -0.037344 -0.013840 -0.024993    440 -0.045472 -0.044642  0.039062  0.001215  0.016318  0.015283 -0.028674    441 -0.045472 -0.044642 -0.073030 -0.081413  0.083740  0.027809  0.173816                s4        s5        s6   0   -0.002592  0.019907 -0.017646   1   -0.039493 -0.068332 -0.092204   2   -0.002592  0.002861 -0.025930   3    0.034309  0.022688 -0.009362   4   -0.002592 -0.031988 -0.046641   ..        ...       ...       ...   437 -0.002592  0.031193  0.007207   438  0.034309 -0.018114  0.044485   439 -0.011080 -0.046883  0.015491   440  0.026560  0.044529 -0.025930   441 -0.039493 -0.004222  0.003064    [442 rows x 10 columns] 0      151.0 1       75.0 2      141.0 3      206.0 4      135.0        ...   437    178.0 438    104.0 439    132.0 440    220.0 441     57.0 Name: target, Length: 442, dtype: float64<\/code><\/pre>\n<h4>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435<\/h><\/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-370500","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/370500","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=370500"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/370500\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=370500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=370500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=370500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}