{"id":371289,"date":"2024-05-21T04:45:06","date_gmt":"2024-05-21T04:45:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=371289"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=371289","title":{"rendered":"<span>\u0414\u0435\u0440\u0435\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 (CART). \u041e\u0442 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0441\u043d\u043e\u0432 \u0434\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u0442\u0435\u0445\u043d\u0438\u043a \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \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\/945\/006\/e62\/945006e6220f8603ce6498edd32b4581.png\" width=\"762\" height=\"433\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/945\/006\/e62\/945006e6220f8603ce6498edd32b4581.png\"\/><\/figure>\n<p>\u0414\u0435\u0440\u0435\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 CART (Classification and Regressoin Tree) \u2014 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0438 \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430 \u0438 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0447\u0438\u0441\u043b\u043e \u0441\u0430\u043c\u044b\u0445 \u043c\u043e\u0449\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c. \u0414\u0435\u0440\u0435\u0432\u044c\u044f \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041a \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u043c \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435: ID3, C4.5, C5.0. <\/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\/decision-tree-cart-from-scratch-full-tutorial\" 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\/07%29%20%D0%94%D0%B5%D1%80%D0%B5%D0%B2%D0%BE%20%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D0%B9%20%28CART%29.ipynb\" rel=\"noopener noreferrer nofollow\"><strong><em>GitHub<\/em><\/strong><\/a><em>\u00a0(rus).<\/em>  <\/p>\n<\/blockquote>\n<h4>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/h4>\n<p>\u0420\u0435\u0448\u0430\u044e\u0449\u0435\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432: \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b, \u0432\u0435\u0442\u0432\u0438 (\u043b\u0435\u0432\u0430\u044f \u0438 \u043f\u0440\u0430\u0432\u0430\u044f), \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0438 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 (\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435) \u0443\u0437\u043b\u044b. \u041a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0438 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0443\u0437\u043b\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0441 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043d\u0430 \u0447\u0430\u0441\u0442\u0438 (\u043b\u0435\u0432\u0430\u044f \u0438 \u043f\u0440\u0430\u0432\u0430\u044f), \u0430 \u043b\u0438\u0441\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u043c\u0438: \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u043b\u0438\u0441\u0442\u0435 \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0430 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0a5\/16e\/391\/0a516e3918c77a287ada239dcbd9f9b6.png\" alt=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 CART\" title=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 CART\" width=\"619\" height=\"526\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0a5\/16e\/391\/0a516e3918c77a287ada239dcbd9f9b6.png\"\/><\/p>\n<div><figcaption><strong>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 CART<\/strong><\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0439 \u0443\u0437\u0435\u043b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0433\u0440\u0430\u043d\u0438\u0446 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0443\u0447\u0430\u0441\u0442\u043a\u0438 \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u043e \u043e\u043d\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0434\u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c.  <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/55d\/22d\/53d\/55d22d53dd9e49a2552d285966b71a2b.png\" alt=\"\u0413\u0440\u0430\u0444\u0438\u043a \u0433\u0440\u0430\u043d\u0438\u0446 \u0440\u0435\u0448\u0435\u043d\u0438\u0439\" title=\"\u0413\u0440\u0430\u0444\u0438\u043a \u0433\u0440\u0430\u043d\u0438\u0446 \u0440\u0435\u0448\u0435\u043d\u0438\u0439\" width=\"1081\" height=\"569\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/55d\/22d\/53d\/55d22d53dd9e49a2552d285966b71a2b.png\"\/><\/p>\n<div><figcaption><strong>\u0413\u0440\u0430\u0444\u0438\u043a \u0433\u0440\u0430\u043d\u0438\u0446 \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/strong><\/figcaption><\/div>\n<\/figure>\n<h4>\u0412\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f<\/h4>\n<p>\u0412\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u0438\u0433\u0440\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u0442\u044c \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u043e\u0441\u0442\u044c, \u0437\u0430\u0434\u0430\u0432\u0430\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0443\u0441\u043b\u044b\u0448\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442 &#171;\u0434\u0430&#187; \u043b\u0438\u0431\u043e &#171;\u043d\u0435\u0442&#187;. \u041b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u043e &#171;\u043f\u043e\u043b&#187; \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u043e &#171;\u0432\u043e\u0437\u0440\u0430\u0441\u0442&#187; \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u0435\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u043c. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0432\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445.<\/p>\n<p>\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0442\u043e\u0433\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u043c \u0443\u0437\u043b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0435\u0440\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0445, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0440\u043e\u0439 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u0443\u0437\u043b\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0443\u0437\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c (\u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u044c) \u0414\u0436\u0438\u043d\u0438 \u2014 \u043c\u0435\u0440\u0430 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u0432 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0443\u0437\u043b\u0435 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443, \u0442\u043e \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438 \u0440\u0430\u0432\u043d\u0430 0, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u0443\u0437\u043b\u0435 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438 \u0440\u0430\u0432\u043d\u0430 0.5.<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"G_{i} = 1 - \\sum\\limits_{k = 1}^{n} P_{i,k}^{2}\" alt=\"G_{i} = 1 - \\sum\\limits_{k = 1}^{n} P_{i,k}^{2}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7ec\/a9a\/891\/7eca9a8916e3064e2399555f6056e342.svg\" width=\"142\" height=\"57\"\/><\/p>\n<ul>\n<li>\n<p>\u042d\u043d\u0442\u0440\u043e\u043f\u0438\u044f \u0428\u0435\u043d\u043d\u043e\u043d\u0430 \u2014 \u043c\u0435\u0440\u0430 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u0431\u0435\u0441\u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u0443\u0437\u043b\u0435. \u041e\u043d\u0430 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b: \u0447\u0435\u043c \u0432\u044b\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438, \u0442\u0435\u043c \u043c\u0435\u043d\u0435\u0435 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"S_{i} = - \\sum\\limits_{k = 1}^{n} P_{i,k} \\ log_{2}P_{i,k}\" alt=\"S_{i} = - \\sum\\limits_{k = 1}^{n} P_{i,k} \\ log_{2}P_{i,k}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a8b\/972\/dac\/a8b972dac851f202ef16525f9288ff3f.svg\" width=\"191\" height=\"57\"\/><\/p>\n<ul>\n<li>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u2014 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0430\u044f \u0434\u043e\u043b\u044e \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\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0443\u0437\u043b\u0435: \u0447\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0443\u0437\u043b\u0435.<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"E_{i} = 1 - max\\ P_{i,k}\" alt=\"E_{i} = 1 - max\\ P_{i,k}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/505\/85f\/6c9\/50585f6c981eb34b11258f64ff244ece.svg\" width=\"153\" height=\"22\"\/><\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"P_{i, k}\" alt=\"P_{i, k}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c92\/48b\/c87\/c9248bc877e77825255bbd8242fe27f7.svg\" width=\"30\" height=\"22\"\/> \u2014 \u044d\u0442\u043e \u0434\u043e\u043b\u044f k-\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0440\u0435\u0434\u0438 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u0432 i-\u043e\u043c \u0443\u0437\u043b\u0435.<\/p>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438 \u0438 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u044f \u0428\u0435\u043d\u043d\u043e\u043d\u0430 \u0437\u0430 \u0441\u0447\u0451\u0442 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 (\u0433\u0434\u0435 P+ \u2014 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043a \u043a\u043b\u0430\u0441\u0441\u0443 &#171;+&#187;), \u0433\u0440\u0430\u0444\u0438\u043a \u0443\u0434\u0432\u043e\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u0414\u0436\u0438\u043d\u0438 \u043e\u0447\u0435\u043d\u044c \u0441\u0445\u043e\u0436 \u0441 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u043c \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438 \u0428\u0435\u043d\u043d\u043e\u043d\u0430: \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u0447\u0443\u0442\u044c \u043c\u0435\u043d\u0435\u0435 \u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \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 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0430 \u0437\u0430 \u0441\u0447\u0451\u0442 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438.  <\/p>\n<p><strong>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/strong>  <\/p>\n<pre><code class=\"python\">import numpy as np import matplotlib.pyplot as plt   def gini(probas):     return np.array([1- (p ** 2 + (1-p) ** 2) for p in probas])   def entropy(probas):     return np.array([-1 * (p * np.log2(p) + (1-p) * np.log2(1-p)) for p in probas])   def misclass_error_rate(probas):     return np.array([1 - max([p, 1-p]) for p in probas])   probas = np.linspace(0, 1, 250) plt.plot(probas, entropy(probas), label=\"Shannon's entropy\") plt.plot(probas, 2 * gini(probas),  label=\"Gini impurity x 2\") plt.plot(probas, 2 * misclass_error_rate(probas), label=\"Misclass error x 2\") plt.plot(probas, gini(probas), label=\"Gini impurity\") plt.plot(probas, misclass_error_rate(probas), label=\"Misclass error\") plt.title(\"Splitting criteria from P+ (binary classification case)\") plt.xlabel(\"P+\") plt.ylabel(\"Impurity\") plt.legend();<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c90\/4c8\/f96\/c904c8f96f5e22ab6d68d09fe69a4c1b.png\" width=\"567\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c90\/4c8\/f96\/c904c8f96f5e22ab6d68d09fe69a4c1b.png\"\/><\/figure>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0443\u0437\u043b\u0430 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b Friedman MSE \u0438 MAE.  <\/p>\n<h4>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c<\/h4>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0436\u0435 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0451\u0442\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f? \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0443\u0437\u043b\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438 \u0438\u043b\u0438 MSE), \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0445 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u0430\u043a \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u0414\u0430\u043b\u0435\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 2 \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0430 (\u0443\u0437\u043b\u0430): \u0432\u0441\u0451 \u0447\u0442\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0434\u0451\u0442 \u0432 \u043b\u0435\u0432\u044b\u0439 \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440, \u0430 \u0432\u0441\u0451 \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u2014 \u0432 \u043f\u0440\u0430\u0432\u044b\u0439. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0445 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430. \u041f\u043e\u0440\u043e\u0433 \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0432 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435 (\u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0435) \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438:<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"J(k, t_{k}) = \\frac{N_{m}^{left}}{N_{m}} G_{left} + \\frac{N_{m}^{right}}{N_{m}} G_{right}\" alt=\"J(k, t_{k}) = \\frac{N_{m}^{left}}{N_{m}} G_{left} + \\frac{N_{m}^{right}}{N_{m}} G_{right}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/13e\/d3b\/e81\/13ed3be81425cde5ef976ef78b9f3d99.svg\" width=\"304\" height=\"52\"\/><\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438:<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"J(k, t_{k}) = \\frac{N_{m}^{left}}{N_{m}} MSE_{left} + \\frac{N_{m}^{right}}{N_{m}} MSE_{right} \" alt=\"J(k, t_{k}) = \\frac{N_{m}^{left}}{N_{m}} MSE_{left} + \\frac{N_{m}^{right}}{N_{m}} MSE_{right} \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3c5\/a6f\/928\/3c5a6f92845b44a12f289d01055a1004.svg\" width=\"368\" height=\"52\"\/><\/p>\n<p>\u0433\u0434\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"J(k, t_{k}) \\to min\" alt=\"J(k, t_{k}) \\to min\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cfc\/ad1\/c45\/cfcad1c45bad54001d833e4deb44a775.svg\" width=\"127\" height=\"22\"\/>.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u2014 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0439 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432. \u041f\u043e\u0440\u043e\u0433 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u043e\u043c \u0432 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435\/\u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u043c\u0443 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044e. :<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"IG(Q) = S_{parent} - (\\frac{N_{m}^{left}}{N_{m}} S_{child}^{left} + \\frac{N_{m}^{right}}{N_{m}} S_{child}^{right}) \\to max\" alt=\"IG(Q) = S_{parent} - (\\frac{N_{m}^{left}}{N_{m}} S_{child}^{left} + \\frac{N_{m}^{right}}{N_{m}} S_{child}^{right}) \\to max\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/87a\/954\/dc1\/87a954dc1ae780b2a711433faae60ef0.svg\" width=\"459\" height=\"52\"\/><\/p>\n<p>\u0433\u0434\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"Q\" alt=\"Q\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c61\/218\/a51\/c61218a51e58a4ccdea158d5627d8ec4.svg\" width=\"15\" height=\"20\"\/> \u2014 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 (\u0432\u043e\u043f\u0440\u043e\u0441) \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"m\" alt=\"m\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dc2\/9be\/b80\/dc29beb801698521bf7661f8f6667883.svg\" width=\"17\" height=\"12\"\/>.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 4 \u043a\u043e\u0442\u0430 \u0438 4 \u0441\u043e\u0431\u0430\u043a\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0438\u0445 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438: &#171;\u0440\u043e\u0441\u0442&#187;, &#171;\u0443\u0448\u0438&#187; (\u0432\u0438\u0441\u044f\u0447\u0438\u0435 \u0438 \u0437\u0430\u043e\u0441\u0442\u0440\u0451\u043d\u043d\u044b\u0435 \u0441\u0442\u043e\u044f\u0447\u0438\u0435) \u0438 &#171;\u0443\u0441\u044b&#187; (\u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043b\u0438\u0431\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435). \u041a\u0430\u043a \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u0430\u043a \u0438 \u043a\u043e\u0442\u043e\u0432? \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0436\u0438\u0432\u043e\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 2 \u0433\u0440\u0443\u043f\u043f\u044b \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0443, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438. \u041f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c (\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u0435\u0439) \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e (\u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0433\u043e) \u0443\u0437\u043b\u0430. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a &#171;\u0440\u043e\u0441\u0442&#187; \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u043c \u0443\u0437\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a &#171;\u0440\u043e\u0441\u0442 \u2a7d 20 \u0441\u043c&#187;. <\/p>\n<blockquote>\n<p><em>\u0421\u0442\u043e\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0445 \u0431\u0438\u043d\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: &#171;\u0443\u0448\u0438 \u2a7d 0.5&#187;, &#171;\u0443\u0441\u044b \u2a7d 0.5&#187;. \u041a\u043e\u0433\u0434\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 2 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0438\u0434\u044b \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 label \u0438\u043b\u0438 one-hot encoding.<\/em>  <\/p>\n<\/blockquote>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6e3\/29e\/78f\/6e329e78fd344316b7e461720a59a876.png\" width=\"959\" height=\"737\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6e3\/29e\/78f\/6e329e78fd344316b7e461720a59a876.png\"\/><\/figure>\n<h4>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0435\u0440\u0435\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 (CART)<\/h4>\n<p>\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:<\/p>\n<ul>\n<li>\n<p>1) \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>2) \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 2 \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0430: \u0432\u0441\u0451 \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043b\u0435\u0432\u044b\u0439 \u0443\u0437\u0435\u043b, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u2014 \u0432 \u043f\u0440\u0430\u0432\u044b\u0439;<\/p>\n<\/li>\n<li>\n<p>3) \u0434\u0430\u043b\u0435\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0448\u0430\u0433\u0438 1-2 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430: \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0433\u043b\u0443\u0431\u0438\u043d\u0430, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u0438\u0441\u0442\u044c\u0435\u0432, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u0432 \u043b\u0438\u0441\u0442\u0435 \u0438\u043b\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0435\u043d\u0438\u044f \u0432 \u0443\u0437\u043b\u0435.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u0440\u0435\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/h4>\n<p>\u0412\u044b\u0440\u0430\u0449\u0435\u043d\u043d\u0430\u044f \u0431\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u043b\u043e\u043d\u043d\u0430 \u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0438 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f 2 \u043f\u043e\u0434\u0445\u043e\u0434\u0430:\u00a0<em>pre-pruning<\/em>\u00a0(\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u043e\u0441\u0442\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u044b\u043c \u0438\u0437 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430) \u0438\u00a0<em>post-pruning<\/em>\u00a0(\u043e\u0442\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043b\u0438\u0448\u043d\u0438\u0445 \u0432\u0435\u0442\u0432\u0435\u0439 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f). \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u043b\u0438\u043a\u0430\u0442\u043d\u044b\u043c \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u0443\u044e \u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u0443\u044e \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043b\u0438\u0448\u044c \u0441\u0430\u043c\u044b\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0443\u0437\u043b\u044b.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 2 \u0442\u0438\u043f\u0430 post-puning&#8217;\u0430:<\/p>\n<ul>\n<li>\n<p><strong>Top-down pruning<\/strong>\u00a0\u2014 \u043c\u0435\u0442\u043e\u0434, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u043e\u0431\u0440\u0435\u0437\u043a\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0432\u0435\u0442\u0432\u0435\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430. \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0438\u0437\u043a\u043e\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e, \u043e\u0434\u043d\u0430\u043a\u043e, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 pre-pruning&#8217;\u043e\u043c, \u0435\u0433\u043e \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u043c \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u0434\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u0430 \u0441\u0447\u0451\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0442\u0432\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0443\u0437\u043b\u044b. \u041a \u0441\u0430\u043c\u044b\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u0432\u0438\u0434\u0430\u043c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0443\u043d\u0438\u043d\u0433\u0430 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><em>Pessimistic Error Pruning (PEP)<\/em>, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0440\u0435\u0437\u0430\u044e\u0442\u0441\u044f \u0432\u0435\u0442\u0432\u0438 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u043f\u043e\u0440\u043e\u0433 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435;<\/p>\n<\/li>\n<li>\n<p><em>Critical Value Pruning (CVP)<\/em>, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0440\u0435\u0437\u0430\u044e\u0442\u0441\u044f \u0432\u0435\u0442\u0432\u0438, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Bottom-up pruning<\/strong>\u00a0\u2014 \u043c\u0435\u0442\u043e\u0434, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u043e\u0431\u0440\u0435\u0437\u043a\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0432\u0435\u0442\u0432\u0435\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043b\u0438\u0441\u0442\u044c\u0435\u0432. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u0437\u0430 \u0441\u0447\u0451\u0442 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043e\u0431\u0445\u043e\u0434\u0430 \u0441\u043d\u0438\u0437\u0443-\u0432\u0432\u0435\u0440\u0445 \u0438 \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u0421\u0430\u043c\u044b\u043c\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u0438\u0434\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0443\u043d\u0438\u043d\u0433\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><em>Minimum Error Pruning (MEP)<\/em>, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0438\u0441\u043a \u0434\u0435\u0440\u0435\u0432\u0430 \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u043d\u0430 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435;<\/p>\n<\/li>\n<li>\n<p><em>Reduced Error Pruning (REP)<\/em>, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0443\u0437\u043b\u044b \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0430\u0434\u0430\u0435\u0442 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435;<\/p>\n<\/li>\n<li>\n<p><em>Cost-complexity pruning (CCP)<\/em>, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u0435\u0440\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0447\u0435\u0440\u0435\u0437 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u043b\u0430\u0431\u0435\u0439\u0448\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043d\u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u043a \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u043e\u0431\u0449\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u0435\u0433\u043e \u043b\u0438\u0441\u0442\u044c\u0435\u0432, \u0430 \u0432\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e k-fold \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0b2\/d3d\/1ce\/0b2d3d1ce4bf7f1b6883aab94ff0798b.png\" alt=\"\u0414\u0435\u0440\u0435\u0432\u043e \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 post-pruning'\u0430\" title=\"\u0414\u0435\u0440\u0435\u0432\u043e \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 post-pruning'\u0430\" width=\"1627\" height=\"955\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0b2\/d3d\/1ce\/0b2d3d1ce4bf7f1b6883aab94ff0798b.png\"\/><\/p>\n<div><figcaption><strong>\u0414\u0435\u0440\u0435\u0432\u043e \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 post-pruning&#8217;\u0430<\/strong><\/figcaption><\/div>\n<\/figure>\n<h4>Minimal cost-complexity pruning<\/h4>\n<p>\u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 scikit-learn \u0434\u043b\u044f \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f cost-complexity pruning, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>1) \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0431\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>2) \u0434\u0430\u043b\u0435\u0435 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0443\u0437\u043b\u043e\u0432 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 MSE \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>3) \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0435\u0433\u043e \u043b\u0438\u0441\u0442\u044c\u0435\u0432;<\/p>\n<\/li>\n<li>\n<p>4) \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0430\u043b\u044c\u0444\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u0430\u043a \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0435\u0433\u043e \u043b\u0438\u0441\u0442\u044c\u0435\u0432;<\/p>\n<\/li>\n<li>\n<p>5) \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\alpha_{ccp}\" alt=\"\\alpha_{ccp}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/53c\/130\/754\/53c130754e38d601034eaffc203bd130.svg\" width=\"33\" height=\"17\"\/>\u00a0\u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u043c \u0443\u0437\u043b\u043e\u043c, \u0430 \u0441\u0430\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 cost_complety_pruning_path \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u043e\u0432\u043e\u043c\u0443 \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0434\u0435\u0440\u0435\u0432\u0443;<\/p>\n<\/li>\n<li>\n<p>6) \u0448\u0430\u0433\u0438 2-5 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043e\u0431\u0440\u0435\u0437\u043a\u0430 \u043d\u0435 \u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u043e \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\alpha_{ccp}\" alt=\"\\alpha_{ccp}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d18\/e40\/22d\/d18e4022d0db3b96d8da7b67c1af0107.svg\" width=\"33\" height=\"17\"\/>\u00a0\u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e, \u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0443 \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432, \u0430 \u0432\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\alpha_{ccp}\" alt=\"\\alpha_{ccp}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/099\/c90\/231\/099c902318edcd1ff34ac0f766972a31.svg\" width=\"33\" height=\"17\"\/>\u00a0\u0438\u0437 cost_complety_pruning_path \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e k-fold \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<\/p>\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>\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u0440\u0435\u0432\u0430:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"R_\\alpha(T) = R(T) + \\alpha|\\widetilde{T}|\" alt=\"R_\\alpha(T) = R(T) + \\alpha|\\widetilde{T}|\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d33\/13c\/53a\/d3313c53a4bfa84042f124d7b7b3c979.svg\" width=\"185\" height=\"25\"\/><\/p>\n<p>\u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\alpha_{ccp}\" alt=\"\\alpha_{ccp}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/865\/ca0\/361\/865ca03612efcaea4dc5e16df93175fa.svg\" width=\"33\" height=\"17\"\/>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\alpha_{ccp} = \\frac{R_{t} - R(T_{t})}{|T| - 1}\" alt=\"\\alpha_{ccp} = \\frac{R_{t} - R(T_{t})}{|T| - 1}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/10f\/886\/f1b\/10f886f1b678cca4f9b8d4df960f92e9.svg\" width=\"158\" height=\"50\"\/><\/p>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0433\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"R_{t}\" alt=\"R_{t}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/083\/40a\/ae4\/08340aae413caeab507ab41ff279cdce.svg\" width=\"21\" height=\"20\"\/> \u0438\u043b\u0438 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0433\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"R(T)\" alt=\"R(T)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/876\/ea6\/5f8\/876ea65f873dfc204edd0e44b23d0582.svg\" width=\"43\" height=\"22\"\/> \u0443\u0437\u043b\u043e\u0432 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"R_{node} = \\frac{N_{m}}{N} G_{m} \" alt=\"R_{node} = \\frac{N_{m}}{N} G_{m} \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f3a\/d6c\/eab\/f3ad6ceab6dc613b1510196b00081a48.svg\" width=\"136\" height=\"43\"\/><\/p>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0433\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"R_{t}\" alt=\"R_{t}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/083\/40a\/ae4\/08340aae413caeab507ab41ff279cdce.svg\" width=\"21\" height=\"20\"\/> \u0438\u043b\u0438 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0433\u043e <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"R(T)\" alt=\"R(T)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/876\/ea6\/5f8\/876ea65f873dfc204edd0e44b23d0582.svg\" width=\"43\" height=\"22\"\/> \u0443\u0437\u043b\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"R_{node} = \\frac{N_{m}}{N} MSE_{m}\" alt=\"R_{node} = \\frac{N_{m}}{N} MSE_{m}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ac\/2ee\/0d4\/2ac2ee0d4a9a8b866b62299febada517.svg\" width=\"168\" height=\"43\"\/><\/p>\n<p>\u0421\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043b\u0438\u0441\u0442\u044c\u0435\u0432 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435\/\u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0435:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"R(T_{t}) = \\sum\\limits_{i=1}^{n} R(T_{i})\" alt=\"R(T_{t}) = \\sum\\limits_{i=1}^{n} R(T_{i})\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/800\/8f7\/d13\/8008f7d13b62f289858321cfec1399c9.svg\" width=\"152\" height=\"57\"\/><\/p>\n<p>T \u2014 \u0447\u0438\u0441\u043b\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 (\u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445) \u0443\u0437\u043b\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/331\/11c\/02e\/33111c02e9d9a3ab801fbbf2ac6032c0.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b cost-complexity pruning'\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430\" title=\"\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b cost-complexity pruning'\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430\" width=\"1805\" height=\"847\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/331\/11c\/02e\/33111c02e9d9a3ab801fbbf2ac6032c0.png\"\/><\/p>\n<div><figcaption><strong>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b cost-complexity pruning&#8217;\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430<\/strong><\/figcaption><\/div>\n<\/figure>\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_linnerud 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.tree import DecisionTreeClassifier, DecisionTreeRegressor, plot_tree from mlxtend.plotting import plot_decision_regions from copy import deepcopy from pprint import pprint<\/code><\/pre>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u043d\u0443\u043b\u044f<\/h4>\n<p>\u0412 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u0437\u043b\u043e\u0432 \u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u043d\u0438\u0445 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0438 \u0432\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0443\u0437\u043b\u0430\u0445 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0432 \u0441\u0442\u0440\u043e\u0447\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0422\u0430\u043a\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 scikit-learn.<\/p>\n<pre><code class=\"python\">class DecisionTreeCART:      def __init__(self, max_depth=100, min_samples=2, ccp_alpha=0.0, regression=False):         self.max_depth = max_depth         self.min_samples = min_samples         self.ccp_alpha = ccp_alpha         self.regression = regression         self.tree = None         self._y_type = None         self._num_all_samples = None      def _set_df_type(self, X, y, dtype):         X = X.astype(dtype)         y = y.astype(dtype) if self.regression else y         self._y_dtype = y.dtype          return X, y      @staticmethod     def _purity(y):         unique_classes = np.unique(y)          return unique_classes.size == 1      @staticmethod     def _is_leaf_node(node):         return not isinstance(node, dict)   # if a node\/tree is a leaf      def _leaf_node(self, y):         class_index = 0          return np.mean(y) if self.regression else y.mode()[class_index]      def _split_df(self, X, y, feature, threshold):         feature_values = X[feature]         left_indexes = X[feature_values &lt;= threshold].index         right_indexes = X[feature_values > threshold].index         sizes = np.array([left_indexes.size, right_indexes.size])          return self._leaf_node(y) if any(sizes == 0) else left_indexes, right_indexes      @staticmethod     def _gini_impurity(y):         _, counts_classes = np.unique(y, return_counts=True)         squared_probabilities = np.square(counts_classes \/ y.size)         gini_impurity = 1 - sum(squared_probabilities)          return gini_impurity      @staticmethod     def _mse(y):         mse = np.mean((y - y.mean()) ** 2)          return mse      @staticmethod     def _cost_function(left_df, right_df, method):         total_df_size = left_df.size + right_df.size         p_left_df = left_df.size \/ total_df_size         p_right_df = right_df.size \/ total_df_size         J_left = method(left_df)         J_right = method(right_df)         J = p_left_df*J_left + p_right_df*J_right          return J  # weighted Gini impurity or weighted mse (depends on a method)      def _node_error_rate(self, y, method):         if self._num_all_samples is None:             self._num_all_samples = y.size   # num samples of all dataframe         current_num_samples = y.size          return current_num_samples \/ self._num_all_samples * method(y)      def _best_split(self, X, y):         features = X.columns         min_cost_function = np.inf         best_feature, best_threshold = None, None         method = self._mse if self.regression else self._gini_impurity          for feature in features:             unique_feature_values = np.unique(X[feature])              for i in range(1, len(unique_feature_values)):                 current_value = unique_feature_values[i]                 previous_value = unique_feature_values[i-1]                 threshold = (current_value + previous_value) \/ 2                 left_indexes, right_indexes = self._split_df(X, y, feature, threshold)                 left_labels, right_labels = y.loc[left_indexes], y.loc[right_indexes]                 current_J = self._cost_function(left_labels, right_labels, method)                  if current_J &lt;= min_cost_function:                     min_cost_function = current_J                     best_feature = feature                     best_threshold = threshold          return best_feature, best_threshold      def _stopping_conditions(self, y, depth, n_samples):         return self._purity(y), depth == self.max_depth, n_samples &lt; self.min_samples      def _grow_tree(self, X, y, depth=0):         current_num_samples = y.size         X, y = self._set_df_type(X, y, np.float128)         method = self._mse if self.regression else self._gini_impurity          if any(self._stopping_conditions(y, depth, current_num_samples)):             RTi = self._node_error_rate(y, method)   # leaf node error rate             leaf_node = f'{self._leaf_node(y)} | error_rate {RTi}'             return leaf_node          Rt = self._node_error_rate(y, method)   # decision node error rate         best_feature, best_threshold = self._best_split(X, y)         decision_node = f'{best_feature} &lt;= {best_threshold} | ' \\                         f'as_leaf {self._leaf_node(y)} error_rate {Rt}'          left_indexes, right_indexes = self._split_df(X, y, best_feature, best_threshold)         left_X, right_X = X.loc[left_indexes], X.loc[right_indexes]         left_labels, right_labels = y.loc[left_indexes], y.loc[right_indexes]          # recursive part         tree = {decision_node: []}         left_subtree = self._grow_tree(left_X, left_labels, depth+1)         right_subtree = self._grow_tree(right_X, right_labels, depth+1)          if left_subtree == right_subtree:             tree = left_subtree         else:             tree[decision_node].extend([left_subtree, right_subtree])          return tree      def _tree_error_rate_info(self, tree, error_rates_list):         if self._is_leaf_node(tree):             *_, leaf_error_rate = tree.split()             error_rates_list.append(np.float128(leaf_error_rate))         else:             decision_node = next(iter(tree))             left_subtree, right_subtree = tree[decision_node]             self._tree_error_rate_info(left_subtree, error_rates_list)             self._tree_error_rate_info(right_subtree, error_rates_list)          RT = sum(error_rates_list)   # total leaf error rate of a tree         num_leaf_nodes = len(error_rates_list)          return RT, num_leaf_nodes      @staticmethod     def _ccp_alpha_eff(decision_node_Rt, leaf_nodes_RTt, num_leafs):          return (decision_node_Rt - leaf_nodes_RTt) \/ (num_leafs - 1)      def _find_weakest_node(self, tree, weakest_node_info):         if self._is_leaf_node(tree):             return tree          decision_node = next(iter(tree))         left_subtree, right_subtree = tree[decision_node]         *_, decision_node_error_rate = decision_node.split()          Rt = np.float128(decision_node_error_rate)         RTt, num_leaf_nodes = self._tree_error_rate_info(tree, [])         ccp_alpha = self._ccp_alpha_eff(Rt, RTt, num_leaf_nodes)         decision_node_index, min_ccp_alpha_index = 0, 1          if ccp_alpha &lt;= weakest_node_info[min_ccp_alpha_index]:             weakest_node_info[decision_node_index] = decision_node             weakest_node_info[min_ccp_alpha_index] = ccp_alpha          self._find_weakest_node(left_subtree, weakest_node_info)         self._find_weakest_node(right_subtree, weakest_node_info)          return weakest_node_info      def _prune_tree(self, tree, weakest_node):         if self._is_leaf_node(tree):             return tree          decision_node = next(iter(tree))         left_subtree, right_subtree = tree[decision_node]         left_subtree_index, right_subtree_index = 0, 1         _, leaf_node = weakest_node.split('as_leaf ')          if weakest_node is decision_node:             tree = weakest_node         if weakest_node in left_subtree:             tree[decision_node][left_subtree_index] = leaf_node         if weakest_node in right_subtree:             tree[decision_node][right_subtree_index] = leaf_node          self._prune_tree(left_subtree, weakest_node)         self._prune_tree(right_subtree, weakest_node)          return tree      def cost_complexity_pruning_path(self, X: pd.DataFrame, y: pd.Series):         tree = self._grow_tree(X, y)   # grow a full tree         tree_error_rate, _ = self._tree_error_rate_info(tree, [])         error_rates = [tree_error_rate]         ccp_alpha_list = [0.0]          while not self._is_leaf_node(tree):             initial_node = [None, np.inf]             weakest_node, ccp_alpha = self._find_weakest_node(tree, initial_node)             tree = self._prune_tree(tree, weakest_node)             tree_error_rate, _ = self._tree_error_rate_info(tree, [])              error_rates.append(tree_error_rate)             ccp_alpha_list.append(ccp_alpha)          return np.array(ccp_alpha_list), np.array(error_rates)      def _ccp_tree_error_rate(self, tree_error_rate, num_leaf_nodes):          return tree_error_rate + self.ccp_alpha*num_leaf_nodes   # regularization      def _optimal_tree(self, X, y):         tree = self._grow_tree(X, y)   # grow a full tree         min_RT_alpha, final_tree = np.inf, None          while not self._is_leaf_node(tree):             RT, num_leaf_nodes = self._tree_error_rate_info(tree, [])             current_RT_alpha = self._ccp_tree_error_rate(RT, num_leaf_nodes)              if current_RT_alpha &lt;= min_RT_alpha:                 min_RT_alpha = current_RT_alpha                 final_tree = deepcopy(tree)              initial_node = [None, np.inf]             weakest_node, _ = self._find_weakest_node(tree, initial_node)             tree = self._prune_tree(tree, weakest_node)          return final_tree      def fit(self, X: pd.DataFrame, y: pd.Series):         self.tree = self._optimal_tree(X, y)      def _traverse_tree(self, sample, tree):         if self._is_leaf_node(tree):             leaf, *_ = tree.split()             return leaf          decision_node = next(iter(tree))  # dict key         left_node, right_node = tree[decision_node]         feature, other = decision_node.split(' &lt;=')         threshold, *_ = other.split()         feature_value = sample[feature]          if np.float128(feature_value) &lt;= np.float128(threshold):             next_node = self._traverse_tree(sample, left_node)    # left_node         else:             next_node = self._traverse_tree(sample, right_node)   # right_node          return next_node      def predict(self, samples: pd.DataFrame):         # apply traverse_tree method for each row in a dataframe         results = samples.apply(self._traverse_tree, args=(self.tree,), axis=1)          return np.array(results.astype(self._y_dtype))<\/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\u043e\u0432<\/h4>\n<pre><code class=\"python\">def tree_plot(sklearn_tree, Xa_train):     plt.figure(figsize=(12, 18))  # customize according to the size of your tree     plot_tree(sklearn_tree, feature_names=Xa_train.columns, filled=True, precision=6)     plt.show()   def tree_scores_plot(estimator, ccp_alphas, train_data, test_data, metric, labels):     train_scores, test_scores = [], []     X_train, y_train = train_data     X_test, y_test = test_data     x_label, y_label = labels      for ccp_alpha_i in ccp_alphas:         estimator.ccp_alpha = ccp_alpha_i         estimator.fit(X_train, y_train)         train_pred_res = estimator.predict(X_train)         test_pred_res = estimator.predict(X_test)          train_score = metric(train_pred_res, y_train)         test_score = metric(test_pred_res, y_test)         train_scores.append(train_score)         test_scores.append(test_score)      fig, ax = plt.subplots()     ax.set_xlabel(x_label)     ax.set_ylabel(y_label)     ax.set_title(f\"{y_label} vs {x_label} for training and testing sets\")     ax.plot(ccp_alphas, train_scores, marker=\"o\", label=\"train\", drawstyle=\"steps-post\")     ax.plot(ccp_alphas, test_scores, marker=\"o\", label=\"test\", drawstyle=\"steps-post\")     ax.legend()     plt.show()   def decision_boundary_plot(X, y, X_train, y_train, clf, feature_indexes, title=None):     if y.dtype != 'int':         y = pd.Series(LabelEncoder().fit_transform(y))         y_train = pd.Series(LabelEncoder().fit_transform(y_train))      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\/himanshunakrani\/iris-dataset\" rel=\"noopener noreferrer nofollow\">Iris dataset<\/a>, \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\u044b \u0446\u0432\u0435\u0442\u043a\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \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 load_linnerud dataset \u0438\u0437 scikit-learn.<\/p>\n<pre><code class=\"python\">df_path = \"\/content\/drive\/MyDrive\/iris.csv\" iris = pd.read_csv(df_path) X1, y1 = iris.iloc[:, :-1], iris.iloc[:, -1] X1_train, X1_test, y1_train, y1_test = train_test_split(X1, y1, test_size=0.3, random_state=0) print(iris)        sepal_length  sepal_width  petal_length  petal_width    species 0             5.1          3.5           1.4          0.2     setosa 1             4.9          3.0           1.4          0.2     setosa 2             4.7          3.2           1.3          0.2     setosa 3             4.6          3.1           1.5          0.2     setosa 4             5.0          3.6           1.4          0.2     setosa ..            ...          ...           ...          ...        ... 145           6.7          3.0           5.2          2.3  virginica 146           6.3          2.5           5.0          1.9  virginica 147           6.5          3.0           5.2          2.0  virginica 148           6.2          3.4           5.4          2.3  virginica 149           5.9          3.0           5.1          1.8  virginica  [150 rows x 5 columns]<\/code><\/pre>\n<pre><code class=\"python\">X2, y2 = load_linnerud(return_X_y=True, as_frame=True) y2 = y2['Pulse'] X2_train, X2_test, y2_train, y2_test = train_test_split(X2, y2, test_size=0.2, random_state=0) print(X2, y2, sep='\\n')       Chins  Situps  Jumps 0     5.0   162.0   60.0 1     2.0   110.0   60.0 2    12.0   101.0  101.0 3    12.0   105.0   37.0 4    13.0   155.0   58.0 5     4.0   101.0   42.0 6     8.0   101.0   38.0 7     6.0   125.0   40.0 8    15.0   200.0   40.0 9    17.0   251.0  250.0 10   17.0   120.0   38.0 11   13.0   210.0  115.0 12   14.0   215.0  105.0 13    1.0    50.0   50.0 14    6.0    70.0   31.0 15   12.0   210.0  120.0 16    4.0    60.0   25.0 17   11.0   230.0   80.0 18   15.0   225.0   73.0 19    2.0   110.0   43.0  0     50.0 1     52.0 2     58.0 3     62.0 4     46.0 5     56.0 6     56.0 7     60.0 8     74.0 9     56.0 10    50.0 11    52.0 12    64.0 13    50.0 14    46.0 15    62.0 16    54.0 17    52.0 18    54.0 19    68.0 Name: Pulse, 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 \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0440\u0438\u0441 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0443\u043d\u0438\u043d\u0433\u0430 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0430\u0441\u044c, \u0437\u0430\u0442\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e (alpha=0.0143) \u0441 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0443\u0437\u043b\u043e\u0432.<\/p>\n<p>\u0410 \u0432\u043e\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0432 alpha=3.613, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0434\u0435\u0440\u0435\u0432\u043e \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435. \u0412\u0441\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> <strong>\u0434\u043e \u043f\u0440\u0443\u043d\u0438\u043d\u0433\u0430<\/strong><\/p>\n<pre><code class=\"python\">tree_classifier = DecisionTreeCART() tree_classifier.fit(X1_train, y1_train) clf_ccp_alphas, _ = tree_classifier.cost_complexity_pruning_path(X1_train, y1_train) clf_ccp_alphas = clf_ccp_alphas[:-1]  sk_tree_classifier = DecisionTreeClassifier(random_state=0) sk_tree_classifier.fit(X1_train, y1_train) sk_clf_path = sk_tree_classifier.cost_complexity_pruning_path(X1_train, y1_train) sk_clf_ccp_alphas = sk_clf_path.ccp_alphas[:-1]  sk_clf_estimator = DecisionTreeClassifier(random_state=0) train1_data, test1_data = [X1_train, y1_train], [X1_test, y1_test] metric = accuracy_score labels = ['Alpha', 'Accuracy']  pprint(tree_classifier.tree, width=180) tree_plot(sk_tree_classifier, X1_train) print(f'tree alphas: {clf_ccp_alphas}', f'sklearn alphas: {sk_clf_ccp_alphas}', sep='\\n') tree_scores_plot(sk_clf_estimator, clf_ccp_alphas, train1_data, test1_data, metric, labels)   {'petal_width &lt;= 0.75 | as_leaf virginica error_rate 0.6643083900226757': ['setosa | error_rate 0.0',                                                                            {'petal_length &lt;= 4.95 | as_leaf virginica error_rate 0.33480885311871234': [{'petal_width &lt;= 1.65 | as_leaf versicolor error_rate 0.0521008403361345': ['versicolor '                                                                                                                                                                                                                                     '| '                                                                                                                                                                                                                                     'error_rate '                                                                                                                                                                                                                                     '0.0',                                                                                                                                                                                                                                     {'sepal_width &lt;= 3.1 | as_leaf virginica error_rate 0.014285714285714287': ['virginica '                                                                                                                                                                                                                                                                                                                 '| '                                                                                                                                                                                                                                                                                                                 'error_rate '                                                                                                                                                                                                                                                                                                                 '0.0',                                                                                                                                                                                                                                                                                                                 'versicolor '                                                                                                                                                                                                                                                                                                                 '| '                                                                                                                                                                                                                                                                                                                 'error_rate '                                                                                                                                                                                                                                                                                                                 '0.0']}]},                                                                                                                                                         {'petal_width &lt;= 1.75 | as_leaf virginica error_rate 0.018532818532818515': [{'petal_width &lt;= 1.65 | as_leaf virginica error_rate 0.014285714285714287': ['virginica '                                                                                                                                                                                                                                                                                                                   '| '                                                                                                                                                                                                                                                                                                                   'error_rate '                                                                                                                                                                                                                                                                                                                   '0.0',                                                                                                                                                                                                                                                                                                                   'versicolor '                                                                                                                                                                                                                                                                                                                   '| '                                                                                                                                                                                                                                                                                                                   'error_rate '                                                                                                                                                                                                                                                                                                                   '0.0']},                                                                                                                                                                                                                                      'virginica '                                                                                                                                                                                                                                      '| '                                                                                                                                                                                                                                      'error_rate '                                                                                                                                                                                                                                      '0.0']}]}]} <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aee\/7bf\/13a\/aee7bf13a2513a81096daeee904619dd.png\" width=\"950\" height=\"1406\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aee\/7bf\/13a\/aee7bf13a2513a81096daeee904619dd.png\"\/><\/figure>\n<pre><code class=\"python\">tree alphas: [0.         0.00926641 0.01428571 0.03781513 0.26417519] sklearn alphas: [0.         0.00926641 0.01428571 0.03781513 0.26417519]<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b8f\/212\/568\/b8f2125685fd271a643cb3648fc7bec8.png\" width=\"576\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b8f\/212\/568\/b8f2125685fd271a643cb3648fc7bec8.png\"\/><\/figure>\n<p><strong>\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f<\/strong> <strong>\u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0443\u043d\u0438\u043d\u0433\u0430<\/strong><\/p>\n<pre><code class=\"python\">tree_clf_prediction = tree_classifier.predict(X1_test) tree_clf_accuracy = accuracy_score(tree_clf_prediction, y1_test) sk_tree_clf_prediction = sk_tree_classifier.predict(X1_test) sk_clf_accuracy = accuracy_score(sk_tree_clf_prediction, y1_test)  best_clf_ccp_alpha = 0.0143 # based on a plot best_tree_classifier = DecisionTreeCART(ccp_alpha=best_clf_ccp_alpha) best_tree_classifier.fit(X1_train, y1_train) best_tree_clf_prediction = best_tree_classifier.predict(X1_test) best_tree_clf_accuracy = accuracy_score(best_tree_clf_prediction, y1_test)  best_sk_tree_classifier = DecisionTreeClassifier(random_state=0, ccp_alpha=best_clf_ccp_alpha) best_sk_tree_classifier.fit(X1_train, y1_train) best_sk_tree_clf_prediction = best_sk_tree_classifier.predict(X1_test) best_sk_clf_accuracy = accuracy_score(best_sk_tree_clf_prediction, y1_test)  print('tree prediction', tree_clf_prediction, ' ', sep='\\n') print('sklearn prediction', sk_tree_clf_prediction, ' ', sep='\\n') print('best tree prediction', best_tree_clf_prediction, ' ', sep='\\n') print('best sklearn prediction', best_sk_tree_clf_prediction, ' ', sep='\\n')  pprint(best_tree_classifier.tree, width=180) tree_plot(best_sk_tree_classifier, X1_train) print(f'our tree pruning accuracy: before {tree_clf_accuracy} -> after {best_tree_clf_accuracy}') print(f'sklearn tree pruning accuracy: before {sk_clf_accuracy} -> after {best_sk_clf_accuracy}')   tree prediction ['virginica' 'versicolor' 'setosa' 'virginica' 'setosa' 'virginica'  'setosa' 'versicolor' 'versicolor' 'versicolor' 'virginica' 'versicolor'  'versicolor' 'versicolor' 'versicolor' 'setosa' 'versicolor' 'versicolor'  'setosa' 'setosa' 'virginica' 'versicolor' 'setosa' 'setosa' 'virginica'  'setosa' 'setosa' 'versicolor' 'versicolor' 'setosa' 'virginica'  'versicolor' 'setosa' 'virginica' 'virginica' 'versicolor' 'setosa'  'virginica' 'versicolor' 'versicolor' 'virginica' 'setosa' 'virginica'  'setosa' 'setosa']   sklearn prediction ['virginica' 'versicolor' 'setosa' 'virginica' 'setosa' 'virginica'  'setosa' 'versicolor' 'versicolor' 'versicolor' 'virginica' 'versicolor'  'versicolor' 'versicolor' 'versicolor' 'setosa' 'versicolor' 'versicolor'  'setosa' 'setosa' 'virginica' 'versicolor' 'setosa' 'setosa' 'virginica'  'setosa' 'setosa' 'versicolor' 'versicolor' 'setosa' 'virginica'  'versicolor' 'setosa' 'virginica' 'virginica' 'versicolor' 'setosa'  'virginica' 'versicolor' 'versicolor' 'virginica' 'setosa' 'virginica'  'setosa' 'setosa']   best tree prediction ['virginica' 'versicolor' 'setosa' 'virginica' 'setosa' 'virginica'  'setosa' 'versicolor' 'versicolor' 'versicolor' 'virginica' 'versicolor'  'versicolor' 'versicolor' 'versicolor' 'setosa' 'versicolor' 'versicolor'  'setosa' 'setosa' 'virginica' 'versicolor' 'setosa' 'setosa' 'virginica'  'setosa' 'setosa' 'versicolor' 'versicolor' 'setosa' 'virginica'  'versicolor' 'setosa' 'virginica' 'virginica' 'versicolor' 'setosa'  'virginica' 'versicolor' 'versicolor' 'virginica' 'setosa' 'virginica'  'setosa' 'setosa']   best sklearn prediction ['virginica' 'versicolor' 'setosa' 'virginica' 'setosa' 'virginica'  'setosa' 'versicolor' 'versicolor' 'versicolor' 'virginica' 'versicolor'  'versicolor' 'versicolor' 'versicolor' 'setosa' 'versicolor' 'versicolor'  'setosa' 'setosa' 'virginica' 'versicolor' 'setosa' 'setosa' 'virginica'  'setosa' 'setosa' 'versicolor' 'versicolor' 'setosa' 'virginica'  'versicolor' 'setosa' 'virginica' 'virginica' 'versicolor' 'setosa'  'virginica' 'versicolor' 'versicolor' 'virginica' 'setosa' 'virginica'  'setosa' 'setosa']   {'petal_width &lt;= 0.75 | as_leaf virginica error_rate 0.6643083900226757': ['setosa | error_rate 0.0',                                                                            {'petal_length &lt;= 4.95 | as_leaf virginica error_rate 0.33480885311871234': [{'petal_width &lt;= 1.65 | as_leaf versicolor error_rate 0.0521008403361345': ['versicolor '                                                                                                                                                                                                                                     '| '                                                                                                                                                                                                                                     'error_rate '                                                                                                                                                                                                                                     '0.0',                                                                                                                                                                                                                                     'virginica '                                                                                                                                                                                                                                     'error_rate '                                                                                                                                                                                                                                     '0.014285714285714287']},                                                                                                                                                         'virginica error_rate '                                                                                                                                                         '0.018532818532818515']}]}<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ecd\/32d\/b3e\/ecd32db3e767594cb89451b7a056ece9.png\" width=\"950\" height=\"1406\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ecd\/32d\/b3e\/ecd32db3e767594cb89451b7a056ece9.png\"\/><\/figure>\n<pre><code class=\"python\">our tree pruning accuracy: before 0.9777777777777777 -> after 0.9777777777777777 sklearn tree pruning accuracy: before 0.9777777777777777 -> after 0.9777777777777777<\/code><\/pre>\n<p><strong>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0445 \u0433\u0440\u0430\u043d\u0438\u0446 \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0443\u043d\u0438\u043d\u0433\u0430<\/strong><\/p>\n<pre><code class=\"python\">feature_indexes = [2, 3] title1 = 'Classification tree surface before pruning' decision_boundary_plot(X1, y1, X1_train, y1_train, sk_tree_classifier, feature_indexes, title1)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/968\/5bb\/398\/9685bb39817a4c79832ffc7d58931adb.png\" width=\"578\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/968\/5bb\/398\/9685bb39817a4c79832ffc7d58931adb.png\"\/><\/figure>\n<pre><code class=\"python\">feature_indexes = [2, 3] title2 = 'Classification tree surface after pruning' decision_boundary_plot(X1, y1, X1_train, y1_train, best_sk_tree_classifier, feature_indexes, title2)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d30\/6d0\/8d6\/d306d08d6cece8361e15a528899f49cd.png\" width=\"578\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d30\/6d0\/8d6\/d306d08d6cece8361e15a528899f49cd.png\"\/><\/figure>\n<pre><code class=\"python\">feature_indexes = [2, 3] plt.figure(figsize=(10, 15))  for i, alpha in enumerate(clf_ccp_alphas):     sk_tree_clf = DecisionTreeClassifier(random_state=0, ccp_alpha=alpha)     plt.subplot(3, 2, i + 1)     plt.subplots_adjust(hspace=0.5)     title = f'ccp_alpha = {alpha}'     decision_boundary_plot(X1, y1, X1_train, y1_train, sk_tree_clf, feature_indexes, title)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bce\/ac8\/1e0\/bceac81e00ddb6639817ea8edc26303a.png\" alt=\"\u041f\u0440\u0443\u043d\u0438\u043d\u0433 \u043f\u0440\u0438 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 alpha ccp\" title=\"\u041f\u0440\u0443\u043d\u0438\u043d\u0433 \u043f\u0440\u0438 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 alpha ccp\" width=\"857\" height=\"1240\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bce\/ac8\/1e0\/bceac81e00ddb6639817ea8edc26303a.png\"\/><\/p>\n<div><figcaption><strong>\u041f\u0440\u0443\u043d\u0438\u043d\u0433 \u043f\u0440\u0438 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 alpha ccp<\/strong><\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0420\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u043e \u043f\u0440\u0443\u043d\u0438\u043d\u0433\u0430<\/strong>  <\/p>\n<pre><code class=\"python\">tree_regressor = DecisionTreeCART(regression=True) tree_regressor.fit(X2_train, y2_train) reg_ccp_alphas, _ = tree_regressor.cost_complexity_pruning_path(X2_train, y2_train) reg_ccp_alphas = reg_ccp_alphas[:-1]  sk_tree_regressor = DecisionTreeRegressor(random_state=0) sk_tree_regressor.fit(X2_train, y2_train) sk_reg_path = sk_tree_regressor.cost_complexity_pruning_path(X2_train, y2_train) sk_reg_ccp_alphas = sk_reg_path.ccp_alphas[:-1]  reg_estimator = DecisionTreeCART(regression=True) sk_reg_estimator = DecisionTreeRegressor(random_state=0) train2_data, test2_data = [X2_train, y2_train], [X2_test, y2_test] metric = mean_absolute_percentage_error labels = ['Alpha', 'MAPE']  pprint(tree_regressor.tree) tree_plot(sk_tree_regressor, X2_train)  print(f'CART alphas: {reg_ccp_alphas}') tree_scores_plot(reg_estimator, reg_ccp_alphas, train2_data, test2_data, metric, labels) print(f'sklearn_alphas: {sk_reg_ccp_alphas}') tree_scores_plot(sk_reg_estimator, sk_reg_ccp_alphas, train2_data, test2_data, metric, labels)   {'Jumps &lt;= 90.5 | as_leaf 54.625 error_rate 29.359375': [{'Jumps &lt;= 46.0 | as_leaf 52.90909090909091 error_rate 17.181818181818183': [{'Jumps &lt;= 34.0 | as_leaf 54.857142857142854 error_rate 11.428571428571429': [{'Jumps &lt;= 28.0 | as_leaf 50.0 error_rate 2.0': ['54.0 '                                                                                                                                                                                                                                                                      '| '                                                                                                                                                                                                                                                                      'error_rate '                                                                                                                                                                                                                                                                      '0.0',                                                                                                                                                                                                                                                                      '46.0 '                                                                                                                                                                                                                                                                      '| '                                                                                                                                                                                                                                                                      'error_rate '                                                                                                                                                                                                                                                                      '0.0']},                                                                                                                                                                                                                     {'Chins &lt;= 14.5 | as_leaf 56.8 error_rate 5.3': [{'Situps &lt;= 103.0 | as_leaf 58.5 error_rate 1.6875': ['56.0 '                                                                                                                                                                                                                                                                                                                            '| '                                                                                                                                                                                                                                                                                                                            'error_rate '                                                                                                                                                                                                                                                                                                                            '0.0',                                                                                                                                                                                                                                                                                                                            {'Jumps &lt;= 38.5 | as_leaf 61.0 error_rate 0.125': ['62.0 '                                                                                                                                                                                                                                                                                                                                                                               '| '                                                                                                                                                                                                                                                                                                                                                                               'error_rate '                                                                                                                                                                                                                                                                                                                                                                               '0.0',                                                                                                                                                                                                                                                                                                                                                                               '60.0 '                                                                                                                                                                                                                                                                                                                                                                               '| '                                                                                                                                                                                                                                                                                                                                                                               'error_rate '                                                                                                                                                                                                                                                                                                                                                                               '0.0']}]},                                                                                                                                                                                                                                                                      '50.0 '                                                                                                                                                                                                                                                                      '| '                                                                                                                                                                                                                                                                      'error_rate '                                                                                                                                                                                                                                                                      '0.0']}]},                                                                                                                                       {'Chins &lt;= 12.0 | as_leaf 49.5 error_rate 1.1875': [{'Jumps &lt;= 70.0 | as_leaf 50.666666666666664 error_rate 0.16666666666666666': ['50.0 '                                                                                                                                                                                                                                                                          '| '                                                                                                                                                                                                                                                                          'error_rate '                                                                                                                                                                                                                                                                          '0.0',                                                                                                                                                                                                                                                                          '52.0 '                                                                                                                                                                                                                                                                          '| '                                                                                                                                                                                                                                                                          'error_rate '                                                                                                                                                                                                                                                                          '0.0']},                                                                                                                                                                                           '46.0 '                                                                                                                                                                                           '| '                                                                                                                                                                                           'error_rate '                                                                                                                                                                                           '0.0']}]},                                                          {'Jumps &lt;= 110.0 | as_leaf 58.4 error_rate 5.7': [{'Jumps &lt;= 103.0 | as_leaf 61.0 error_rate 1.125': ['58.0 '                                                                                                                                                                '| '                                                                                                                                                                'error_rate '                                                                                                                                                                '0.0',                                                                                                                                                                '64.0 '                                                                                                                                                                '| '                                                                                                                                                                'error_rate '                                                                                                                                                                '0.0']},                                                                                                            {'Chins &lt;= 12.5 | as_leaf 56.666666666666664 error_rate 3.1666666666666665': ['62.0 '                                                                                                                                                                                          '| '                                                                                                                                                                                          'error_rate '                                                                                                                                                                                          '0.0',                                                                                                                                                                                          {'Jumps &lt;= 182.5 | as_leaf 54.0 error_rate 0.5': ['52.0 '                                                                                                                                                                                                                                            '| '                                                                                                                                                                                                                                            'error_rate '                                                                                                                                                                                                                                            '0.0',                                                                                                                                                                                                                                            '56.0 '                                                                                                                                                                                                                                            '| '                                                                                                                                                                                                                                            'error_rate '                                                                                                                                                                                                                                            '0.0']}]}]}]}<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aaf\/cd0\/df4\/aafcd0df46c2293ea43064a7920ebf24.png\" width=\"950\" height=\"1406\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aaf\/cd0\/df4\/aafcd0df46c2293ea43064a7920ebf24.png\"\/><\/figure>\n<pre><code class=\"python\">CART alphas: [0.         0.125      0.16666667 0.5        1.02083333 1.125  1.5625     2.         2.0375     3.6125     4.12857143 4.56574675]<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6dd\/0f9\/8cd\/6dd0f98cdaf47e8bbfe31428f1efaf9e.png\" width=\"576\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6dd\/0f9\/8cd\/6dd0f98cdaf47e8bbfe31428f1efaf9e.png\"\/><\/figure>\n<pre><code class=\"python\">sklearn_alphas: [0.         0.125      0.16666667 0.5        1.02083333 1.125  1.5625     2.         2.0375     3.6125     4.12857143 4.56574675]<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/315\/a15\/d24\/315a15d24ed26bad2558fbef53fe8184.png\" width=\"576\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/315\/a15\/d24\/315a15d24ed26bad2558fbef53fe8184.png\"\/><\/figure>\n<p><strong>\u0420\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0443\u043d\u0438\u043d\u0433\u0430<\/strong>  <\/p>\n<pre><code class=\"python\">tree_reg_prediction = tree_regressor.predict(X2_test) tree_reg_error = mean_absolute_percentage_error(tree_reg_prediction, y2_test) sk_tree_reg_prediction = sk_tree_regressor.predict(X2_test) sk_reg_error= mean_absolute_percentage_error(sk_tree_reg_prediction, y2_test)  best_reg_ccp_alpha = 3.613   # based on a plot best_tree_regressor = DecisionTreeCART(ccp_alpha=best_reg_ccp_alpha, regression=True) best_tree_regressor.fit(X2_train, y2_train) best_tree_reg_prediction = best_tree_regressor.predict(X2_test) lowest_tree_reg_error = mean_absolute_percentage_error(best_tree_reg_prediction, y2_test)  best_sk_tree_regressor = DecisionTreeRegressor(random_state=0, ccp_alpha=best_reg_ccp_alpha) best_sk_tree_regressor.fit(X2_train, y2_train) best_sk_tree_reg_prediction = best_sk_tree_regressor.predict(X2_test) lowest_sk_reg_error = mean_absolute_percentage_error(best_sk_tree_reg_prediction, y2_test)  print('tree prediction', tree_reg_prediction, ' ', sep='\\n') print('sklearn prediction', sk_tree_reg_prediction, ' ', sep='\\n') print('best tree prediction', best_tree_reg_prediction, ' ', sep='\\n') print('best sklearn prediction', best_sk_tree_reg_prediction, ' ', sep='\\n')  pprint(best_tree_regressor.tree) tree_plot(best_sk_tree_regressor, X2_train) print(f'tree error: before {tree_reg_error} -> after pruning {lowest_tree_reg_error}') print(f'sklearn tree error: before {sk_reg_error} -> after pruning {lowest_sk_reg_error}')   tree prediction [46. 50. 60. 50.]   sklearn prediction [46. 50. 60. 50.]   best tree prediction [49.5 49.5 56.8 56.8]   best sklearn prediction [49.5 49.5 56.8 56.8]   {'Jumps &lt;= 90.5 | as_leaf 54.625 error_rate 29.359375': [{'Jumps &lt;= 46.0 | as_leaf 52.90909090909091 error_rate 17.181818181818183': [{'Jumps &lt;= 34.0 | as_leaf 54.857142857142854 error_rate 11.428571428571429': ['50.0 '                                                                                                                                                                                                                     'error_rate '                                                                                                                                                                                                                     '2.0',                                                                                                                                                                                                                     '56.8 '                                                                                                                                                                                                                     'error_rate '                                                                                                                                                                                                                     '5.3']},                                                                                                                                       '49.5 '                                                                                                                                       'error_rate '                                                                                                                                       '1.1875']},                                                          '58.4 error_rate 5.7']}<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cea\/db3\/6d2\/ceadb36d233fd9d10441f1d777b97f16.png\" width=\"950\" height=\"1406\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cea\/db3\/6d2\/ceadb36d233fd9d10441f1d777b97f16.png\"\/><\/figure>\n<pre><code class=\"python\">tree error: before 0.20681159420289855 -> after pruning 0.16035353535353536 sklearn tree error: before 0.20681159420289855 -> after pruning 0.1603535353535354<\/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 \u0434\u0435\u0440\u0435\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/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>\u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0432 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043f\u043b\u043e\u0445\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \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>\u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0441\u043e\u0431\u043e\u0439 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p><u>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/u>:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0438\u0441\u043a \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f NP-\u043f\u043e\u043b\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445;<\/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 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a \u0448\u0443\u043c\u0443 \u0438 \u0432\u044b\u0431\u0440\u043e\u0441\u0430\u043c \u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/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 \u00abThe CART Decision Tree for Mining Data Streams\u00bb, Leszek Rutkowskia, Maciej Jaworskia, Lena Pietruczuka, Piotr Dudaa.<\/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\/tree.html#\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 CART<\/a>\u00a0;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.tree.DecisionTreeClassifier.html\" rel=\"noopener noreferrer nofollow\">DecisionTreeClassifier<\/a>\u00a0;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.tree.DecisionTreeRegressor.html\" rel=\"noopener noreferrer nofollow\">DecisionTreeRegressor<\/a>\u00a0;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/auto_examples\/tree\/plot_cost_complexity_pruning.html\" rel=\"noopener noreferrer nofollow\">pruning<\/a>\u00a0.<\/p>\n<\/li>\n<\/ul>\n<p>\u041b\u0435\u043a\u0446\u0438\u0438: <a href=\"https:\/\/www.youtube.com\/watch?v=KEprOSyrOVY\" rel=\"noopener noreferrer nofollow\">\u043e\u0434\u0438\u043d<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=1I5MBdkpWgo\" rel=\"noopener noreferrer nofollow\">\u0434\u0432\u0430<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=5aIFgrrTqOw\" rel=\"noopener noreferrer nofollow\">\u0442\u0440\u0438<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=5O8HvA9pMew\/\" rel=\"noopener noreferrer nofollow\">\u0447\u0435\u0442\u044b\u0440\u0435<\/a>.<\/p>\n<p>\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439: <a href=\"https:\/\/www.youtube.com\/playlist?list=PLPOTBrypY74xS3WD0G_uzqPjCQfU6IRK-\" rel=\"noopener noreferrer nofollow\">\u043e\u0434\u0438\u043d<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=_L39rN6gz7Y\" rel=\"noopener noreferrer nofollow\">\u0434\u0432\u0430<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=g9c66TUylZ4\" rel=\"noopener noreferrer nofollow\">\u0442\u0440\u0438<\/a>.<\/p>\n<p>Pruning:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/www.programmersought.com\/article\/47967993808\/\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0438\u0434\u0435\u043e: <a href=\"https:\/\/www.youtube.com\/watch?v=Tg2OGohaUTc\" rel=\"noopener noreferrer nofollow\">\u043e\u0434\u0438\u043d<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=D0efHEJsfHo\" rel=\"noopener noreferrer nofollow\">\u0434\u0432\u0430<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=4VAOjWCHzXk\" rel=\"noopener noreferrer nofollow\">\u0442\u0440\u0438<\/a>.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/801885\/\" rel=\"noopener noreferrer nofollow\"><strong>? K-\u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (KNN)<\/strong><\/a><strong>  |  <\/strong><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><\/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\/801515\/\"> https:\/\/habr.com\/ru\/articles\/801515\/<\/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>\u0414\u0435\u0440\u0435\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 CART (Classification and Regressoin Tree) \u2014 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u0438 \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430 \u0438 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0447\u0438\u0441\u043b\u043e \u0441\u0430\u043c\u044b\u0445 \u043c\u043e\u0449\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c. \u0414\u0435\u0440\u0435\u0432\u044c\u044f \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041a \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u043c \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435: ID3, C4.5, C5.0. <\/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\/decision-tree-cart-from-scratch-full-tutorial\" 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\/07%29%20%D0%94%D0%B5%D1%80%D0%B5%D0%B2%D0%BE%20%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D0%B9%20%28CART%29.ipynb\" rel=\"noopener noreferrer nofollow\"><strong><em>GitHub<\/em><\/strong><\/a><em>\u00a0(rus).<\/em>  <\/p>\n<\/blockquote>\n<h4>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/h4>\n<p>\u0420\u0435\u0448\u0430\u044e\u0449\u0435\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432: \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b, \u0432\u0435\u0442\u0432\u0438 (\u043b\u0435\u0432\u0430\u044f \u0438 \u043f\u0440\u0430\u0432\u0430\u044f), \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0438 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 (\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435) \u0443\u0437\u043b\u044b. \u041a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0438 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0443\u0437\u043b\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0441 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043d\u0430 \u0447\u0430\u0441\u0442\u0438 (\u043b\u0435\u0432\u0430\u044f \u0438 \u043f\u0440\u0430\u0432\u0430\u044f), \u0430 \u043b\u0438\u0441\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u043c\u0438: \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u043b\u0438\u0441\u0442\u0435 \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0430 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<figure class=\"full-width\">\n<div><figcaption><strong>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 CART<\/strong><\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0439 \u0443\u0437\u0435\u043b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0433\u0440\u0430\u043d\u0438\u0446 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0443\u0447\u0430\u0441\u0442\u043a\u0438 \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u043e \u043e\u043d\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0434\u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c.  <\/p>\n<figure class=\"full-width\">\n<div><figcaption><strong>\u0413\u0440\u0430\u0444\u0438\u043a \u0433\u0440\u0430\u043d\u0438\u0446 \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/strong><\/figcaption><\/div>\n<\/figure>\n<h4>\u0412\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f<\/h4>\n<p>\u0412\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u0438\u0433\u0440\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u0442\u044c \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u043e\u0441\u0442\u044c, \u0437\u0430\u0434\u0430\u0432\u0430\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0443\u0441\u043b\u044b\u0448\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442 &#171;\u0434\u0430&#187; \u043b\u0438\u0431\u043e &#171;\u043d\u0435\u0442&#187;. \u041b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u043e &#171;\u043f\u043e\u043b&#187; \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u043e &#171;\u0432\u043e\u0437\u0440\u0430\u0441\u0442&#187; \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u0435\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u043c. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0432\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445.<\/p>\n<p>\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0442\u043e\u0433\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u043c \u0443\u0437\u043b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0435\u0440\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0445, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0440\u043e\u0439 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u0443\u0437\u043b\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0443\u0437\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c (\u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u044c) \u0414\u0436\u0438\u043d\u0438 \u2014 \u043c\u0435\u0440\u0430 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u0432 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0443\u0437\u043b\u0435 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0442 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443, \u0442\u043e \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438 \u0440\u0430\u0432\u043d\u0430 0, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u0443\u0437\u043b\u0435 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438 \u0440\u0430\u0432\u043d\u0430 0.5.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u042d\u043d\u0442\u0440\u043e\u043f\u0438\u044f \u0428\u0435\u043d\u043d\u043e\u043d\u0430 \u2014 \u043c\u0435\u0440\u0430 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u0431\u0435\u0441\u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u0443\u0437\u043b\u0435. \u041e\u043d\u0430 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b: \u0447\u0435\u043c \u0432\u044b\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438, \u0442\u0435\u043c \u043c\u0435\u043d\u0435\u0435 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u2014 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0430\u044f \u0434\u043e\u043b\u044e \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\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0443\u0437\u043b\u0435: \u0447\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0443\u0437\u043b\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435  \u2014 \u044d\u0442\u043e \u0434\u043e\u043b\u044f k-\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0440\u0435\u0434\u0438 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u0432 i-\u043e\u043c \u0443\u0437\u043b\u0435.<\/p>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438 \u0438 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u044f \u0428\u0435\u043d\u043d\u043e\u043d\u0430 \u0437\u0430 \u0441\u0447\u0451\u0442 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 (\u0433\u0434\u0435 P+ \u2014 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043a \u043a\u043b\u0430\u0441\u0441\u0443 &#171;+&#187;), \u0433\u0440\u0430\u0444\u0438\u043a \u0443\u0434\u0432\u043e\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u0414\u0436\u0438\u043d\u0438 \u043e\u0447\u0435\u043d\u044c \u0441\u0445\u043e\u0436 \u0441 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u043c \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438 \u0428\u0435\u043d\u043d\u043e\u043d\u0430: \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u0447\u0443\u0442\u044c \u043c\u0435\u043d\u0435\u0435 \u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \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 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0430 \u0437\u0430 \u0441\u0447\u0451\u0442 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438.  <\/p>\n<p><strong>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/strong>  <\/p>\n<pre><code class=\"python\">import numpy as np import matplotlib.pyplot as plt   def gini(probas):     return np.array([1- (p ** 2 + (1-p) ** 2) for p in probas])   def entropy(probas):     return np.array([-1 * (p * np.log2(p) + (1-p) * np.log2(1-p)) for p in probas])   def misclass_error_rate(probas):     return np.array([1 - max([p, 1-p]) for p in probas])   probas = np.linspace(0, 1, 250) plt.plot(probas, entropy(probas), label=\"Shannon's entropy\") plt.plot(probas, 2 * gini(probas),  label=\"Gini impurity x 2\") plt.plot(probas, 2 * misclass_error_rate(probas), label=\"Misclass error x 2\") plt.plot(probas, gini(probas), label=\"Gini impurity\") plt.plot(probas, misclass_error_rate(probas), label=\"Misclass error\") plt.title(\"Splitting criteria from P+ (binary classification case)\") plt.xlabel(\"P+\") plt.ylabel(\"Impurity\") plt.legend();<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0443\u0437\u043b\u0430 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b Friedman MSE \u0438 MAE.  <\/p>\n<h4>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c<\/h4>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0436\u0435 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0451\u0442\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f? \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0443\u0437\u043b\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438 \u0438\u043b\u0438 MSE), \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0445 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u0430\u043a \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u0414\u0430\u043b\u0435\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 2 \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0430 (\u0443\u0437\u043b\u0430): \u0432\u0441\u0451 \u0447\u0442\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0434\u0451\u0442 \u0432 \u043b\u0435\u0432\u044b\u0439 \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440, \u0430 \u0432\u0441\u0451 \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u2014 \u0432 \u043f\u0440\u0430\u0432\u044b\u0439. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0445 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430. \u041f\u043e\u0440\u043e\u0433 \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0432 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435 (\u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0435) \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438:<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438:<\/p>\n<\/li>\n<\/ul>\n<p>\u0433\u0434\u0435 .<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u2014 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0439 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432. \u041f\u043e\u0440\u043e\u0433 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u043e\u043c \u0432 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435\/\u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u043c\u0443 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044e. :<\/p>\n<p>\u0433\u0434\u0435  \u2014 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 (\u0432\u043e\u043f\u0440\u043e\u0441) \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0430 .<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 4 \u043a\u043e\u0442\u0430 \u0438 4 \u0441\u043e\u0431\u0430\u043a\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0438\u0445 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438: &#171;\u0440\u043e\u0441\u0442&#187;, &#171;\u0443\u0448\u0438&#187; (\u0432\u0438\u0441\u044f\u0447\u0438\u0435 \u0438 \u0437\u0430\u043e\u0441\u0442\u0440\u0451\u043d\u043d\u044b\u0435 \u0441\u0442\u043e\u044f\u0447\u0438\u0435) \u0438 &#171;\u0443\u0441\u044b&#187; (\u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043b\u0438\u0431\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435). \u041a\u0430\u043a \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u0430\u043a \u0438 \u043a\u043e\u0442\u043e\u0432? \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0436\u0438\u0432\u043e\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 2 \u0433\u0440\u0443\u043f\u043f\u044b \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0443, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0414\u0436\u0438\u043d\u0438. \u041f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c (\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0441\u0442\u0435\u0439) \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e (\u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0433\u043e) \u0443\u0437\u043b\u0430. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a &#171;\u0440\u043e\u0441\u0442&#187; \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u043c \u0443\u0437\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a &#171;\u0440\u043e\u0441\u0442 \u2a7d 20 \u0441\u043c&#187;. <\/p>\n<blockquote>\n<p><em>\u0421\u0442\u043e\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0445 \u0431\u0438\u043d\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: &#171;\u0443\u0448\u0438 \u2a7d 0.5&#187;, &#171;\u0443\u0441\u044b \u2a7d 0.5&#187;. \u041a\u043e\u0433\u0434\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 2 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0438\u0434\u044b \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 label \u0438\u043b\u0438 one-hot encoding.<\/em>  <\/p>\n<\/blockquote>\n<figure class=\"full-width\"><\/figure>\n<h4>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0435\u0440\u0435\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 (CART)<\/h4>\n<p>\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:<\/p>\n<ul>\n<li>\n<p>1) \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>2) \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 2 \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0430: \u0432\u0441\u0451 \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043b\u0435\u0432\u044b\u0439 \u0443\u0437\u0435\u043b, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u2014 \u0432 \u043f\u0440\u0430\u0432\u044b\u0439;<\/p>\n<\/li>\n<li>\n<p>3) \u0434\u0430\u043b\u0435\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0448\u0430\u0433\u0438 1-2 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430: \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0433\u043b\u0443\u0431\u0438\u043d\u0430, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u0438\u0441\u0442\u044c\u0435\u0432, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u0432 \u043b\u0438\u0441\u0442\u0435 \u0438\u043b\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0435\u043d\u0438\u044f \u0432 \u0443\u0437\u043b\u0435.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u0440\u0435\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/h4>\n<p>\u0412\u044b\u0440\u0430\u0449\u0435\u043d\u043d\u0430\u044f \u0431\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u043b\u043e\u043d\u043d\u0430 \u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0438 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f 2 \u043f\u043e\u0434\u0445\u043e\u0434\u0430:\u00a0<em>pre-pruning<\/em>\u00a0(\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u043e\u0441\u0442\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u044b\u043c \u0438\u0437 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430) \u0438\u00a0<em>post-pruning<\/em>\u00a0(\u043e\u0442\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043b\u0438\u0448\u043d\u0438\u0445 \u0432\u0435\u0442\u0432\u0435\u0439 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f). \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u043b\u0438\u043a\u0430\u0442\u043d\u044b\u043c \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u0443\u044e \u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u0443\u044e \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043b\u0438\u0448\u044c \u0441\u0430\u043c\u044b\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0443\u0437\u043b\u044b.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 2 \u0442\u0438\u043f\u0430 post-puning&#8217;\u0430:<\/p>\n<ul>\n<li>\n<p><strong>Top-down pruning<\/strong>\u00a0\u2014 \u043c\u0435\u0442\u043e\u0434, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u043e\u0431\u0440\u0435\u0437\u043a\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0432\u0435\u0442\u0432\u0435\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430. \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0438\u0437\u043a\u043e\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e, \u043e\u0434\u043d\u0430\u043a\u043e, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 pre-pruning&#8217;\u043e\u043c, \u0435\u0433\u043e \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u043c \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u0434\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u0430 \u0441\u0447\u0451\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0442\u0432\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0443\u0437\u043b\u044b. \u041a \u0441\u0430\u043c\u044b\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u0432\u0438\u0434\u0430\u043c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0443\u043d\u0438\u043d\u0433\u0430 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><em>Pessimistic Error Pruning (PEP)<\/em>, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0440\u0435\u0437\u0430\u044e\u0442\u0441\u044f \u0432\u0435\u0442\u0432\u0438 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u043f\u043e\u0440\u043e\u0433 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435;<\/p>\n<\/li>\n<li>\n<p><em>Critical Value Pruning (CVP)<\/em>, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0440\u0435\u0437\u0430\u044e\u0442\u0441\u044f \u0432\u0435\u0442\u0432\u0438, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Bottom-up pruning<\/strong>\u00a0\u2014 \u043c\u0435\u0442\u043e\u0434, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u043e\u0431\u0440\u0435\u0437\u043a\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0432\u0435\u0442\u0432\u0435\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043b\u0438\u0441\u0442\u044c\u0435\u0432. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u0437\u0430 \u0441\u0447\u0451\u0442 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043e\u0431\u0445\u043e\u0434\u0430 \u0441\u043d\u0438\u0437\u0443-\u0432\u0432\u0435\u0440\u0445 \u0438 \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u0421\u0430\u043c\u044b\u043c\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u0438\u0434\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0443\u043d\u0438\u043d\u0433\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><em>Minimum Error Pruning (MEP)<\/em>, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0438\u0441\u043a \u0434\u0435\u0440\u0435\u0432\u0430 \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u043d\u0430 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435;<\/p>\n<\/li>\n<li>\n<p><em>Reduced Error Pruning (REP)<\/em>, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0443\u0437\u043b\u044b \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0430\u0434\u0430\u0435\u0442 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435;<\/p>\n<\/li>\n<li>\n<p><em>Cost-complexity pruning (CCP)<\/em>, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u0435\u0440\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0447\u0435\u0440\u0435\u0437 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u043b\u0430\u0431\u0435\u0439\u0448\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043d\u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u043a \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u043e\u0431\u0449\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u0435\u0433\u043e \u043b\u0438\u0441\u0442\u044c\u0435\u0432, \u0430 \u0432\u044b\u0431\u043e\u0440 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e k-fold \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<figure class=\"full-width\">\n<div><figcaption><strong>\u0414\u0435\u0440\u0435\u0432\u043e \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 post-pruning&#8217;\u0430<\/strong><\/figcaption><\/div>\n<\/figure>\n<h4>Minimal cost-complexity pruning<\/h4>\n<p>\u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 scikit-learn \u0434\u043b\u044f \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f cost-complexity pruning, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>1) \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0431\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>2) \u0434\u0430\u043b\u0435\u0435 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0443\u0437\u043b\u043e\u0432 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u0451\u043d\u043d\u043e\u0441\u0442\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 MSE \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>3) \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0435\u0433\u043e \u043b\u0438\u0441\u0442\u044c\u0435\u0432;<\/p>\n<\/li>\n<li>\n<p>4) \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0430\u043b\u044c\u0444\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u0430\u043a \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0435\u0433\u043e \u043b\u0438\u0441\u0442\u044c\u0435\u0432;<\/p>\n<\/li>\n<li>\n<p>5) \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e \u0441 <\/p>\n<\/li>\n<\/ul>\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-371289","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/371289","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=371289"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/371289\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=371289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=371289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=371289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}