{"id":320994,"date":"2021-04-06T15:01:48","date_gmt":"2021-04-06T15:01:48","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=320994"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=320994","title":{"rendered":"\u041e\u0442\u0431\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0427\u0430\u0441\u0442\u044c 1"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0427\u0430\u0441\u0442\u043e \u043d\u0430\u0431\u043e\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0447\u0438\u0441\u043b\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043e\u0442\u0435\u043d \u0438 \u0434\u0430\u0436\u0435 \u0442\u044b\u0441\u044f\u0447. \u041f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u0438\u0437 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043d\u0435\u0451 \u0432\u0430\u0436\u043d\u044b (\u0442.\u0435. \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u044f\u0437\u044c \u0441 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439), \u0430 \u043a\u0430\u043a\u0438\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u043c\u0438 (\u0438\u043b\u0438 \u0448\u0443\u043c\u043e\u0432\u044b\u043c\u0438). \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438, \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0435\u0451 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c. \u0418\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0438 \u0432\u043e\u0432\u0441\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0430\u043c\u043e\u0439 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b, \u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0438\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u0430\u043d\u043a\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u0441\u043a\u043e\u0440\u0438\u043d\u0433\u0430, \u043f\u043e\u0438\u0441\u043a\u0430 \u0444\u0440\u043e\u0434\u0430 \u0438\u043b\u0438 \u043c\u0435\u0434\u0438\u0446\u0438\u043d\u0441\u043a\u0438\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041c\u0435\u0442\u043e\u0434\u044b \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u0435\u043b\u044f\u0442 \u043d\u0430 3 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438: \u0444\u0438\u043b\u044c\u0442\u0440\u044b (filter methods), \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (embedded methods) \u0438 \u043e\u0431\u0451\u0440\u0442\u043a\u0438 (wrapper methods). \u0412\u044b\u0431\u043e\u0440 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0426\u0435\u043b\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 &#8212; \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u0438\u0445 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432, \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c \u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c.<\/p>\n<h3>1. \u041c\u0435\u0442\u043e\u0434\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0438\u043c\u0435\u044e\u0442 \u043d\u0438\u0437\u043a\u0443\u044e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u041a \u043d\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043e), \u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f (\u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438, \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438,&nbsp;X<sup>2 <\/sup>\u0438 \u0434\u0440.) \u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 (\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443, \u0438\u043b\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438).<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0432\u0435\u0434\u043e\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439&nbsp;<a href=\"https:\/\/newtechaudit.ru\/uskoryaem-analiz-dannyh-c-pomoshhyu-pandas-profiling\/\" rel=\"noopener noreferrer nofollow\"><u>pandas-profiling<\/u><\/a>). \u042d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438&nbsp;<a href=\"https:\/\/github.com\/WillKoehrsen\/feature-selector\" rel=\"noopener noreferrer nofollow\"><u>feature-selector<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c:<\/p>\n<ul>\n<li>\n<p>\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0433\u043e).<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 (\u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0433\u043e).<\/p>\n<\/li>\n<li>\n<p>\u0412\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c (\u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f).<\/p>\n<\/li>\n<li>\n<p>\u041e\u0446\u0435\u043d\u043a\u0430 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e lightgbm (\u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0438\u043c\u0435\u044e\u0449\u0438\u0435 \u043d\u0438\u0437\u043a\u0443\u044e \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 lightgbm. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 lightgbm \u0438\u043c\u0435\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c.)<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f&nbsp;<a href=\"https:\/\/github.com\/WillKoehrsen\/feature-selector\/blob\/master\/\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 sklearn.&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.VarianceThreshold.html#sklearn.feature_selection.VarianceThreshold\" rel=\"noopener noreferrer nofollow\"><u>VarianceThreshold<\/u><\/a>&nbsp;\u043e\u0442\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.SelectKBest.html#sklearn.feature_selection.SelectKBest\" rel=\"noopener noreferrer nofollow\"><u>SelectKBest<\/u><\/a>&nbsp;\u0438&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.SelectPercentile.html#sklearn.feature_selection.SelectPercentile\" rel=\"noopener noreferrer nofollow\"><u>SelectPercentile<\/u><\/a>&nbsp;\u043e\u0446\u0435\u043d\u0438\u0432\u0430\u044e\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u044c \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u043e\u0432 \u0441 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0442\u0435\u0441\u0442\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438 \u0434\u043e\u043b\u044e \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u0445 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f F-\u0442\u0435\u0441\u0442,&nbsp;<\/p>\n<p>&nbsp;\u0438 \u0432\u0437\u0430\u0438\u043c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f.<\/p>\n<h4>F-\u0442\u0435\u0441\u0442<\/h4>\n<p>F-\u0442\u0435\u0441\u0442 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 sklearn \u043a\u0430\u043a&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.f_regression.html#sklearn.feature_selection.f_regression\" rel=\"noopener noreferrer nofollow\"><u>f_regression<\/u><\/a>&nbsp;\u0438&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.f_classif.html#sklearn.feature_selection.f_classif\" rel=\"noopener noreferrer nofollow\"><u>f_classif<\/u><\/a>&nbsp;\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<p>&nbsp;X<sup>2<\/sup><\/p>\n<p>\u042d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0437\u0430\u0434\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e&nbsp;<a href=\"https:\/\/habr.com\/ru\/post\/264915\/\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>\u0438&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.chi2.html#sklearn.feature_selection.chi2\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>&nbsp;(\u0434\u043b\u044f sklearn). \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0442\u0438\u043f \u0442\u0435\u0441\u0442\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432.<\/p>\n<h4>\u0412\u0437\u0430\u0438\u043c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f<\/h4>\n<p>\u0412\u0437\u0430\u0438\u043c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0451\u0442\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0435\u0441\u043b\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u0430 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435&nbsp;<a href=\"https:\/\/habr.com\/ru\/post\/264915\/\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>&nbsp;\u0438&nbsp;<a href=\"http:\/\/www.machinelearning.ru\/wiki\/images\/2\/21\/PZAD2017_09_featureselection.pdf\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>). \u042d\u0442\u043e\u0442 \u0442\u0438\u043f \u0442\u0435\u0441\u0442\u043e\u0432 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 &#8212; \u043e\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187; \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 sklearn \u043a\u0430\u043a&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.mutual_info_regression.html#sklearn.feature_selection.mutual_info_regression\" rel=\"noopener noreferrer nofollow\"><u>mutual_info_regression<\/u><\/a>&nbsp;\u0438&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.mutual_info_classif.html#sklearn.feature_selection.mutual_info_classif\" rel=\"noopener noreferrer nofollow\"><u>mutual_info_classif<\/u><\/a>&nbsp;\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<h3>2. \u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/h3>\n<p>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043e\u0442\u0431\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u0438\u0445 \u043d\u0430\u0431\u043e\u0440 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u041a \u044d\u0442\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 (\u043e\u0431\u044b\u0447\u043d\u043e L1) \u0438 \u0440\u0430\u0441\u0447\u0451\u0442 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445 \u0441 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u043c\u0438 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d&nbsp;<a href=\"https:\/\/mlcourse.ai\/articles\/topic5-part3-feature-importance\/#3.-Sklearn-Random-Forest-Feature-Importance\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>). \u041e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440<\/h3>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439&nbsp;<a href=\"https:\/\/archive.ics.uci.edu\/ml\/datasets\/Adult\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0430\u0434\u0430\u0447\u0435<\/u><\/a>&nbsp;\u2013 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043b\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0431\u043e\u043b\u044c\u0448\u0435 $50 \u0442\u044b\u0441. \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>age \u2013 \u0432\u043e\u0437\u0440\u0430\u0441\u0442<\/p>\n<\/li>\n<li>\n<p>fnlwgt (final weight) \u2013 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p>educational-num \u2013 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>capital-gain \u2013 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043a\u0430\u043f\u0438\u0442\u0430\u043b\u0430<\/p>\n<\/li>\n<li>\n<p>capital-loss \u2013 \u043f\u043e\u0442\u0435\u0440\u044f \u043a\u0430\u043f\u0438\u0442\u0430\u043b\u0430<\/p>\n<\/li>\n<li>\n<p>hours-per-week \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0447\u0430\u0441\u043e\u0432 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e<\/p>\n<\/li>\n<\/ul>\n<pre><code>import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.feature_selection import GenericUnivariateSelect, mutual_info_classif, SelectFromModel from sklearn.pipeline import Pipeline from sklearn.model_selection import StratifiedKFold, GridSearchCV, cross_val_score from sklearn.ensemble import RandomForestClassifier from sklearn.preprocessing import PowerTransformer from sklearn.linear_model import LogisticRegression  # \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438  SEED = 1  # \u0424\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f def plot_features_scores(model, data, target, column_names, model_type):     '''\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432'''          model.fit(data, target)          if model_type == 'rf':         (pd.DataFrame(data={'score': model['rf'].feature_importances_},                        index=column_names).sort_values(by='score')                                          .plot(kind='barh', grid=True,                                                figsize=(6,6), legend=False));     elif model_type == 'lr':         (pd.DataFrame(data={'score': model['lr'].coef_[0]},                       index=column_names).sort_values(by='score')                                          .plot(kind='barh', grid=True,                                                figsize=(6,6), legend=False));              else:         raise KeyError('Unknown model_type')  def grid_search(model, gs_params):     '''\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u043a\u0440\u0451\u0441\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438'''           gs = GridSearchCV(estimator=model, param_grid=gs_params, refit=True,                       scoring='roc_auc', n_jobs=-1, cv=skf, verbose=0)     gs.fit(X, y)     scores = [gs.cv_results_[f'split{i}_test_score'][gs.best_index_] for i in range(5)]     print('scores = {}, \\nmean score = {:.5f} +\/- {:.5f} \\            \\nbest params = {}'.format(scores,                                       gs.cv_results_['mean_test_score'][gs.best_index_],                                       gs.cv_results_['std_test_score'][gs.best_index_],                                       gs.best_params_))     return gs          # \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435         df = pd.read_csv(r'..\\adult.data.csv')  # \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c # \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0435\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 X = df.select_dtypes(exclude=['object']).copy() # \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e y = df['salary'].map({'&lt;=50K':0, '&gt;50K':1}).values  X.head()<\/code><\/pre>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th><\/th>\n<th>\n<p><strong>age<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>fnlwgt<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>education-num<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>capital-gain<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>capital-loss<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>hours-per-week<\/strong><\/p>\n<\/th>\n<\/tr>\n<tr>\n<th>\n<p><strong>0<\/strong><\/p>\n<\/th>\n<td>\n<p>39<\/p>\n<\/td>\n<td>\n<p>77516<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>2174<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>1<\/strong><\/p>\n<\/th>\n<td>\n<p>50<\/p>\n<\/td>\n<td>\n<p>83311<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>2<\/strong><\/p>\n<\/th>\n<td>\n<p>38<\/p>\n<\/td>\n<td>\n<p>215646<\/p>\n<\/td>\n<td>\n<p>9<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>3<\/strong><\/p>\n<\/th>\n<td>\n<p>53<\/p>\n<\/td>\n<td>\n<p>234721<\/p>\n<\/td>\n<td>\n<p>7<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>4<\/strong><\/p>\n<\/th>\n<td>\n<p>28<\/p>\n<\/td>\n<td>\n<p>338409<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<pre><code>X.describe()  <\/code><\/pre>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th><\/th>\n<th>\n<p><strong>age<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>fnlwgt<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>education-num<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>capital-gain<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>capital-loss<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>hours-per-week<\/strong><\/p>\n<\/th>\n<\/tr>\n<tr>\n<th>\n<p><strong>count<\/strong><\/p>\n<\/th>\n<td>\n<p>32561.000000<\/p>\n<\/td>\n<td>\n<p>3.256100e+04<\/p>\n<\/td>\n<td>\n<p>32561.000000<\/p>\n<\/td>\n<td>\n<p>32561.000000<\/p>\n<\/td>\n<td>\n<p>32561.000000<\/p>\n<\/td>\n<td>\n<p>32561.000000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>mean<\/strong><\/p>\n<\/th>\n<td>\n<p>38.581647<\/p>\n<\/td>\n<td>\n<p>1.897784e+05<\/p>\n<\/td>\n<td>\n<p>10.080679<\/p>\n<\/td>\n<td>\n<p>1077.648844<\/p>\n<\/td>\n<td>\n<p>87.303830<\/p>\n<\/td>\n<td>\n<p>40.437456<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>std<\/strong><\/p>\n<\/th>\n<td>\n<p>13.640433<\/p>\n<\/td>\n<td>\n<p>1.055500e+05<\/p>\n<\/td>\n<td>\n<p>2.572720<\/p>\n<\/td>\n<td>\n<p>7385.292085<\/p>\n<\/td>\n<td>\n<p>402.960219<\/p>\n<\/td>\n<td>\n<p>12.347429<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>min<\/strong><\/p>\n<\/th>\n<td>\n<p>17.000000<\/p>\n<\/td>\n<td>\n<p>1.228500e+04<\/p>\n<\/td>\n<td>\n<p>1.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>1.000000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>25%<\/strong><\/p>\n<\/th>\n<td>\n<p>28.000000<\/p>\n<\/td>\n<td>\n<p>1.178270e+05<\/p>\n<\/td>\n<td>\n<p>9.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>40.000000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>50%<\/strong><\/p>\n<\/th>\n<td>\n<p>37.000000<\/p>\n<\/td>\n<td>\n<p>1.783560e+05<\/p>\n<\/td>\n<td>\n<p>10.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>40.000000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>75%<\/strong><\/p>\n<\/th>\n<td>\n<p>48.000000<\/p>\n<\/td>\n<td>\n<p>2.370510e+05<\/p>\n<\/td>\n<td>\n<p>12.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>45.000000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>max<\/strong><\/p>\n<\/th>\n<td>\n<p>90.000000<\/p>\n<\/td>\n<td>\n<p>1.484705e+06<\/p>\n<\/td>\n<td>\n<p>16.000000<\/p>\n<\/td>\n<td>\n<p>99999.000000<\/p>\n<\/td>\n<td>\n<p>4356.000000<\/p>\n<\/td>\n<td>\n<p>99.000000<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430:  <\/p>\n<pre><code>rf = Pipeline([('rf', RandomForestClassifier(n_jobs=-1,                                               class_weight='balanced',                                               random_state=SEED))])  # \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 (\u0441\u0442\u0440\u0430\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f 5-\u0444\u043e\u043b\u0434\u043e\u0432\u0430\u044f \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435\u043c)  skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=SEED)  scores = cross_val_score(estimator=rf, X=X, y=y,                           cv=skf, scoring='roc_auc', n_jobs=-1) print('scores = {} \\nmean score = {:.5f} +\/- {:.5f}'.format(scores, scores.mean(), scores.std()))  # \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 plot_features_scores(model=rf, data=X, target=y, column_names=X.columns, model_type='rf')<\/code><\/pre>\n<pre><code>scores = [0.82427915 0.82290796 0.83106668 0.8192637  0.83155106]  mean score = 0.82581 +\/- 0.00478<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/edc\/dca\/85a\/edcdca85a01e0c10b022b451f4db85e1.png\" width=\"433\" height=\"357\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0430\u043c\u044b\u043c \u0432\u0430\u0436\u043d\u044b\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f fnlwgt. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0442\u043e, \u0447\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 $50 \u0442\u044b\u0441. \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438. \u0422\u0430\u043a\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439, \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043c\u0435\u0449\u0451\u043d\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435&nbsp;<a href=\"https:\/\/explained.ai\/rf-importance\/\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>). \u041f\u0440\u0438\u0442\u043e\u043c, \u0447\u0435\u043c \u0445\u0443\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c, \u0442\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043e\u0446\u0435\u043d\u043a\u0430\u043c \u0442\u0430\u043a\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0430\u0434\u043e \u0441 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u0434\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (\u0441 L1-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439). \u0414\u043b\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.preprocessing.PowerTransformer.html#sklearn.preprocessing.PowerTransformer\" rel=\"noopener noreferrer nofollow\"><u>PowerTransformer<\/u><\/a>.<\/p>\n<pre><code>lr = Pipeline([('p_trans', PowerTransformer(method='yeo-johnson', standardize=True)),                ('lr', LogisticRegression(solver='liblinear',                                          penalty='l1',                                          max_iter=200,                                          class_weight='balanced',                                          random_state=SEED)                )]) scores = cross_val_score(estimator=lr, X=X, y=y,                           cv=skf, scoring='roc_auc', n_jobs=-1) print('scores = {} \\nmean score = {:.5f} +\/- {:.5f}'.format(scores, scores.mean(), scores.std()))  plot_features_scores(model=lr, data=X, target=y, column_names=X.columns, model_type='lr')<\/code><\/pre>\n<pre><code>scores = [0.82034993 0.83000963 0.8348707  0.81787667 0.83548066]  mean score = 0.82772 +\/- 0.00732 <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dde\/c1b\/0d9\/ddec1b0d9f2e6a8cff09d473d8eaf7e4.png\" width=\"433\" height=\"357\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c 12 \u0448\u0443\u043c\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u0432\u044b\u0431\u043e\u0440\u043e\u043a \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c, \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u043c \u0438 \u041b\u0430\u043f\u043b\u0430\u0441\u043e\u0432\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f\u043c\u0438. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430.  <\/p>\n<pre><code># \u0443\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 np.random.seed(SEED)  fix, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(14,5)) ax1.set_title(\"normal distribution\") ax2.set_title(\"uniform distribution\") ax3.set_title(\"laplace distribution\") for i in range(4):     X.loc[:, f'norm_{i}'] = np.random.normal(loc=np.random.randint(low=0, high=10),                                               scale=np.random.randint(low=1, high=10),                                               size=(X.shape[0], 1))          X.loc[:, f'unif_{i}'] = np.random.uniform(low=np.random.randint(low=1, high=4),                                                high=np.random.randint(low=5, high=10),                                                size=(X.shape[0], 1))     X.loc[:, f'lapl_{i}'] = np.random.laplace(loc=np.random.randint(low=0, high=10),                                                scale=np.random.randint(low=1, high=10),                                                size=(X.shape[0], 1))     # \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u043a\u0435\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432     sns.kdeplot(X[f'norm_{i}'], ax=ax1)     sns.kdeplot(X[f'unif_{i}'], ax=ax2)     sns.kdeplot(X[f'lapl_{i}'], ax=ax3)  # \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 X.head()<\/code><\/pre>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th><\/th>\n<th>\n<p><strong>age<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>fnlwgt<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>education-num<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>capital-gain<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>capital-loss<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>hours-per-week<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>norm_0<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>unif_0<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>lapl_0<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>norm_1<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>unif_1<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>lapl_1<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>norm_2<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>unif_2<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>lapl_2<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>norm_3<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>unif_3<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>lapl_3<\/strong><\/p>\n<\/th>\n<\/tr>\n<tr>\n<th>\n<p><strong>0<\/strong><\/p>\n<\/th>\n<td>\n<p>39<\/p>\n<\/td>\n<td>\n<p>77516<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>2174<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<td>\n<p>0.246454<\/p>\n<\/td>\n<td>\n<p>4.996750<\/p>\n<\/td>\n<td>\n<p>2.311467<\/p>\n<\/td>\n<td>\n<p>6.474587<\/p>\n<\/td>\n<td>\n<p>6.431455<\/p>\n<\/td>\n<td>\n<p>-0.932124<\/p>\n<\/td>\n<td>\n<p>3.773136<\/p>\n<\/td>\n<td>\n<p>3.382773<\/p>\n<\/td>\n<td>\n<p>-1.324387<\/p>\n<\/td>\n<td>\n<p>8.031167<\/p>\n<\/td>\n<td>\n<p>2.142457<\/p>\n<\/td>\n<td>\n<p>8.050902<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>1<\/strong><\/p>\n<\/th>\n<td>\n<p>50<\/p>\n<\/td>\n<td>\n<p>83311<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>-4.656718<\/p>\n<\/td>\n<td>\n<p>4.693542<\/p>\n<\/td>\n<td>\n<p>2.095298<\/p>\n<\/td>\n<td>\n<p>14.622329<\/p>\n<\/td>\n<td>\n<p>2.795007<\/p>\n<\/td>\n<td>\n<p>6.465348<\/p>\n<\/td>\n<td>\n<p>-3.275117<\/p>\n<\/td>\n<td>\n<p>3.787041<\/p>\n<\/td>\n<td>\n<p>0.652694<\/p>\n<\/td>\n<td>\n<p>7.537461<\/p>\n<\/td>\n<td>\n<p>5.247103<\/p>\n<\/td>\n<td>\n<p>9.014559<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>2<\/strong><\/p>\n<\/th>\n<td>\n<p>38<\/p>\n<\/td>\n<td>\n<p>215646<\/p>\n<\/td>\n<td>\n<p>9<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<td>\n<p>12.788669<\/p>\n<\/td>\n<td>\n<p>4.255611<\/p>\n<\/td>\n<td>\n<p>22.278713<\/p>\n<\/td>\n<td>\n<p>9.643720<\/p>\n<\/td>\n<td>\n<p>3.533265<\/p>\n<\/td>\n<td>\n<p>2.716441<\/p>\n<\/td>\n<td>\n<p>4.725608<\/p>\n<\/td>\n<td>\n<p>3.126107<\/p>\n<\/td>\n<td>\n<p>23.410698<\/p>\n<\/td>\n<td>\n<p>1.932907<\/p>\n<\/td>\n<td>\n<p>4.933431<\/p>\n<\/td>\n<td>\n<p>13.233319<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>3<\/strong><\/p>\n<\/th>\n<td>\n<p>53<\/p>\n<\/td>\n<td>\n<p>234721<\/p>\n<\/td>\n<td>\n<p>7<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<td>\n<p>-15.713848<\/p>\n<\/td>\n<td>\n<p>3.989797<\/p>\n<\/td>\n<td>\n<p>5.971506<\/p>\n<\/td>\n<td>\n<p>8.978198<\/p>\n<\/td>\n<td>\n<p>7.772238<\/p>\n<\/td>\n<td>\n<p>-5.402306<\/p>\n<\/td>\n<td>\n<p>5.742672<\/p>\n<\/td>\n<td>\n<p>3.084132<\/p>\n<\/td>\n<td>\n<p>0.937932<\/p>\n<\/td>\n<td>\n<p>9.435720<\/p>\n<\/td>\n<td>\n<p>4.915537<\/p>\n<\/td>\n<td>\n<p>-3.396526<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>4<\/strong><\/p>\n<\/th>\n<td>\n<p>28<\/p>\n<\/td>\n<td>\n<p>338409<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<td>\n<p>20.703306<\/p>\n<\/td>\n<td>\n<p>3.159246<\/p>\n<\/td>\n<td>\n<p>8.718559<\/p>\n<\/td>\n<td>\n<p>8.217148<\/p>\n<\/td>\n<td>\n<p>4.365603<\/p>\n<\/td>\n<td>\n<p>14.403088<\/p>\n<\/td>\n<td>\n<p>3.023828<\/p>\n<\/td>\n<td>\n<p>6.934299<\/p>\n<\/td>\n<td>\n<p>4.978327<\/p>\n<\/td>\n<td>\n<p>7.355296<\/p>\n<\/td>\n<td>\n<p>2.551361<\/p>\n<\/td>\n<td>\n<p>10.479218<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3c0\/b0f\/3d3\/3c0b0f3d3cf142291a421a52518da360.png\" width=\"841\" height=\"334\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u043e\u0432\u0435\u0434\u0451\u043c \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043d\u0430 \u0437\u0430\u0448\u0443\u043c\u043b\u0451\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432:  <\/p>\n<pre><code>scores = cross_val_score(estimator=rf, X=X, y=y,                           cv=skf, scoring='roc_auc', n_jobs=-1) print('scores = {} \\nmean score = {:.5f} +\/- {:.5f}'.format(scores, scores.mean(), scores.std())) plot_features_scores(model=rf, data=X, target=y, column_names=X.columns, model_type='rf')<\/code><\/pre>\n<pre><code>scores = [0.8522425  0.85382173 0.86249657 0.84897581 0.85443027]  mean score = 0.85439 +\/- 0.00447<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a28\/50c\/21d\/a2850c21db8c2766741c6605b9519fb0.png\" width=\"433\" height=\"357\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0448\u0443\u043c\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u0440\u043e\u0441\u043b\u0430 \u043a\u0430\u043a \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0444\u043e\u043b\u0434\u0435, \u0442\u0430\u043a \u0438 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c! \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0432\u0441\u0435 \u0448\u0443\u043c\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438\u043c\u0435\u044e\u0442 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c, \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u0443\u044e \u0441 \u0434\u0432\u0443\u043c\u044f \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u0442\u0430\u043a\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0431\u044b\u0432\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0442\u044c, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 (\u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u2013 \u0448\u0443\u043c\u043e\u0432\u044b\u0435 \u043e\u043d\u0438, \u0438\u043b\u0438 \u043d\u0435\u0442) \u043f\u0430\u0434\u0430\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0434\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0445 \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438.<\/p>\n<pre><code>scores = cross_val_score(estimator=lr, X=X, y=y,                           cv=skf, scoring='roc_auc', n_jobs=-1) print('scores = {} \\nmean score = {:.5f} +\/- {:.5f}'.format(scores, scores.mean(), scores.std()))  plot_features_scores(model=lr, data=X, target=y, column_names=X.columns, model_type='lr')<\/code><\/pre>\n<pre><code>scores = [0.81993058 0.83005516 0.83446553 0.81763029 0.83543145]  mean score = 0.82750 +\/- 0.00738<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e06\/f68\/204\/e06f6820404b940cf9e34f2bba1b32e4.png\" width=\"433\" height=\"357\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0448\u0443\u043c\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u043f\u0440\u0435\u043e\u0431\u0443\u0447\u0438\u043b\u0430\u0441\u044c, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u044d\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u043a\u0438 \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0438\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b, \u0447\u0435\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435. \u041e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0434\u0451\u043c \u043e\u0442\u0431\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442&nbsp;<code>SelectKBest<\/code>&nbsp;\u0438&nbsp;<code>SelectPercentile<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.GenericUnivariateSelect.html#sklearn.feature_selection.GenericUnivariateSelect\" rel=\"noopener noreferrer nofollow\"><u>GenericUnivariateSelect<\/u><\/a>. \u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 3 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u2013 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0446\u0435\u043d\u043a\u0438, \u0440\u0435\u0436\u0438\u043c \u043e\u0442\u0431\u043e\u0440\u0430 \u0438 \u0435\u0433\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0446\u0435\u043d\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<pre><code>selector = GenericUnivariateSelect(score_func=mutual_info_classif,                                     mode='k_best',                                     param=6) # \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0443 selector.fit(X, y) # \u043c\u0435\u0442\u043e\u0434 transform \u0432\u0435\u0440\u043d\u0451\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 # \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430  pd.DataFrame(data={'score':selector.scores_,                    'support':selector.get_support()},               index=X.columns).sort_values(by='score',ascending=False)<\/code><\/pre>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th><\/th>\n<th>\n<p><strong>score<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>support<\/strong><\/p>\n<\/th>\n<\/tr>\n<tr>\n<th>\n<p><strong>capital-gain<\/strong><\/p>\n<\/th>\n<td>\n<p>0.080221<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>age<\/strong><\/p>\n<\/th>\n<td>\n<p>0.065703<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>education-num<\/strong><\/p>\n<\/th>\n<td>\n<p>0.064743<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>hours-per-week<\/strong><\/p>\n<\/th>\n<td>\n<p>0.043655<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>capital-loss<\/strong><\/p>\n<\/th>\n<td>\n<p>0.033617<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>fnlwgt<\/strong><\/p>\n<\/th>\n<td>\n<p>0.033390<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>norm_3<\/strong><\/p>\n<\/th>\n<td>\n<p>0.003217<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>unif_3<\/strong><\/p>\n<\/th>\n<td>\n<p>0.002696<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>norm_0<\/strong><\/p>\n<\/th>\n<td>\n<p>0.002506<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>norm_2<\/strong><\/p>\n<\/th>\n<td>\n<p>0.002052<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>lapl_3<\/strong><\/p>\n<\/th>\n<td>\n<p>0.001201<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>unif_1<\/strong><\/p>\n<\/th>\n<td>\n<p>0.001144<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>lapl_1<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>unif_2<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>lapl_2<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>lapl_0<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>unif_0<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>norm_1<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438\u043c\u0435\u044e\u0442 \u043d\u0438\u0437\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0446\u0435\u043d\u043e\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (<code>scores_<\/code>), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c (<code>get_support()=False<\/code>).<\/p>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 (\u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0443\u043c\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e) \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b&nbsp;<code>GenericUnivariateSelect<\/code>&nbsp;\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u0438\u0445 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430:<\/p>\n<pre><code># \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u043a \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c\u0443 \u043b\u0435\u0441\u0443 selector = ('selector', GenericUnivariateSelect(score_func=mutual_info_classif,                                                  mode='k_best')) rf.steps.insert(0, selector)       # grid search rf_params = {'selector__param': np.arange(4,10),              'rf__max_depth': np.arange(2, 16, 2),              'rf__max_features': np.arange(0.3, 0.9, 0.2)} print('grid search results for rf') rf_grid = grid_search(model=rf, gs_params=rf_params)<\/code><\/pre>\n<pre><code>grid search results for rf scores = [0.8632776968200635, 0.8683443340928604, 0.8710308000627435, 0.8615748939138762, 0.8693334091828478],  mean score = 0.86671 +\/- 0.00364             best params = {'rf__max_depth': 12, 'rf__max_features': 0.3, 'selector__param': 5}<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430 \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0440\u043e\u0441\u043b\u0430, \u0430 \u043b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u0434\u043b\u044f 5 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432:  <\/p>\n<pre><code># \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u043e\u043c selected_features = [X.columns[i] for i, support                      in enumerate(rf_grid.best_estimator_['selector'].get_support()) if support]  plot_features_scores(model=rf_grid.best_estimator_,                       data=X, target=y, column_names=selected_features, model_type='rf')<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d17\/ba2\/545\/d17ba2545d79a24accf67f277b04992a.png\" width=\"433\" height=\"357\"><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u044b\u043b \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u043f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0448\u0443\u043c\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 fnlwgt, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u0435 \u0431\u044b\u043b \u0441\u0430\u043c\u044b\u043c \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u043c \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u0437 \u0432\u0441\u0435\u0445 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043e\u043d \u0438\u043c\u0435\u043b \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0446\u0435\u043d\u043e\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432&nbsp;<code>GenericUnivariateSelect<\/code>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0446\u0435\u043d\u043a\u0438 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0438\u0445 \u043e\u0442\u0431\u043e\u0440\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u043c\u0435\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044e \u2013 \u043d\u0430 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u043e\u043a \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0432\u043b\u0438\u044f\u044e\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u0430 \u043d\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u0430\u043c\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u0442\u0431\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u043d\u0435\u0435 \u0441\u043c\u0435\u0449\u0451\u043d\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u0440\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0435\u043d\u0442\u044b \u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0443 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438.<\/p>\n<pre><code>lr_params = {'lr__C': np.logspace(-3, 1.5, 10)}               print('grid search results for lr') lr_grid = grid_search(model=lr, gs_params=lr_params)  plot_features_scores(model=lr_grid.best_estimator_,                       data=X, target=y, column_names=X.columns, model_type='lr')<\/code><\/pre>\n<pre><code>grid search results for lr scores = [0.820445329307105, 0.829874053687009, 0.8346493482101578, 0.8177211039148669, 0.8354590546776963],  mean score = 0.82763 +\/- 0.00729             best params = {'lr__C': 0.01}<\/code><\/pre>\n<p>\u0421\u0440\u0435\u0434\u043d\u044f\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c, \u043d\u043e \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0443 \u0448\u0443\u043c\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u041e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f (L1) \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u0443\u043b\u0438\u0442\u044c \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432.<\/p>\n<p>\u041e\u0442\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0430\u0442\u044c \u043d\u0430 \u0432\u0445\u043e\u0434 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.SelectFromModel.html#sklearn.feature_selection.SelectFromModel\" rel=\"noopener noreferrer nofollow\"><u>SelectFromModel<\/u><\/a>, \u0434\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043d\u0430\u0448\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u0433\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0442\u0431\u043e\u0440\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code>lr_selector = SelectFromModel(estimator=lr_grid.best_estimator_['lr'], prefit=True, threshold=0.1)  # \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 pd.DataFrame(data={'score':lr_selector.estimator.coef_[0],                    'support':lr_selector.get_support()},               index=X.columns).sort_values(by='score',ascending=False)<\/code><\/pre>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th><\/th>\n<th>\n<p><strong>score<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>support<\/strong><\/p>\n<\/th>\n<\/tr>\n<tr>\n<th>\n<p><strong>education-num<\/strong><\/p>\n<\/th>\n<td>\n<p>0.796547<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>age<\/strong><\/p>\n<\/th>\n<td>\n<p>0.759419<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>hours-per-week<\/strong><\/p>\n<\/th>\n<td>\n<p>0.534709<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>capital-gain<\/strong><\/p>\n<\/th>\n<td>\n<p>0.435187<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>capital-loss<\/strong><\/p>\n<\/th>\n<td>\n<p>0.237207<\/p>\n<\/td>\n<td>\n<p>True<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>fnlwgt<\/strong><\/p>\n<\/th>\n<td>\n<p>0.046698<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>norm_0<\/strong><\/p>\n<\/th>\n<td>\n<p>0.010349<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>unif_0<\/strong><\/p>\n<\/th>\n<td>\n<p>0.002101<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>norm_2<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>unif_3<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>lapl_2<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>unif_2<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>norm_1<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>lapl_1<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>unif_1<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>lapl_0<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>lapl_3<\/strong><\/p>\n<\/th>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>norm_3<\/strong><\/p>\n<\/th>\n<td>\n<p>-0.018818<\/p>\n<\/td>\n<td>\n<p>False<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u041a \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u043d\u0438\u0437\u043a\u0443\u044e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 (\u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432) \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c. \u041a \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c \u2013 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u044f\u0432\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u043e\u0432. \u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442, \u0435\u0441\u043b\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043d\u043e \u043c\u0430\u043b\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0447\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043c\u0435\u0434\u0438\u0446\u0438\u043d\u0441\u043a\u0438\u0445, \u0438\u043b\u0438 \u0431\u0438\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445).<\/p>\n<p>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432, \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0434\u043d\u0430\u043a\u043e, \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u044f\u0432\u0438\u0442\u044c \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0414\u043b\u044f \u043c\u0435\u043d\u0435\u0435 \u0441\u043c\u0435\u0449\u0451\u043d\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438. \u0412\u0430\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u044d\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0443 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043b\u0438\u0431\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0445 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 sklearn \u0438\u043b\u0438&nbsp;<a href=\"https:\/\/github.com\/stmyst\/ML-notebooks\/blob\/master\/hyperopt.ipynb\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/u><\/a>.<\/p>\n<\/div>\n<p> \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\/post\/550978\/\"> https:\/\/habr.com\/ru\/post\/550978\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0427\u0430\u0441\u0442\u043e \u043d\u0430\u0431\u043e\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0447\u0438\u0441\u043b\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043e\u0442\u0435\u043d \u0438 \u0434\u0430\u0436\u0435 \u0442\u044b\u0441\u044f\u0447. \u041f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u0438\u0437 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043d\u0435\u0451 \u0432\u0430\u0436\u043d\u044b (\u0442.\u0435. \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u044f\u0437\u044c \u0441 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439), \u0430 \u043a\u0430\u043a\u0438\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u043c\u0438 (\u0438\u043b\u0438 \u0448\u0443\u043c\u043e\u0432\u044b\u043c\u0438). \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438, \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0435\u0451 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c. \u0418\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0438 \u0432\u043e\u0432\u0441\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0430\u043c\u043e\u0439 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b, \u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0438\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u0430\u043d\u043a\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u0441\u043a\u043e\u0440\u0438\u043d\u0433\u0430, \u043f\u043e\u0438\u0441\u043a\u0430 \u0444\u0440\u043e\u0434\u0430 \u0438\u043b\u0438 \u043c\u0435\u0434\u0438\u0446\u0438\u043d\u0441\u043a\u0438\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041c\u0435\u0442\u043e\u0434\u044b \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u0435\u043b\u044f\u0442 \u043d\u0430 3 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438: \u0444\u0438\u043b\u044c\u0442\u0440\u044b (filter methods), \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (embedded methods) \u0438 \u043e\u0431\u0451\u0440\u0442\u043a\u0438 (wrapper methods). \u0412\u044b\u0431\u043e\u0440 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0426\u0435\u043b\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 &#8212; \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u0438\u0445 \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432, \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c \u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c.<\/p>\n<h3>1. \u041c\u0435\u0442\u043e\u0434\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0438\u043c\u0435\u044e\u0442 \u043d\u0438\u0437\u043a\u0443\u044e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u041a \u043d\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043e), \u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f (\u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438, \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438,&nbsp;X<sup>2 <\/sup>\u0438 \u0434\u0440.) \u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 (\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443, \u0438\u043b\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438).<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0432\u0435\u0434\u043e\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439&nbsp;<a href=\"https:\/\/newtechaudit.ru\/uskoryaem-analiz-dannyh-c-pomoshhyu-pandas-profiling\/\" rel=\"noopener noreferrer nofollow\"><u>pandas-profiling<\/u><\/a>). \u042d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438&nbsp;<a href=\"https:\/\/github.com\/WillKoehrsen\/feature-selector\" rel=\"noopener noreferrer nofollow\"><u>feature-selector<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c:<\/p>\n<ul>\n<li>\n<p>\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0433\u043e).<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 (\u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0433\u043e).<\/p>\n<\/li>\n<li>\n<p>\u0412\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c (\u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f).<\/p>\n<\/li>\n<li>\n<p>\u041e\u0446\u0435\u043d\u043a\u0430 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e lightgbm (\u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0438\u043c\u0435\u044e\u0449\u0438\u0435 \u043d\u0438\u0437\u043a\u0443\u044e \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 lightgbm. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 lightgbm \u0438\u043c\u0435\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c.)<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f&nbsp;<a href=\"https:\/\/github.com\/WillKoehrsen\/feature-selector\/blob\/master\/\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 sklearn.&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.VarianceThreshold.html#sklearn.feature_selection.VarianceThreshold\" rel=\"noopener noreferrer nofollow\"><u>VarianceThreshold<\/u><\/a>&nbsp;\u043e\u0442\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.SelectKBest.html#sklearn.feature_selection.SelectKBest\" rel=\"noopener noreferrer nofollow\"><u>SelectKBest<\/u><\/a>&nbsp;\u0438&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.SelectPercentile.html#sklearn.feature_selection.SelectPercentile\" rel=\"noopener noreferrer nofollow\"><u>SelectPercentile<\/u><\/a>&nbsp;\u043e\u0446\u0435\u043d\u0438\u0432\u0430\u044e\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u044c \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u043e\u0432 \u0441 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0442\u0435\u0441\u0442\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438 \u0434\u043e\u043b\u044e \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u0445 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f F-\u0442\u0435\u0441\u0442,&nbsp;<\/p>\n<p>&nbsp;\u0438 \u0432\u0437\u0430\u0438\u043c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f.<\/p>\n<h4>F-\u0442\u0435\u0441\u0442<\/h4>\n<p>F-\u0442\u0435\u0441\u0442 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 sklearn \u043a\u0430\u043a&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.f_regression.html#sklearn.feature_selection.f_regression\" rel=\"noopener noreferrer nofollow\"><u>f_regression<\/u><\/a>&nbsp;\u0438&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.f_classif.html#sklearn.feature_selection.f_classif\" rel=\"noopener noreferrer nofollow\"><u>f_classif<\/u><\/a>&nbsp;\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<p>&nbsp;X<sup>2<\/sup><\/p>\n<p>\u042d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0437\u0430\u0434\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e&nbsp;<a href=\"https:\/\/habr.com\/ru\/post\/264915\/\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>\u0438&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.chi2.html#sklearn.feature_selection.chi2\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>&nbsp;(\u0434\u043b\u044f sklearn). \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0442\u0438\u043f \u0442\u0435\u0441\u0442\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432.<\/p>\n<h4>\u0412\u0437\u0430\u0438\u043c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f<\/h4>\n<p>\u0412\u0437\u0430\u0438\u043c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0451\u0442\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0435\u0441\u043b\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u0430 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435&nbsp;<a href=\"https:\/\/habr.com\/ru\/post\/264915\/\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>&nbsp;\u0438&nbsp;<a href=\"http:\/\/www.machinelearning.ru\/wiki\/images\/2\/21\/PZAD2017_09_featureselection.pdf\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>). \u042d\u0442\u043e\u0442 \u0442\u0438\u043f \u0442\u0435\u0441\u0442\u043e\u0432 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 &#8212; \u043e\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187; \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 sklearn \u043a\u0430\u043a&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.mutual_info_regression.html#sklearn.feature_selection.mutual_info_regression\" rel=\"noopener noreferrer nofollow\"><u>mutual_info_regression<\/u><\/a>&nbsp;\u0438&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.feature_selection.mutual_info_classif.html#sklearn.feature_selection.mutual_info_classif\" rel=\"noopener noreferrer nofollow\"><u>mutual_info_classif<\/u><\/a>&nbsp;\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<h3>2. \u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/h3>\n<p>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043e\u0442\u0431\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u0438\u0445 \u043d\u0430\u0431\u043e\u0440 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u041a \u044d\u0442\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 (\u043e\u0431\u044b\u0447\u043d\u043e L1) \u0438 \u0440\u0430\u0441\u0447\u0451\u0442 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u0445 \u0441 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u043c\u0438 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d&nbsp;<a href=\"https:\/\/mlcourse.ai\/articles\/topic5-part3-feature-importance\/#3.-Sklearn-Random-Forest-Feature-Importance\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>). \u041e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440<\/h3>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439&nbsp;<a href=\"https:\/\/archive.ics.uci.edu\/ml\/datasets\/Adult\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0430\u0434\u0430\u0447\u0435<\/u><\/a>&nbsp;\u2013 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043b\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0431\u043e\u043b\u044c\u0448\u0435 $50 \u0442\u044b\u0441. \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>age \u2013 \u0432\u043e\u0437\u0440\u0430\u0441\u0442<\/p>\n<\/li>\n<li>\n<p>fnlwgt (final weight) \u2013 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p>educational-num \u2013 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>capital-gain \u2013 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043a\u0430\u043f\u0438\u0442\u0430\u043b\u0430<\/p>\n<\/li>\n<li>\n<p>capital-loss \u2013 \u043f\u043e\u0442\u0435\u0440\u044f \u043a\u0430\u043f\u0438\u0442\u0430\u043b\u0430<\/p>\n<\/li>\n<li>\n<p>hours-per-week \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0447\u0430\u0441\u043e\u0432 \u0432 \u043d\u0435\u0434\u0435\u043b\u044e<\/p>\n<\/li>\n<\/ul>\n<pre><code>import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.feature_selection import GenericUnivariateSelect, mutual_info_classif, SelectFromModel from sklearn.pipeline import Pipeline from sklearn.model_selection import StratifiedKFold, GridSearchCV, cross_val_score from sklearn.ensemble import RandomForestClassifier from sklearn.preprocessing import PowerTransformer from sklearn.linear_model import LogisticRegression  # \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438  SEED = 1  # \u0424\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f def plot_features_scores(model, data, target, column_names, model_type):     '''\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432'''          model.fit(data, target)          if model_type == 'rf':         (pd.DataFrame(data={'score': model['rf'].feature_importances_},                        index=column_names).sort_values(by='score')                                          .plot(kind='barh', grid=True,                                                figsize=(6,6), legend=False));     elif model_type == 'lr':         (pd.DataFrame(data={'score': model['lr'].coef_[0]},                       index=column_names).sort_values(by='score')                                          .plot(kind='barh', grid=True,                                                figsize=(6,6), legend=False));              else:         raise KeyError('Unknown model_type')  def grid_search(model, gs_params):     '''\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u043a\u0440\u0451\u0441\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438'''           gs = GridSearchCV(estimator=model, param_grid=gs_params, refit=True,                       scoring='roc_auc', n_jobs=-1, cv=skf, verbose=0)     gs.fit(X, y)     scores = [gs.cv_results_[f'split{i}_test_score'][gs.best_index_] for i in range(5)]     print('scores = {}, \\nmean score = {:.5f} +\/- {:.5f} \\            \\nbest params = {}'.format(scores,                                       gs.cv_results_['mean_test_score'][gs.best_index_],                                       gs.cv_results_['std_test_score'][gs.best_index_],                                       gs.best_params_))     return gs          # \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435         df = pd.read_csv(r'..\\adult.data.csv')  # \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c # \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0435\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 X = df.select_dtypes(exclude=['object']).copy() # \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e y = df['salary'].map({'&lt;=50K':0, '&gt;50K':1}).values  X.head()<\/code><\/pre>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th><\/th>\n<th>\n<p><strong>age<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>fnlwgt<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>education-num<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>capital-gain<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>capital-loss<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>hours-per-week<\/strong><\/p>\n<\/th>\n<\/tr>\n<tr>\n<th>\n<p><strong>0<\/strong><\/p>\n<\/th>\n<td>\n<p>39<\/p>\n<\/td>\n<td>\n<p>77516<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>2174<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>1<\/strong><\/p>\n<\/th>\n<td>\n<p>50<\/p>\n<\/td>\n<td>\n<p>83311<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>2<\/strong><\/p>\n<\/th>\n<td>\n<p>38<\/p>\n<\/td>\n<td>\n<p>215646<\/p>\n<\/td>\n<td>\n<p>9<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>3<\/strong><\/p>\n<\/th>\n<td>\n<p>53<\/p>\n<\/td>\n<td>\n<p>234721<\/p>\n<\/td>\n<td>\n<p>7<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>4<\/strong><\/p>\n<\/th>\n<td>\n<p>28<\/p>\n<\/td>\n<td>\n<p>338409<\/p>\n<\/td>\n<td>\n<p>13<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>40<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<pre><code>X.describe()  <\/code><\/pre>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th><\/th>\n<th>\n<p><strong>age<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>fnlwgt<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>education-num<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>capital-gain<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>capital-loss<\/strong><\/p>\n<\/th>\n<th>\n<p><strong>hours-per-week<\/strong><\/p>\n<\/th>\n<\/tr>\n<tr>\n<th>\n<p><strong>count<\/strong><\/p>\n<\/th>\n<td>\n<p>32561.000000<\/p>\n<\/td>\n<td>\n<p>3.256100e+04<\/p>\n<\/td>\n<td>\n<p>32561.000000<\/p>\n<\/td>\n<td>\n<p>32561.000000<\/p>\n<\/td>\n<td>\n<p>32561.000000<\/p>\n<\/td>\n<td>\n<p>32561.000000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>mean<\/strong><\/p>\n<\/th>\n<td>\n<p>38.581647<\/p>\n<\/td>\n<td>\n<p>1.897784e+05<\/p>\n<\/td>\n<td>\n<p>10.080679<\/p>\n<\/td>\n<td>\n<p>1077.648844<\/p>\n<\/td>\n<td>\n<p>87.303830<\/p>\n<\/td>\n<td>\n<p>40.437456<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>std<\/strong><\/p>\n<\/th>\n<td>\n<p>13.640433<\/p>\n<\/td>\n<td>\n<p>1.055500e+05<\/p>\n<\/td>\n<td>\n<p>2.572720<\/p>\n<\/td>\n<td>\n<p>7385.292085<\/p>\n<\/td>\n<td>\n<p>402.960219<\/p>\n<\/td>\n<td>\n<p>12.347429<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>min<\/strong><\/p>\n<\/th>\n<td>\n<p>17.000000<\/p>\n<\/td>\n<td>\n<p>1.228500e+04<\/p>\n<\/td>\n<td>\n<p>1.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>1.000000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>25%<\/strong><\/p>\n<\/th>\n<td>\n<p>28.000000<\/p>\n<\/td>\n<td>\n<p>1.178270e+05<\/p>\n<\/td>\n<td>\n<p>9.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>40.000000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>50%<\/strong><\/p>\n<\/th>\n<td>\n<p>37.000000<\/p>\n<\/td>\n<td>\n<p>1.783560e+05<\/p>\n<\/td>\n<td>\n<p>10.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>40.000000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>75%<\/strong><\/p>\n<\/th>\n<td>\n<p>48.000000<\/p>\n<\/td>\n<td>\n<p>2.370510e+05<\/p>\n<\/td>\n<td>\n<p>12.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>0.000000<\/p>\n<\/td>\n<td>\n<p>45.000000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<th>\n<p><strong>max<\/strong><\/p>\n<\/th>\n<td>\n<p>90.000000<\/p>\n<\/td>\n<td>\n<p>1.484705e+06<\/p>\n<\/td>\n<td>\n<p>16.000000<\/p>\n<\/td>\n<td>\n<p>99999.000000<\/p>\n<\/td>\n<td>\n<p>4356.000000<\/p>\n<\/td>\n<td>\n<p>99.000000<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430:  <\/p>\n<pre><code>rf = Pipeline([('rf', RandomForestClassifier(n_jobs=-1,                                               class_weight='balanced',                                               random_state=SEED))])  # \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 (\u0441\u0442\u0440\u0430\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f 5-\u0444\u043e\u043b\u0434\u043e\u0432\u0430\u044f \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435\u043c)  skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=SEED)  scores = cross_val_score(estimator=rf, X=X, y=y,                           cv=skf, scoring='roc_auc', n_jobs=-1) print('scores = {} \\nmean score = {:.5f} +\/- {:.5f}'.format(scores, scores.mean(), scores.std()))  # \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 plot_features_scores(model=rf, data=X, target=y, column_names=X.columns, model_type='rf')<\/code><\/pre>\n<pre><code>scores = [0.82427915 0.82290796 0.83106668 0.8192637  0.83155106]  mean score = 0.82581 +\/- 0.00478<\/code><\/pre>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0430\u043c\u044b\u043c \u0432\u0430\u0436\u043d\u044b\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f fnlwgt. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0442\u043e, \u0447\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 $50 \u0442\u044b\u0441. \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0436\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438. \u0422\u0430\u043a\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439, \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043c\u0435\u0449\u0451\u043d\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435&nbsp;<a href=\"https:\/\/explained.ai\/rf-importance\/\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>). \u041f\u0440\u0438\u0442\u043e\u043c, \u0447\u0435\u043c \u0445\u0443\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c, \u0442\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043e\u0446\u0435\u043d\u043a\u0430\u043c \u0442\u0430\u043a\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0430\u0434\u043e \u0441 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u0434\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (\u0441 L1-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439). \u0414\u043b\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434&nbsp;<a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.preprocessing.PowerTransformer.html#sklearn.preprocessing.PowerTransformer\" rel=\"noopener noreferrer nofollow\"><u>PowerTransformer<\/u><\/a>.<\/p>\n<pre><code>lr = Pipeline([('p_trans', PowerTransformer(method='yeo-johnson', standardize=True)),                ('lr', LogisticRegression(solver='liblinear',                                          penalty='l1',                                          max_iter=200,                                          class_weight='balanced',                                          random_state=SEED)                )]) scores = cross_val_score(estimator=lr, X=X, y=y,                           cv=skf, scoring='roc_auc', n_jobs=-1) print('scores = {} \\nmean score = {:.5f} +\/- {:.5f}'.format(scores, scores.mean(), scores.std()))<\/code><\/pre>\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-320994","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320994","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=320994"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320994\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}