{"id":370894,"date":"2024-05-21T04:35:59","date_gmt":"2024-05-21T04:35:59","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=370894"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=370894","title":{"rendered":"<span>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b AdaBoost (SAMME &amp; R2). \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \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\/c7c\/795\/3da\/c7c7953da6a61dac110a989d07620e05.png\" width=\"763\" height=\"430\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c7c\/795\/3da\/c7c7953da6a61dac110a989d07620e05.png\"\/><\/figure>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043c\u043e\u0449\u043d\u044b\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f AdaBoost (adaptive boosting), \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043b\u0435\u0436\u0438\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430, \u043a\u043e\u0433\u0434\u0430 \u0441\u043b\u0430\u0431\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0441\u0438\u043b\u044c\u043d\u0443\u044e, \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044f \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u0432.<\/p>\n<p>\u0412 AdaBoost \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u043d\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439 (\u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438) \u2014 \u0434\u0435\u0440\u0435\u0432\u043e \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440 \u0432\u0435\u0441\u043e\u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 N, \u043a\u0430\u0436\u0434\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e y_train \u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0432\u043d\u043e\u00a01 \/ N, \u0433\u0434\u0435 N \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u0432 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435. \u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0435\u043d\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0432\u0435\u0441\u043e\u0432, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043d\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432.<\/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\/adaboost-samme-r2-from-scratch-using-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\/09%29%20%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC%D1%8B%20AdaBoost%20%28SAMME%20%26%20R2%29.ipynb\" rel=\"noopener noreferrer nofollow\"><strong><em>GitHub<\/em><\/strong><\/a><em>\u00a0(rus)<\/em>  <\/p>\n<\/blockquote>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ec0\/7ae\/6a6\/ec07ae6a64cf28a9c39fa599e5d788cb.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b AdaBoost\" title=\"\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b AdaBoost\" width=\"1211\" height=\"627\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ec0\/7ae\/6a6\/ec07ae6a64cf28a9c39fa599e5d788cb.png\"\/><\/p>\n<div><figcaption><strong>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b AdaBoost<\/strong><\/figcaption><\/div>\n<\/figure>\n<h4>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/h4>\n<p><strong>SAMME<\/strong>\u00a0(Stagewise Additive Modeling using \u0430 Multiclass Exponential loss function) \u2014 \u0432\u0435\u0440\u0441\u0438\u044f AdaBoost \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u043e\u043a\u043b\u0430\u0441\u0441\u043e\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u044e\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00a0<em>SAMME.R<\/em>, \u0433\u0434\u0435 R (Real) \u2014 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438, \u0432 \u0446\u0435\u043b\u043e\u043c, \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/strong>:<\/p>\n<ol>\n<li>\n<p> \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e y_train \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0432\u0435\u0441;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u043d\u044c \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439 1 \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 X_train \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043b\u044f \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043e\u0448\u0438\u0431\u043a\u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0441 \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f (\u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f) \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0435\u0441\u0430 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0432\u0435\u0441\u0430 \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0435\u043d\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 X_train \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u0445 \u0432\u0435\u0441\u043e\u0432: \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0442\u043e\u0433\u043e \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0449\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u0446\u044b (\u0442\u0435, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0435\u0441\u0430);<\/p>\n<\/li>\n<li>\n<p>\u0448\u0430\u0433\u0438 2-5 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043f\u0435\u043d\u044c \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 1 \u043e\u0431\u0440\u0430\u0437\u0446\u0430 X_test;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u0435\u0441\u0430 \u043f\u043d\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043b\u0430\u0441\u0441 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 \u0432\u0435\u0441\u043e\u0432 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>\u0434\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 \u0432\u0441\u0435\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0424\u043e\u0440\u043c\u0443\u043b\u044b \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u0432<\/strong><\/p>\n<p>\u0412\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043e\u0448\u0438\u0431\u043e\u043a j-\u0433\u043e \u043f\u043d\u044f:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"r_j = \\sum\\limits_{i=1}^{m} w_i (\\hat{y_j}^{(i)} \\neq {y}^{(i)})\" alt=\"r_j = \\sum\\limits_{i=1}^{m} w_i (\\hat{y_j}^{(i)} \\neq {y}^{(i)})\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f59\/be8\/284\/f59be8284c110cdd9838858a1ab6fc01.svg\" width=\"195\" height=\"57\"\/><\/p>\n<p>\u0412\u0435\u0441 \u043f\u043d\u044f:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\u03b1_j = \u03b7 \\ log(\\frac{1 - r_j}{r_j}) + log(K - 1)\" alt=\"\u03b1_j = \u03b7 \\ log(\\frac{1 - r_j}{r_j}) + log(K - 1)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0ef\/e35\/c51\/0efe35c51ec5754583a7b856500657f7.svg\" width=\"269\" height=\"49\"\/><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0435\u0441 \u043f\u043d\u044f \u043a\u0430\u043a (\u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"w^{(i)} \\leftarrow w^{(i)} exp(\u03b1_j) \\ (\\hat{y_j}^{(i)} \\neq {y}^{(i)})\" alt=\"w^{(i)} \\leftarrow w^{(i)} exp(\u03b1_j) \\ (\\hat{y_j}^{(i)} \\neq {y}^{(i)})\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f0a\/a6d\/6a5\/f0aa6d6a5594f68eb0f471e2954ab556.svg\" width=\"263\" height=\"27\"\/><\/p>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\hat{y}(x) = argmax \\sum\\limits_{j=1}^{N} \u03b1_j (\\hat{y}_j(x) = k)\" alt=\"\\hat{y}(x) = argmax \\sum\\limits_{j=1}^{N} \u03b1_j (\\hat{y}_j(x) = k)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b47\/cec\/e79\/b47cece79886d72e1aa000eca3de6d2c.svg\" width=\"278\" height=\"62\"\/><\/p>\n<p>j-\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 i-\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430: <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\hat{y_j}^{(i)}\" alt=\"\\hat{y_j}^{(i)}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf8\/b86\/9e6\/bf8b869e62f40bc657449e7b96316148.svg\" width=\"34\" height=\"27\"\/> <\/p>\n<p>\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f: <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\u03b7\" alt=\"\u03b7\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e60\/056\/9ac\/e600569ac5c7d96a311e1a8cfea5d2b0.svg\" width=\"10\" height=\"16\"\/> <\/p>\n<p>\u0447\u0438\u0441\u043b\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"K\" alt=\"K\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/595\/73a\/ab2\/59573aab2335cddde11581c152d3fc85.svg\" width=\"17\" height=\"17\"\/>.<\/p>\n<h4>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/h4>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438\u00a0<em>AdaBoost.R2<\/em>\u00a0\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439: \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043f\u043d\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<a href=\"https:\/\/iq.opengenus.org\/weighted-median-problem\/\" rel=\"noopener noreferrer nofollow\">\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0434\u0438\u0430\u043d\u044b<\/a>, \u0441\u0443\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0438 \u0432\u0435\u0441\u043e\u0432 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0442\u043e\u0433\u043e, \u0447\u044c\u044f \u043a\u0443\u043c\u0443\u043b\u044f\u0442\u0438\u0432\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b \u043e\u0442 \u043e\u0431\u0449\u0435\u0439.<\/p>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/strong>:<\/p>\n<ol>\n<li>\n<p>\u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e y_train \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0432\u0435\u0441;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u043d\u044c \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439 3 \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 X_train \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u0438 \u043f\u043d\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u00a0\u03b2\u00a0\u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430\u00a0\u03b2\u00a0\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0435\u0441 \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0435\u0441\u0430 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0432\u0435\u0441\u0430 \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0435\u043d\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 X_train \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u0445 \u0432\u0435\u0441\u043e\u0432: \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0442\u043e\u0433\u043e \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0449\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u0440\u0430\u0437\u0446\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0432\u0435\u0441\u0430\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0448\u0430\u0433\u0438 2-6 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0432\u0441\u0435\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 X_test \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u043c \u043f\u043d\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u0438\u0437 \u0448\u0430\u0433\u0430 8 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430 \u0438 \u0431\u0443\u0434\u0443\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0424\u043e\u0440\u043c\u0443\u043b\u044b \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u0432<\/strong> <\/p>\n<p>\u0410\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"e_{abs} = |\\hat{y_j}^{(i)} - {y}^{(i)}|\" alt=\"e_{abs} = |\\hat{y_j}^{(i)} - {y}^{(i)}|\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/752\/6be\/39f\/7526be39f62bf33b7e120988bf34de9c.svg\" width=\"152\" height=\"27\"\/><\/p>\n<p>\u0421\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"e_{l} = \\frac{e_{abs}}{max(e_{abs})}\" alt=\"e_{l} = \\frac{e_{abs}}{max(e_{abs})}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/544\/c77\/5cf\/544c775cfc97bc5630fc565fee7518f4.svg\" width=\"131\" height=\"43\"\/><\/p>\n<p>\u0421\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u043f\u043d\u044f:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\overline{e} = \\sum\\limits_{i=1}^{n} w^{(i)} e_l^{(i)}\" alt=\"\\overline{e} = \\sum\\limits_{i=1}^{n} w^{(i)} e_l^{(i)}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/992\/b86\/5f1\/992b865f1f524a7f028539bdcb8ca4f7.svg\" width=\"124\" height=\"57\"\/><\/p>\n<p>\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u03b2:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\u03b2 = \\frac{\\overline{e}}{1 - \\overline{e}}\" alt=\"\u03b2 = \\frac{\\overline{e}}{1 - \\overline{e}}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8f4\/5d5\/f2a\/8f45d5f2a50a9592407d94c94294228e.svg\" width=\"87\" height=\"48\"\/><\/p>\n<p>\u0412\u0435\u0441 \u043f\u043d\u044f:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"w^{(i)} = \u03b7 \\ ln(\\frac{1}{\u03b2})\" alt=\"w^{(i)} = \u03b7 \\ ln(\\frac{1}{\u03b2})\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/72e\/7ed\/04f\/72e7ed04fa8d082c4aa872c629bb87f5.svg\" width=\"121\" height=\"45\"\/><\/p>\n<p>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0435\u0441 \u043f\u043d\u044f \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0443 (\u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"w^{(i)} \\leftarrow w^{(i)} \u03b2_i^{1 - e_{l}}\" alt=\"w^{(i)} \\leftarrow w^{(i)} \u03b2_i^{1 - e_{l}}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ab5\/87f\/1c5\/ab587f1c584c514ab2d8a55e3c758f57.svg\" width=\"133\" height=\"28\"\/><\/p>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\hat{y}(x) = weighted \\ median (\\hat{y_j}^{(i)})\" alt=\"\\hat{y}(x) = weighted \\ median (\\hat{y_j}^{(i)})\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cc3\/2a5\/b6d\/cc32a5b6d884d5d14f7836b403d9504e.svg\" width=\"257\" height=\"27\"\/><\/p>\n<p>j-\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 i-\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430: <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\hat{y_j}^{(i)}\" alt=\"\\hat{y_j}^{(i)}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf8\/b86\/9e6\/bf8b869e62f40bc657449e7b96316148.svg\" width=\"34\" height=\"27\"\/> <\/p>\n<p>C\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f: <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\u03b7\" alt=\"\u03b7\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e60\/056\/9ac\/e600569ac5c7d96a311e1a8cfea5d2b0.svg\" width=\"10\" height=\"16\"\/>.<\/p>\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.preprocessing import LabelEncoder from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score, mean_absolute_percentage_error from sklearn.datasets import load_diabetes from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor from sklearn.ensemble import AdaBoostClassifier, AdaBoostRegressor 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 AdaBoost:     def __init__(self, regression=False, n_estimators=50, learning_rate=1.0, random_state=0):         self.regression = regression         self.n_estimators = n_estimators         self.learning_rate = learning_rate         self.random_state = random_state         self.stumps = []         self.weights = []      def _update_weights(self, args):         if self.regression:             weights, beta, loss_function = args             weights *= beta ** (1 - loss_function)         else:             weights, wrong_predictions, stump_weight = args             weights[wrong_predictions] *= np.exp(stump_weight)          return weights      @staticmethod     def _normalize(weights: np.ndarray):         return weights \/ sum(weights)      def fit(self, X, y):         n_samples = len(y)         self.K = len(np.unique(y.values))   # num unique classes         weights = np.ones(n_samples) \/ n_samples          for _ in range(self.n_estimators):             if self.regression:                 stump = DecisionTreeRegressor(max_depth=3, random_state=self.random_state)                 stump_predictions = stump.fit(X, y, sample_weight=weights).predict(X)                  abs_instance_errors = abs(stump_predictions - y)                 adjusted_instance_errors = abs_instance_errors \/ max(abs_instance_errors)                 adjusted_stump_error = sum(weights * adjusted_instance_errors)                  if adjusted_stump_error >= 0.5:                     self.stumps.pop(-1)                     break                  beta = adjusted_stump_error \/ (1 - adjusted_stump_error)                 stump_weight = self.learning_rate * np.log(1 \/ beta)                 args = [weights, beta, adjusted_instance_errors]             else:                 stump = DecisionTreeClassifier(max_depth=1, random_state=self.random_state)                 stump_predictions = stump.fit(X, y, sample_weight=weights).predict(X)                  wrong_predictions = stump_predictions != y                 r = sum(weights[wrong_predictions])   # weighted_error_rate                 stump_weight = self.learning_rate * np.log((1 - r) \/ r) + np.log(self.K - 1)                 args = [weights, wrong_predictions, stump_weight]              self.stumps.append(stump)             self.weights.append(stump_weight)             weights= self._update_weights(args)             weights = self._normalize(weights)      def _max_weighted_votes(self, samples):         n_samples = len(samples)         sample_indexes = np.array(range(n_samples))         prediction_weights = np.zeros((n_samples, self.K))          for i in range(self.n_estimators):             stump_prediction = self.stumps[i].predict(samples)             prediction_weights[sample_indexes, stump_prediction] += self.weights[i]          return np.argmax(prediction_weights, axis=1)      def _weighted_median_prediction(self, samples):         n_samples = len(samples)         sample_indexes = np.arange(n_samples)         predictions = np.array([stump.predict(samples) for stump in self.stumps]).T         sorted_pred_indexes = np.argsort(predictions, axis=1)          # Find index of median prediction for each sample         cumsum_weights = np.array(self.weights)[sorted_pred_indexes].cumsum(axis=1)         is_over_median = cumsum_weights >= 0.5 * sum(self.weights)   # True\/False matrix         median_indexes = is_over_median.argmax(axis=1)         median_prediction_indexes = sorted_pred_indexes[sample_indexes, median_indexes]          return predictions[sample_indexes, median_prediction_indexes]      def predict(self, samples):         if self.regression:             return self._weighted_median_prediction(samples)         else:             return self._max_weighted_votes(samples)<\/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\u00a0<a href=\"https:\/\/www.kaggle.com\/datasets\/uciml\/glass\" rel=\"noopener noreferrer nofollow\">Glass Classification<\/a>\u00a0\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<\/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>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0438\u0437\u043a\u0430\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e AdaBoost \u043f\u043b\u043e\u0445\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043d\u0435\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0441\u0442\u0430\u0440\u0430\u044f\u0441\u044c \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u0438\u0437 \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0447\u0442\u043e \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 \u043d\u0430 \u044d\u0442\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u0438 \u043a \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0446\u0435\u043b\u043e\u043c.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430 (\u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u0432\u044b\u0439\u0434\u0435\u0442 \u0441\u0442\u0430\u0442\u044c\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435) \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 AdaBoost \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0435. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043f\u0440\u0438 \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 AdaBoost \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043b\u0443\u0447\u0448\u0435 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u0432 \u043a\u0430\u043a \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u0442\u0430\u043a \u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. <\/p>\n<blockquote>\n<p><em>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187;.<\/em><\/p>\n<\/blockquote>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0438\u0436\u0435.<\/p>\n<p><strong>\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f<\/strong> <\/p>\n<pre><code class=\"python\">adaboost_clf = AdaBoost(random_state=0) adaboost_clf.fit(X1_train, y1_train) adaboost_clf_pred_res = adaboost_clf.predict(X1_test) adaboost_clf_accuracy = accuracy_score(adaboost_clf_pred_res, y1_test) print(f'adaboost_clf_accuracy: {adaboost_clf_accuracy}') print(adaboost_clf_pred_res, '', sep='\\n')  sk_adaboost_clf = AdaBoostClassifier(random_state=0, algorithm='SAMME') sk_adaboost_clf.fit(X1_train, y1_train) sk_adaboost_clf_pred_res = sk_adaboost_clf.predict(X1_test) sk_adaboost_clf_accuracy = accuracy_score(sk_adaboost_clf_pred_res, y1_test) print(f'sk_adaboost_clf_accuracy: {sk_adaboost_clf_accuracy}') print(sk_adaboost_clf_pred_res)  feature_indexes = [1, 3] title1 = 'AdaBoostClassifier surface' decision_boundary_plot(X1, y1, X1_train, y1_train, sk_adaboost_clf, feature_indexes, title1)   adaboost_clf_accuracy: 0.46296296296296297 [5 0 0 3 1 0 0 0 0 0 1 0 1 1 0 5 0 0 0 0 1 0 5 5 1 0 5 0 0 0 0 4 0 1 0 0 0  0 0 5 1 4 0 0 0 0 0 0 0 0 0 1 5 0]  sk_adaboost_clf_accuracy: 0.46296296296296297 [5 0 0 3 1 0 0 0 0 0 1 0 1 1 0 5 0 0 0 0 1 0 5 5 1 0 5 0 0 0 0 4 0 1 0 0 0  0 0 5 1 4 0 0 0 0 0 0 0 0 0 1 5 0]<\/code><\/pre>\n<p><strong>\u0420\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/strong><\/p>\n<pre><code class=\"python\">adaboost_reg = AdaBoost(regression=True, random_state=0) adaboost_reg.fit(X2_train, y2_train) adaboost_reg_pred_res = adaboost_reg.predict(X2_test) mape = mean_absolute_percentage_error(adaboost_reg_pred_res, y2_test) print(f'adaboost_mape {mape}') print(adaboost_reg_pred_res, '', sep='\\n')  sk_adaboost_reg = AdaBoostRegressor(random_state=0, loss='linear') sk_adaboost_reg.fit(X2_train, y2_train) sk_adaboost_reg_pred_res = sk_adaboost_reg.predict(X2_test) sk_mape = mean_absolute_percentage_error(sk_adaboost_reg_pred_res, y2_test) print(f'sk_adaboost_mape {sk_mape}') print(sk_adaboost_reg_pred_res)   adaboost_mape 0.31162122370993556 [239.42353344 230.0610339  167.83786364 109.90928178 184.64646203  239.42353344 101.90476455 212.98494882 140.80423233 234.56903421  149.26846999 194.19445742 117.43386255 108.94790608 242.1290679  113.80597432 154.09826483  98.94335581 115.9061429  215.42377993  174.95712248 153.4188609  156.40651525 101.90476455 212.98494882  167.10327877 124.65270476 101.84145017 192.87682861 155.83747832  199.62919177 101.90476455 117.43386255 149.26846999 149.26846999  154.09826483 153.4188609  154.49247636 101.3830624  209.29518647  109.90928178 161.72545559 157.26677336 164.34687775 194.42677031  101.84145017 121.14501461 138.47917841 118.20881026 221.76239616  142.75885825 106.54153274 115.59244578 156.73838581 228.18233286  159.23529268 188.06281057 115.59244578 136.36747076 179.90046612  235.54909423 136.36747076 146.94594595 117.30376558 235.54909423  156.55259315 109.14947399 222.75       216.80587827 117.30376558  101.3830624  149.26846999 124.65270476 138.47917841 121.14501461  164.34687775 129.01990679 215.42377993 237.65169877 173.94597477  140.80423233 210.13587296 101.3830624  222.95089406 126.1623703  102.63869452 155.06486638 198.82203583 109.90928178 153.9068871  113.80597432 115.9061429  101.85242259 155.83747832 113.80597432  102.63869452 216.80587827 211.45665899 109.90928178 160.62212018  153.4188609  109.65526344 163.575      106.94547559 230.1457969  140.80423233 215.42377993 234.56903421 109.65526344 115.9061429  216.80587827]  sk_adaboost_mape 0.3108613573264116 [258.32911392 227.87142857 176.77325581 112.12676056 189.65263158  240.23529412  97.56934307 215.65217391 131.52777778 228.77894737  148.55223881 161.68085106 115.83916084 106.13636364 259.90697674  117.94565217 147.52941176  95.01538462 117.94565217 229.88429752  175.55696203 133.24277457 174.94444444 113.         213.70093458  169.35955056 133.24277457  95.67142857 195.7173913  156.20253165  206.96875    101.32330827 117.94565217 148.55223881 148.55223881  155.86893204 149.32352941 149.32352941  96.05932203 200.54545455  115.83916084 171.         143.02857143 169.8        196.54054054   99.05617978 123.4375     112.12676056 117.17213115 227.87142857  148.09195402  99.05617978 121.2826087  167.92592593 227.87142857  150.0106383  169.35955056 104.71794872 133.24277457 200.54545455  231.56934307 121.2826087  139.78205128 113.08602151 234.00735294  131.52777778 106.92380952 218.64705882 215.3        113.69172932   97.56934307 147.29166667 126.87591241 113.69172932 118.26470588  168.76       123.16037736 200.89473684 234.00735294 189.65263158  133.24277457 226.15686275  95.03703704 233.25       134.91428571  101.32330827 133.24277457 200.54545455 113.08602151 149.32352941  113.08602151 117.94565217  95.03703704 154.67532468 113.69172932   97.56934307 227.43037975 221.58433735 126.87591241 155.86893204  148.09195402 102.25714286 169.52147239 104.71794872 227.87142857  142.38461538 218.64705882 247.9122807  112.12676056 117.94565217  226.15686275]<\/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 AdaBoost<\/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>\u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438, \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0441\u043e\u043a\u0430\u044f \u043e\u0431\u043e\u0431\u0449\u0430\u044e\u0449\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c.<\/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>\u043d\u0438\u0437\u043a\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043a\u043b\u043e\u043d\u0435\u043d \u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0435\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a \u0448\u0443\u043c\u0443 \u0438 \u0432\u044b\u0431\u0440\u043e\u0441\u0430\u043c.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0414\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430<\/h4>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e\u0431\u043e\u0431\u0449\u0430\u044e\u0449\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c AdaBoost \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0441\u043d\u0438\u0437\u0438\u0442\u044c\u0441\u044f, \u0431\u044b\u043b\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u0435, \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u0421\u0440\u0435\u0434\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><strong>L2-Boost<\/strong>\u00a0\u2014 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 L2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0434\u043b\u044f \u0448\u0442\u0440\u0430\u0444\u043e\u0432 \u043c\u0435\u043d\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p><strong>LogitBoost<\/strong>\u00a0\u2014 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c, \u0447\u0442\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432 \u0440\u044f\u0434\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0434\u0435\u043b\u0430\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u043c;<\/p>\n<\/li>\n<li>\n<p><strong>BrownBoost<\/strong>\u00a0\u2014 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u0430\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043b\u0435\u0436\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u043c\u0438\u0442\u0430 \u043d\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u0441 \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u043c\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0448\u0442\u0440\u0430\u0444\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u0442\u0440\u0443\u0434\u043d\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b.<\/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\u0438:<\/p>\n<ul>\n<li>\n<p>\u00abMulti-class AdaBoost\u00bb, Ji Zhu, Hui Zou, Saharon Rosset and Trevor Hastie;<\/p>\n<\/li>\n<li>\n<p>\u00abBoosting for Regression Transfer\u00bb, David Pardoe and Peter Stone;<\/p>\n<\/li>\n<li>\n<p>\u00abL2 Boosting for Economic Applications\u00bb, Ye Luo and Martin Spindler;<\/p>\n<\/li>\n<li>\n<p>\u00abRobust LogitBoost and Adaptive Base Class (ABC) LogitBoost\u00bb, Ping Li;<\/p>\n<\/li>\n<li>\n<p>\u00abAn adaptive version of the boost by majority algorithm\u00bb, Yoav Freund.<\/p>\n<\/li>\n<\/ul>\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#adaboost\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 AdaBoost<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.ensemble.AdaBoostClassifier.html\" rel=\"noopener noreferrer nofollow\">AdaBoostClassifier<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.ensemble.AdaBoostRegressor.html\" rel=\"noopener noreferrer nofollow\">AdaBoostRegressor<\/a>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0438\u0434\u0435\u043e:\u00a0<a href=\"https:\/\/www.youtube.com\/watch?v=LsK-xG1cLYA&amp;t=1110s&amp;ab_channel=StatQuestwithJoshStarmer\" rel=\"noopener noreferrer nofollow\">\u043e\u0434\u0438\u043d<\/a>,\u00a0<a href=\"https:\/\/www.youtube.com\/watch?v=UHBmv7qCey4&amp;t=1477s\" rel=\"noopener noreferrer nofollow\">\u0434\u0432\u0430<\/a>,\u00a0<a href=\"https:\/\/www.youtube.com\/watch?v=toOAToTaGV4\" rel=\"noopener noreferrer nofollow\">\u0442\u0440\u0438<\/a>.<\/p>\n<hr\/>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/801161\/\" rel=\"noopener noreferrer nofollow\"><strong>? \u0411\u044d\u0433\u0433\u0438\u043d\u0433 \u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043b\u0435\u0441<\/strong><\/a><strong>  |  <\/strong><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 \u0438 \u0435\u0433\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 ?<\/strong><\/a><\/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\/800499\/\"> https:\/\/habr.com\/ru\/articles\/800499\/<\/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\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043c\u043e\u0449\u043d\u044b\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f AdaBoost (adaptive boosting), \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043b\u0435\u0436\u0438\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430, \u043a\u043e\u0433\u0434\u0430 \u0441\u043b\u0430\u0431\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0441\u0438\u043b\u044c\u043d\u0443\u044e, \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044f \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u0432.<\/p>\n<p>\u0412 AdaBoost \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u043d\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439 (\u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438) \u2014 \u0434\u0435\u0440\u0435\u0432\u043e \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440 \u0432\u0435\u0441\u043e\u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 N, \u043a\u0430\u0436\u0434\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e y_train \u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0432\u043d\u043e\u00a01 \/ N, \u0433\u0434\u0435 N \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u0432 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435. \u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0435\u043d\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0432\u0435\u0441\u043e\u0432, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043d\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432.<\/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\/adaboost-samme-r2-from-scratch-using-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\/09%29%20%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC%D1%8B%20AdaBoost%20%28SAMME%20%26%20R2%29.ipynb\" rel=\"noopener noreferrer nofollow\"><strong><em>GitHub<\/em><\/strong><\/a><em>\u00a0(rus)<\/em>  <\/p>\n<\/blockquote>\n<figure class=\"full-width\">\n<div><figcaption><strong>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b AdaBoost<\/strong><\/figcaption><\/div>\n<\/figure>\n<h4>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/h4>\n<p><strong>SAMME<\/strong>\u00a0(Stagewise Additive Modeling using \u0430 Multiclass Exponential loss function) \u2014 \u0432\u0435\u0440\u0441\u0438\u044f AdaBoost \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u043e\u043a\u043b\u0430\u0441\u0441\u043e\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u044e\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00a0<em>SAMME.R<\/em>, \u0433\u0434\u0435 R (Real) \u2014 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438, \u0432 \u0446\u0435\u043b\u043e\u043c, \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/strong>:<\/p>\n<ol>\n<li>\n<p> \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e y_train \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0432\u0435\u0441;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u043d\u044c \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439 1 \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 X_train \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043b\u044f \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u043e\u0448\u0438\u0431\u043a\u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0441 \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f (\u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f) \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0435\u0441\u0430 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0432\u0435\u0441\u0430 \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0435\u043d\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 X_train \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u0445 \u0432\u0435\u0441\u043e\u0432: \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0442\u043e\u0433\u043e \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0449\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u0446\u044b (\u0442\u0435, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0435\u0441\u0430);<\/p>\n<\/li>\n<li>\n<p>\u0448\u0430\u0433\u0438 2-5 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043f\u0435\u043d\u044c \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 1 \u043e\u0431\u0440\u0430\u0437\u0446\u0430 X_test;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u0435\u0441\u0430 \u043f\u043d\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043b\u0430\u0441\u0441 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 \u0432\u0435\u0441\u043e\u0432 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>\u0434\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 \u0432\u0441\u0435\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0424\u043e\u0440\u043c\u0443\u043b\u044b \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u0432<\/strong><\/p>\n<p>\u0412\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043e\u0448\u0438\u0431\u043e\u043a j-\u0433\u043e \u043f\u043d\u044f:<\/p>\n<p>\u0412\u0435\u0441 \u043f\u043d\u044f:<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0435\u0441 \u043f\u043d\u044f \u043a\u0430\u043a (\u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c):<\/p>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437:<\/p>\n<p>j-\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 i-\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430:  <\/p>\n<p>\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f:  <\/p>\n<p>\u0447\u0438\u0441\u043b\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 .<\/p>\n<h4>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/h4>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438\u00a0<em>AdaBoost.R2<\/em>\u00a0\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439: \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043f\u043d\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<a href=\"https:\/\/iq.opengenus.org\/weighted-median-problem\/\" rel=\"noopener noreferrer nofollow\">\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0434\u0438\u0430\u043d\u044b<\/a>, \u0441\u0443\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0438 \u0432\u0435\u0441\u043e\u0432 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0442\u043e\u0433\u043e, \u0447\u044c\u044f \u043a\u0443\u043c\u0443\u043b\u044f\u0442\u0438\u0432\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b \u043e\u0442 \u043e\u0431\u0449\u0435\u0439.<\/p>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/strong>:<\/p>\n<ol>\n<li>\n<p>\u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e y_train \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0432\u0435\u0441;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u043d\u044c \u0433\u043b\u0443\u0431\u0438\u043d\u043e\u0439 3 \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 X_train \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u0438 \u043f\u043d\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u00a0\u03b2\u00a0\u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430\u00a0\u03b2\u00a0\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0435\u0441 \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0435\u0441\u0430 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0432\u0435\u0441\u0430 \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0435\u043d\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 X_train \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u0445 \u0432\u0435\u0441\u043e\u0432: \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0442\u043e\u0433\u043e \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0449\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u0440\u0430\u0437\u0446\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0432\u0435\u0441\u0430\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0448\u0430\u0433\u0438 2-6 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043d\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0432\u0441\u0435\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 X_test \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u043c \u043f\u043d\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b \u0438\u0437 \u0448\u0430\u0433\u0430 8 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430 \u0438 \u0431\u0443\u0434\u0443\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0424\u043e\u0440\u043c\u0443\u043b\u044b \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u0432<\/strong> <\/p>\n<p>\u0410\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430:<\/p>\n<p>\u0421\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430:<\/p>\n<p>\u0421\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u043f\u043d\u044f:<\/p>\n<p>\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u03b2:<\/p>\n<p>\u0412\u0435\u0441 \u043f\u043d\u044f:<\/p>\n<p>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0435\u0441 \u043f\u043d\u044f \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0443 (\u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c):<\/p>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437:<\/p>\n<p>j-\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 i-\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430:  <\/p>\n<p>C\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f: .<\/p>\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.preprocessing import LabelEncoder from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score, mean_absolute_percentage_error from sklearn.datasets import load_diabetes from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor from sklearn.ensemble import AdaBoostClassifier, AdaBoostRegressor 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 AdaBoost:     def __init__(self, regression=False, n_estimators=50, learning_rate=1.0, random_state=0):         self.regression = regression         self.n_estimators = n_estimators         self.learning_rate = learning_rate         self.random_state = random_state         self.stumps = []         self.weights = []      def _update_weights(self, args):         if self.regression:             weights, beta, loss_function = args             weights *= beta ** (1 - loss_function)         else:             weights, wrong_predictions, stump_weight = args             weights[wrong_predictions] *= np.exp(stump_weight)          return weights      @staticmethod     def _normalize(weights: np.ndarray):         return weights \/ sum(weights)      def fit(self, X, y):         n_samples = len(y)         self.K = len(np.unique(y.values))   # num unique classes         weights = np.ones(n_samples) \/ n_samples          for _ in range(self.n_estimators):             if self.regression:                 stump = DecisionTreeRegressor(max_depth=3, random_state=self.random_state)                 stump_predictions = stump.fit(X, y, sample_weight=weights).predict(X)                  abs_instance_errors = abs(stump_predictions - y)                 adjusted_instance_errors = abs_instance_errors \/ max(abs_instance_errors)                 adjusted_stump_error = sum(weights * adjusted_instance_errors)                  if adjusted_stump_error >= 0.5:                     self.stumps.pop(-1)                     break                  beta = adjusted_stump_error \/ (1 - adjusted_stump_error)                 stump_weight = self.learning_rate * np.log(1 \/ beta)                 args = [weights, beta, adjusted_instance_errors]             else:                 stump = DecisionTreeClassifier(max_depth=1, random_state=self.random_state)                 stump_predictions = stump.fit(X, y, sample_weight=weights).predict(X)                  wrong_predictions = stump_predictions != y                 r = sum(weights[wrong_predictions])   # weighted_error_rate                 stump_weight = self.learning_rate * np.log((1 - r) \/ r) + np.log(self.K - 1)                 args = [weights, wrong_predictions, stump_weight]              self.stumps.append(stump)             self.weights.append(stump_weight)             weights= self._update_weights(args)             weights = self._normalize(weights)      def _max_weighted_votes(self, samples):         n_samples = len(samples)         sample_indexes = np.array(range(n_samples))         prediction_weights = np.zeros((n_samples, self.K))          for i in range(self.n_estimators):             stump_prediction = self.stumps[i].predict(samples)             prediction_weights[sample_indexes, stump_prediction] += self.weights[i]          return np.argmax(prediction_weights, axis=1)      def _weighted_median_prediction(self, samples):         n_samples = len(samples)         sample_indexes = np.arange(n_samples)         predictions = np.array([stump.predict(samples) for stump in self.stumps]).T         sorted_pred_indexes = np.argsort(predictions, axis=1)          # Find index of median prediction for each sample         cumsum_weights = np.array(self.weights)[sorted_pred_indexes].cumsum(axis=1)         is_over_median = cumsum_weights >= 0.5 * sum(self.weights)   # True\/False matrix         median_indexes = is_over_median.argmax(axis=1)         median_prediction_indexes = sorted_pred_indexes[sample_indexes, median_indexes]          return predictions[sample_indexes, median_prediction_indexes]      def predict(self, samples):         if self.regression:             return self._weighted_median_prediction(samples)         else:             return self._max_weighted_votes(samples)<\/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\u00a0<a href=\"https:\/\/www.kaggle.com\/datasets\/uciml\/glass\" rel=\"noopener noreferrer nofollow\">Glass Classification<\/a>\u00a0\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<\/code><\/pre>\n<pre><code class=\"python\">X2, y2 = load_diabetes(return_X_y=True,<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-370894","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/370894","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=370894"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/370894\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=370894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=370894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=370894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}