{"id":471435,"date":"2025-08-21T09:00:30","date_gmt":"2025-08-21T09:00:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=471435"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=471435","title":{"rendered":"<span>Shap-\u0433\u0440\u0430\u0444\u0438\u043a\u0438: \u043a\u0430\u043a \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/224\/9c5\/9c4\/2249c59c49ed11f5966e7f7fdf4e96b5.png\" width=\"1536\" height=\"1024\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/224\/9c5\/9c4\/2249c59c49ed11f5966e7f7fdf4e96b5.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/224\/9c5\/9c4\/2249c59c49ed11f5966e7f7fdf4e96b5.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u042f \u0410\u043d\u0434\u0440\u0435\u0439 \u0411\u043e\u044f\u0440\u0435\u043d\u043a\u043e\u0432, \u043b\u0438\u0434\u0435\u0440 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441\u0442\u0440\u0438\u043c\u0430 &#171;\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u041a\u0418\u0411 \u0438 \u0421\u041c\u0411&#187; \u0431\u0430\u043d\u043a\u0430 \u0412\u0422\u0411.<\/p>\n<p>\u041d\u0430\u0448 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430:<\/p>\n<p>\u00a0&#8212; \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 AutoML,<\/p>\n<p>\u00a0&#8212; \u0437\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432: \u041f\u041e\u0414\u0424\u0422 \\ Precollection \\ \u0416\u0426\u041a (\u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430),<\/p>\n<p>\u00a0&#8212; \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0445 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0431\u0430\u043d\u043a\u0430,\u00a0\u0432 \u0442.\u0447. \u0440\u0438\u0441\u043a-\u0430\u043d\u0434\u0435\u0440\u0440\u0430\u0439\u0442\u0438\u043d\u0433\u0430, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0440\u0438\u0441\u043a\u043e\u0432 \u0438 \u043a\u043e\u043c\u043f\u043b\u0430\u0435\u043d\u0441\u0430.<\/p>\n<p>\u0423\u0447\u0430\u0441\u0442\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0430\u0436\u043d\u044b\u043c. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043e\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445:<\/p>\n<p>&#8212; \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 \u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439,<\/p>\n<p>&#8212; \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u043e\u043d\u0433-\u043b\u0438\u0441\u0442\u0430 \u0444\u0438\u0447\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u0438 \u0438\u0445 \u0440\u0430\u0441\u0447\u0435\u0442\u0430,<\/p>\n<p>&#8212; \u043f\u0440\u0438\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 (\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u043c),<\/p>\n<p>&#8212; \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0435\u0439 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0442\u0438\u043f\u044b \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c,\u00a0\u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0435\u0439 \u0432 \u043c\u043e\u0434\u0435\u043b\u044f\u0445. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c, \u0447\u0442\u043e \u0446\u0435\u043b\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0435\u0439 \u043d\u0435 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f,\u00a0\u0430 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0432 \u0446\u0435\u043b\u043e\u043c.\u00a0<\/p>\n<p>\u0413\u0440\u0430\u0444\u0438\u043a\u0438 \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 telecom_churn. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0441\u0441\u044b\u043b\u043a\u0430\u043c:\u00a0<\/p>\n<p>1.\u00a0<a href=\"https:\/\/www.kaggle.com\/datasets\/keyush06\/telecom-churncsv\" rel=\"noopener noreferrer nofollow\">https:\/\/www.kaggle.com\/datasets\/keyush06\/telecom-churncsv<\/a><\/p>\n<p>2.\u00a0<a href=\"https:\/\/www.kaggle.com\/datasets\/nikkitha8\/telecom-churn\" rel=\"noopener noreferrer nofollow\">https:\/\/www.kaggle.com\/datasets\/nikkitha8\/telecom-churn<\/a><\/p>\n<p>3.\u00a0<a href=\"https:\/\/www.kaggle.com\/code\/kashnitsky\/topic-1-exploratory-data-analysis-with-pandas\" rel=\"noopener noreferrer nofollow\">https:\/\/www.kaggle.com\/code\/kashnitsky\/topic-1-exploratory-data-analysis-with-pandas<\/a><\/p>\n<p>4.\u00a0<a href=\"https:\/\/habr.com\/ru\/companies\/ods\/articles\/322626\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/companies\/ods\/articles\/322626\/<\/a><\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 telecom_churn \u0432 \u0446\u0435\u043b\u044f\u0445 \u0435\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>1. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>2. \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c data \u0441 \u0432\u044b\u0431\u043e\u0440\u043a\u043e\u0439 telecom_churn, \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 churn. \u0414\u0435\u0442\u0430\u043b\u044c\u043d\u044b\u0439 EDA (Explanatory Data Analysis) \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0442.\u043a. \u0446\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0447\u0442\u043e\u0431\u044b\u00a0\u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0435\u0439.<\/p>\n<p>3. \u0414\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0440\u044f\u0434 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u0447\u0435\u0439.<\/p>\n<p>4. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>5. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043b\u043e\u043d\u0433-\u043b\u0438\u0441\u0442 \u0444\u0438\u0447\u0435\u0439 features \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u0447\u0435\u0439 cat_feat.\u00a0<\/p>\n<p>6. \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441\u043e \u0441\u0442\u0440\u0430\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043f\u043e churn \u043d\u0430 train (75%) \u0438 test (25%) \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435.<\/p>\n<p>7. \u0412\u044b\u0431\u043e\u0440\u043a\u0443 train \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043d\u0430 train (60%) \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 val (15%) \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f \u0440\u0430\u043d\u043d\u043e\u0439 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438.<\/p>\n<p>\u041a\u043e\u0434 \u043d\u0430 Python \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441 \u0432\u044b\u0431\u043e\u0440\u043a\u043e\u0439 \u0441\u043c. \u043d\u0438\u0436\u0435:<\/p>\n<p><code><strong>import<\/strong> pandas <strong>as<\/strong> pd <strong>import<\/strong> re <strong>import<\/strong> shap <strong>import<\/strong> numpy <strong>as<\/strong> np <strong>import<\/strong> matplotlib.pyplot <strong>as<\/strong> plt <strong>import<\/strong> seaborn <strong>as<\/strong> sns <strong>from<\/strong> catboost <strong>import<\/strong> CatBoostClassifier <strong>from<\/strong> sklearn.model_selection <strong>import<\/strong> train_test_split <strong>from<\/strong> sklearn <strong>import<\/strong> preprocessing <strong>from<\/strong> sklearn.metrics <strong>import<\/strong> make_scorer, roc_auc_score <strong>from<\/strong> scipy <strong>import<\/strong> stats <strong>import<\/strong> warnings warnings<strong>.<\/strong>filterwarnings('ignore') data <strong>=<\/strong> pd<strong>.<\/strong>read_csv('telecom_churn.csv', sep<strong>=<\/strong>',') <em># \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u0430<\/em> data<strong>.<\/strong>columns <strong>=<\/strong> data<strong>.<\/strong>columns<strong>.<\/strong>str<strong>.<\/strong>replace(' ', '_') <em># \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0441\u0442\u0440\u043e\u043a<\/em> data['churn'] <strong>=<\/strong> data['churn']<strong>.<\/strong>map({<strong>True<\/strong>: 1, <strong>False<\/strong>: 0})<strong>.<\/strong>astype('int32') <em>#\u0440\u0430\u0441\u0447\u0435\u0442 \u0441\u0443\u043c\u043c\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0437\u0430 \u0432\u0441\u0435 \u0432\u0440\u0435\u043c\u044f <\/em> col_minutes <strong>=<\/strong> [x <strong>for<\/strong> x <strong>in<\/strong> data<strong>.<\/strong>columns <strong>if<\/strong> len(re<strong>.<\/strong>findall('total_\\w*_minutes', x)) <strong>!=<\/strong> 0] col_calls <strong>=<\/strong> [x <strong>for<\/strong> x <strong>in<\/strong> data<strong>.<\/strong>columns <strong>if<\/strong> len(re<strong>.<\/strong>findall('total_\\w*_calls', x)) <strong>!=<\/strong> 0] col_charge <strong>=<\/strong> [x <strong>for<\/strong> x <strong>in<\/strong> data<strong>.<\/strong>columns <strong>if<\/strong> len(re<strong>.<\/strong>findall('total_\\w*_charge', x)) <strong>!=<\/strong> 0] data['total_minutes'] <strong>=<\/strong> data[col_minutes]<strong>.<\/strong>sum(axis<strong>=<\/strong>1) data['total_calls'] <strong>=<\/strong> data[col_calls]<strong>.<\/strong>sum(axis<strong>=<\/strong>1) data['total_charge'] <strong>=<\/strong> data[col_charge]<strong>.<\/strong>sum(axis<strong>=<\/strong>1) data['charge_per_minute'] <strong>=<\/strong> data['total_charge'] <strong>\/<\/strong> data['total_minutes'] <em>#\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0439 \u043c\u0438\u043d\u0443\u0442\u044b<\/em> data['charge_per_call'] <strong>=<\/strong> data['total_charge'] <strong>\/<\/strong> data['total_calls'] <em>#\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0432\u043e\u043d\u043a\u0430<\/em> data['minutes_per_call'] <strong>=<\/strong> data['total_minutes'] <strong>\/<\/strong> data['total_calls'] <em>#\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0432\u043e\u043d\u043a\u0430<\/em> <em>#\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u0438\u0447\u0438 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043e\u0442 3 \u0434\u043e 9 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e<\/em> <strong>for<\/strong> column <strong>in<\/strong> data<strong>.<\/strong>columns:    <strong>if<\/strong> data[column]<strong>.<\/strong>nunique() <strong>&lt;<\/strong> 10 <strong>and<\/strong> data[column]<strong>.<\/strong>nunique() <strong>&gt;=<\/strong> 3:        data[column] <strong>=<\/strong> data[column]<strong>.<\/strong>astype('str')        <em>#\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u0444\u0438\u0447\u0438 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c 2 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u0438\u043f\u0430\u043c\u0438 'object' \u0438\u043b\u0438 'bool'<\/em> bool_columns <strong>=<\/strong> [] <strong>for<\/strong> column <strong>in<\/strong> data<strong>.<\/strong>dtypes[(data<strong>.<\/strong>dtypes<strong>==<\/strong>'object')<strong>|<\/strong>(data<strong>.<\/strong>dtypes<strong>==<\/strong>'bool')]<strong>.<\/strong>index:    <strong>if<\/strong> data[column]<strong>.<\/strong>nunique() <strong>==<\/strong> 2:        bool_columns<strong>.<\/strong>append(column) le <strong>=<\/strong> preprocessing<strong>.<\/strong>LabelEncoder() <strong>for<\/strong> column <strong>in<\/strong> bool_columns:    data[column] <strong>=<\/strong> le<strong>.<\/strong>fit_transform(data[column]) <em># \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0435\u0439 \u0444\u0438\u0447\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043d\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u0447\u0430\u0445<\/em> <em># \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0444\u0438\u0447\u0443 'customer_service_calls' \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u043e\u0439 (\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0432\u0435\u0434\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <\/em> <em># \u043e\u0442 'A' \u0434\u043e 'F', \u0430 \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 6 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e 'G' \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 1% \u0432\u044b\u0431\u043e\u0440\u043a\u0438<\/em> data['customer_service_calls'] <strong>=<\/strong> data['customer_service_calls']<strong>.<\/strong>replace(    {0: 'A', 1: 'B', 2: 'C', 3: 'D', 4: 'E', 5: 'F'})<strong>.<\/strong>mask(data['customer_service_calls'] <strong>&gt;=<\/strong> 6, 'G') <em># \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043b\u043e\u043d\u0433-\u043b\u0438\u0441\u0442 \u0444\u0438\u0447\u0435\u0439 features \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u0447\u0435\u0439 cat_feat (\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 phone_number \u0438 \u0442\u0430\u0440\u0433\u0435\u0442 churn)<\/em> features <strong>=<\/strong> data<strong>.<\/strong>columns<strong>.<\/strong>to_list() features  <strong>=<\/strong> [x <strong>for<\/strong> x <strong>in<\/strong> features <strong>if<\/strong> x <strong>not<\/strong> <strong>in<\/strong> ['phone_number','churn']] cat_feat <strong>=<\/strong> data<strong>.<\/strong>select_dtypes(exclude <strong>=<\/strong> [np<strong>.<\/strong>number])<strong>.<\/strong>columns<strong>.<\/strong>to_list() cat_feat  <strong>=<\/strong> [x <strong>for<\/strong> x <strong>in<\/strong> cat_feat <strong>if<\/strong> x <strong>not<\/strong> <strong>in<\/strong> ['phone_number','churn']] <em># \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441\u043e \u0441\u0442\u0440\u0430\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043f\u043e churn \u043d\u0430 \u0442\u0440\u0435\u0439\u043d(75%) \u0438 \u0442\u0435\u0441\u0442(25%) \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435:<\/em> x_train,x_test,y_train,y_test<strong>=<\/strong>train_test_split(data, data['churn'], stratify <strong>=<\/strong> data['churn'], test_size <strong>=<\/strong> 0.25, random_state<strong>=<\/strong>42) x_train,x_val,y_train,y_val<strong>=<\/strong>train_test_split(x_train, y_train, stratify <strong>=<\/strong> y_train, test_size <strong>=<\/strong> 0.20, random_state <strong>=<\/strong> 42)<\/code><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0444\u0438\u0447\u0430\u0445 \u0438\u0437 \u043b\u043e\u043d\u0433\u2013\u043b\u0438\u0441\u0442\u0430 \u043e\u0431\u0443\u0447\u0438\u043c Catboost \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u0438 c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432.\u00a0\u041d\u0430\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0431\u043e\u043b\u0435\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0444\u0438\u0447\u0435\u0439.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0414\u0436\u0438\u043d\u0438 83,08%.<\/p>\n<p>\u0417\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0446\u0435\u043d\u0438\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e get_feature_importance() \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c PredictionValueChange,\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0444\u0438\u0447\u0435\u0439.<\/p>\n<p>\u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438 \u0437\u0430\u043c\u0435\u043d\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u0447\u0438 \u043f\u043e \u0432\u044b\u0431\u043e\u0440\u043a\u0435,\u00a0\u0430 \u0434\u043b\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u2014 \u043d\u0430 \u0441\u0430\u043c\u044b\u0439 \u0447\u0430\u0441\u0442\u044b\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>\u0412\u044b\u0431\u0435\u0440\u0435\u043c \u043f\u044f\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0444\u0438\u0447. \u0418\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u043d\u0438\u0445 \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u044f\u0442\u044c\u044e \u0441\u0430\u043c\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u043c\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438\u0441\u044c: &#8216;total_charge&#8217;, &#8216;customer_service_calls&#8217;, &#8216;international_plan&#8217;, &#8216;total_intl_calls&#8217; \u0438 &#8216;number_vmail_messages&#8217;.<\/p>\n<p>\u0414\u043b\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445.\u00a0\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 describe \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041a\u043e\u0434 \u043d\u0430 Python \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u043c. \u043d\u0438\u0436\u0435:<\/p>\n<p><code><strong>def<\/strong> gini(y_true, y_pred):    gini <strong>=<\/strong> 2 <em> roc_auc_score(y_true, y_pred) <\/em><strong><em>-<\/em><\/strong><em> 1    <\/em><strong><em>return<\/em><\/strong><em> gini<\/em><br \/><em>gini_scorer <\/em><strong><em>=<\/em><\/strong><em> make_scorer(gini, greater_is_better <\/em><strong><em>=<\/em><\/strong><em> <\/em><strong><em>True<\/em><\/strong><em>)<\/em><br \/><em>params <\/em><strong><em>=<\/em><\/strong><em> {    \"verbose\": <\/em><strong><em>False<\/em><\/strong><em>,    \"eval_metric\": 'Logloss',    'iterations':  1000,    'random_state': 42,    'early_stopping_rounds': 10,    'max_depth': 4<\/em><br \/><em>}<\/em><br \/><em>model <\/em><strong><em>=<\/em><\/strong><em> CatBoostClassifier(<\/em><strong>*<\/strong>params)<br \/>model<strong>.<\/strong>fit(x_train[features], y_train, eval_set <strong>=<\/strong> (x_val[features], y_val), cat_features <strong>=<\/strong> cat_feat)<br \/>y_pred_train <strong>=<\/strong> model<strong>.<\/strong>predict_proba(x_train[features])<strong>.<\/strong>T[1]<br \/>y_pred_val <strong>=<\/strong> model<strong>.<\/strong>predict_proba(x_val[features])<strong>.<\/strong>T[1]<br \/>y_pred_test <strong>=<\/strong> model<strong>.<\/strong>predict_proba(x_test[features])<strong>.<\/strong>T[1]<br \/>gini_train <strong>=<\/strong> np<strong>.<\/strong>round(gini(y_train, y_pred_train),3)<br \/>gini_val <strong>=<\/strong> np<strong>.<\/strong>round(gini(y_val, y_pred_val),3)<br \/>gini_test <strong>=<\/strong> np<strong>.<\/strong>round(gini(y_test, y_pred_test),3)<br \/>print('\u0414\u0436\u0438\u043d\u0438 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0444\u0438\u0447\u0430\u0445:', 'train', gini_train, 'val', gini_val, 'test', gini_test)<br \/>fe_stats <strong>=<\/strong> pd<strong>.<\/strong>DataFrame({'feature_importance': model<strong>.<\/strong>get_feature_importance(),               'feature_names':features})<strong>.<\/strong>sort_values(by<strong>=<\/strong>['feature_importance'], ascending<strong>=False<\/strong>)<br \/>display(fe_stats[0:5])<br \/>features <strong>=<\/strong> fe_stats[0:5]<strong>.<\/strong>feature_names<strong>.<\/strong>to_list()<br \/>cat_feat <strong>=<\/strong> ['customer_service_calls']<\/code><\/p>\n<p><code><br \/>target <strong>=<\/strong> ['churn']<br \/>data <strong>=<\/strong> data[features <strong>+<\/strong> target]<strong>.<\/strong>copy()<br \/>data_info <strong>=<\/strong> data<strong>.<\/strong>describe(percentiles <strong>=<\/strong> [0.01, 0.05, 0.5, 0.95, 0.99],                          include<strong>=<\/strong>list(np<strong>.<\/strong>unique(data[data<strong>.<\/strong>columns]<strong>.<\/strong>dtypes<strong>.<\/strong>astype('str')<strong>.<\/strong>values)))<strong>.<\/strong>T<br \/>data_info['type'] <strong>=<\/strong> data[data<strong>.<\/strong>columns]<strong>.<\/strong>dtypes<br \/>data_info['null'] <strong>=<\/strong> data[data<strong>.<\/strong>columns]<strong>.<\/strong>isnull()<strong>.<\/strong>sum()<br \/>data_info['null%'] <strong>=<\/strong> np<strong>.<\/strong>round(data[data<strong>.<\/strong>columns]<strong>.<\/strong>isnull()<strong>.<\/strong>mean() <strong>*<\/strong> 100, 1)<br \/>data_info['nunique'] <strong>=<\/strong> data[data<strong>.<\/strong>columns]<strong>.<\/strong>nunique()<br \/>data_info['count'] <strong>=<\/strong> data_info['count']<strong>.<\/strong>astype('int')<br \/>data_info <strong>=<\/strong> data_info<strong>.<\/strong>drop('unique', axis <strong>=<\/strong> 1)<br \/>data_info<strong>.<\/strong>sort_values(by <strong>=<\/strong> ['type','nunique'], ascending <strong>=<\/strong> [<strong>False<\/strong>, <strong>False<\/strong>], inplace <strong>=<\/strong> <strong>True<\/strong>)<br \/>data_info<strong>=<\/strong>data_info<strong>.<\/strong>loc[:,['type','count','nunique','null','null%','top','freq','min','max','mean','std','1%','5%','50%','95%','99%']]<br \/>data_info[['min','max','mean','std','1%','5%','50%','95%','99%']] <strong>=<\/strong> data_info[['min','max','mean','std','1%','5%','50%','95%','99%']]<strong>.<\/strong>astype(float)<strong>.<\/strong>round(4)<br \/>display(data_info)<\/code><\/p>\n<p><u>\u0414\u0436\u0438\u043d\u0438 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0444\u0438\u0447\u0430\u0445: train 0.934 val 0.859 test 0.831<\/u><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">\n<\/td>\n<td>\n<p align=\"left\"><strong>feature_importance<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>feature_names<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>21<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">39.692171<\/p>\n<\/td>\n<td>\n<p align=\"left\">total_charge<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>18<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">17.874816<\/p>\n<\/td>\n<td>\n<p align=\"left\">customer_service_calls<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>3<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">14.006796<\/p>\n<\/td>\n<td>\n<p align=\"left\">international_plan<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>16<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">6.891904<\/p>\n<\/td>\n<td>\n<p align=\"left\">total_intl_calls<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>5<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">5.593090<\/p>\n<\/td>\n<td>\n<p align=\"left\">number_vmail_messages<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\"><strong>type<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\"><strong>count<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\"><strong>nunique<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\"><strong>null<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\"><strong>null%<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\"><strong>top<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\"><strong>freq<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\"><strong>min<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\"><strong>max<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\"><strong>mean<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\"><strong>std<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\"><strong>1%<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\"><strong>5%<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\"><strong>50%<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\"><strong>95%<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>99%<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>customer_service_calls<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">object<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">7<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">B<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">1181<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td>\n<p align=\"left\">NaN<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>total_charge<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">float64<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">2678<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">22.93<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">96.15<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">59.4498<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">10.5023<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">33.8532<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">42.338<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">59.47<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">76.516<\/p>\n<\/td>\n<td>\n<p align=\"left\">83.8396<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>number_vmail_messages<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">int64<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">46<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">51.00<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">8.0990<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">13.6884<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">0.0000<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">0.000<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">36.000<\/p>\n<\/td>\n<td>\n<p align=\"left\">43.0000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>total_intl_calls<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">int64<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">21<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">20.00<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">4.4794<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">2.4612<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">1.0000<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">1.000<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">4.00<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">9.000<\/p>\n<\/td>\n<td>\n<p align=\"left\">13.0000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>international_plan<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">int32<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">2<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">1.00<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">0.0969<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">0.2959<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">0.0000<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">0.000<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">1.000<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>churn<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">int32<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">2<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">1.00<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">0.1449<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">0.3521<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">0.0000<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">0.000<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">1.000<\/p>\n<\/td>\n<td>\n<p align=\"center\">1.0000<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u0431\u0443\u0447\u0438\u043c catboost \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u044f\u0442\u0438 \u0441\u0430\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0444\u0438\u0447\u0430\u0445.\u00a0\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0414\u0436\u0438\u043d\u0438 82,5%.<\/p>\n<p><code>params\u00a0<strong>=<\/strong>\u00a0{<\/code><\/p>\n<p><code>\u00a0 \u00a0\u00a0\"verbose\":\u00a0<strong>False<\/strong>,<\/code><\/p>\n<p><code>\u00a0 \u00a0\u00a0'eval_metric':\u00a0'Logloss',<\/code><\/p>\n<p><code>\u00a0 \u00a0\u00a0'iterations':\u00a01000,<\/code><\/p>\n<p><code>\u00a0 \u00a0\u00a0'early_stopping_rounds':\u00a010,<\/code><\/p>\n<p><code>\u00a0 \u00a0\u00a0'depth':\u00a04,\u00a0<em>#\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 6<\/em><\/code><\/p>\n<p><code>\u00a0 \u00a0\u00a0'random_state':\u00a042,<\/code><\/p>\n<p><code>}<\/code><\/p>\n<p><code>model\u00a0<strong>=<\/strong>\u00a0CatBoostClassifier(<strong>**<\/strong>params)<\/code><\/p>\n<p><code>model<strong>.<\/strong>fit(x_train[features],\u00a0y_train,\u00a0eval_set\u00a0<strong>=<\/strong>\u00a0(x_val[features],\u00a0y_val),\u00a0cat_features\u00a0<strong>=<\/strong>\u00a0cat_feat)<\/code><\/p>\n<p><code><br \/><\/code><\/p>\n<p><code>y_pred_train\u00a0<strong>=<\/strong>\u00a0model<strong>.<\/strong>predict_proba(x_train[features])<strong>.<\/strong>T[1]<\/code><\/p>\n<p><code>y_pred_val\u00a0<strong>=<\/strong>\u00a0model<strong>.<\/strong>predict_proba(x_val[features])<strong>.<\/strong>T[1]<\/code><\/p>\n<p><code>y_pred_test\u00a0<strong>=<\/strong>\u00a0model<strong>.<\/strong>predict_proba(x_test[features])<strong>.<\/strong>T[1]<\/code><\/p>\n<p><code>gini_train\u00a0<strong>=<\/strong>\u00a0np<strong>.<\/strong>round(gini(y_train,\u00a0y_pred_train),3)<\/code><\/p>\n<p><code>gini_val\u00a0<strong>=<\/strong>\u00a0np<strong>.<\/strong>round(gini(y_val,\u00a0y_pred_val),3)<\/code><\/p>\n<p><code>gini_test\u00a0<strong>=<\/strong>\u00a0np<strong>.<\/strong>round(gini(y_test,\u00a0y_pred_test),3)<\/code><\/p>\n<p><code>print('\u0414\u0436\u0438\u043d\u0438 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0444\u0438\u0447\u0430\u0445:',\u00a0'train',\u00a0gini_train,\u00a0'val',\u00a0gini_val,\u00a0'test',\u00a0gini_test)<\/code><\/p>\n<p><u>\u0414\u0436\u0438\u043d\u0438 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0444\u0438\u0447\u0430\u0445: train 0.904 val 0.865 test 0.825.<\/u><\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u0447\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 SHAP.\u00a0\u0414\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0440\u0430\u0441\u0447\u0435\u0442\u0430 Shap \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445:<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/428213\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/articles\/428213\/<\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/wunderfund\/articles\/739744\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/companies\/wunderfund\/articles\/739744\/<\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/ods\/articles\/599573\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/companies\/ods\/articles\/599573\/<\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/otus\/articles\/465329\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/companies\/otus\/articles\/465329\/<\/a><\/p>\n<p><a href=\"https:\/\/www.kaggle.com\/code\/dansbecker\/shap-values\" rel=\"noopener noreferrer nofollow\">https:\/\/www.kaggle.com\/code\/dansbecker\/shap-values<\/a><\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043f\u043e Shap:<\/p>\n<p><a href=\"https:\/\/shap.readthedocs.io\/en\/latest\/example_notebooks\/tabular_examples\/tree_based_models\/Catboost%20tutorial.html\" rel=\"noopener noreferrer nofollow\">https:\/\/shap.readthedocs.io\/en\/latest\/example_notebooks\/tabular_examples\/tree_based_models\/Catboost%20tutorial.html<\/a><\/p>\n<p>\u0421\u0443\u0442\u0435\u0432\u043e SHAP-value \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: &#171;\u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0438\u0447\u0443, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \/ \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0444\u0438\u0447\u0435\u0439&#187;.<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a Shap.summary_plot. \u041d\u0430 \u043d\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0444\u0438\u0447\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0446\u0435\u043b\u043e\u043c.<\/p>\n<p>\u041a\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<p><code>explainer = shap.TreeExplainer(model)<\/code><\/p>\n<p><code>shap_values = explainer(x_train[features].iloc[:,:])<\/code><\/p>\n<p><code>shap.summary_plot(shap_values, x_train[features], max_display = len(features))<\/code><\/p>\n<p>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0438\u0434\u0435\u0442 \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437 \u043e\u0442 \u0441\u0430\u043c\u043e\u0439 \u0432\u0430\u0436\u043d\u043e\u0439 \u0444\u0438\u0447\u0438 \u0434\u043e \u043c\u0435\u043d\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0445 \u043f\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u043c\u0443 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e Shap.values.<\/p>\n<p>\u041d\u043e \u043d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u0444\u0438\u0447\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0430:<\/p>\n<p><code>shap.plots.bar(shap_values, max_display = len(features))<\/code><\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c shap.summary_plot, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 \u043d\u0435\u0433\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Shap.values. \u041a\u043e\u0434 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p><code><em># \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f explainer<\/em><\/code><\/p>\n<p><code>explainer\u00a0<strong>=<\/strong>\u00a0shap<strong>.<\/strong>TreeExplainer(model)<\/code><\/p>\n<p><code><em># \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 SHAP \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/em><\/code><\/p>\n<p><code>shap_values\u00a0<strong>=<\/strong>\u00a0explainer(x_train[features]<strong>.<\/strong>iloc[:,:])<\/code><\/p>\n<p><code><em># \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 mean(|SHAP value|) \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430<\/em><\/code><\/p>\n<p><code>mean_abs_shap\u00a0<strong>=<\/strong>\u00a0np<strong>.<\/strong>mean(np<strong>.<\/strong>abs(shap_values<strong>.<\/strong>values),\u00a0axis<strong>=<\/strong>0)<\/code><\/p>\n<p><code><em># \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0435\u0439 \u0441 SHAP \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438<\/em><\/code><\/p>\n<p><code>feature_labels\u00a0<strong>=<\/strong>\u00a0[f\"{features[i]} ({mean_abs_shap[i]<strong>*<\/strong>100:.2f})\"\u00a0<\/code><\/p>\n<p><code>\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<strong>for<\/strong>\u00a0i\u00a0<strong>in<\/strong>\u00a0range(len(features))]<\/code><\/p>\n<p><code><em># \u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0441 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044f\u043c\u0438<\/em><\/code><\/p>\n<p><code>shap<strong>.<\/strong>summary_plot(shap_values,\u00a0x_train[features],\u00a0feature_names<strong>=<\/strong>feature_labels,\u00a0\u00a0<em># \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0438\u0447\u0435\u0439 \u043a\u0430\u043a \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/em><\/code><\/p>\n<p><code>\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 max_display<strong>=<\/strong>len(features),\u00a0show<strong>=False<\/strong>)<\/code><\/p>\n<p><code><em># \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435\u043c<\/em><\/code><\/p>\n<p><code>plt<strong>.<\/strong>title(\"SHAP Summary Plot: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 - mean(|SHAP value|)\",\u00a0y\u00a0<strong>=<\/strong>\u00a01.05)<\/code><\/p>\n<p><code>plt<strong>.<\/strong>tight_layout()<\/code><\/p>\n<p><code>plt<strong>.<\/strong>show()<\/code><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3fc\/71f\/6f6\/3fc71f6f6d1fb8306af1dfea0324b2eb.png\" width=\"793\" height=\"338\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/3fc\/71f\/6f6\/3fc71f6f6d1fb8306af1dfea0324b2eb.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3fc\/71f\/6f6\/3fc71f6f6d1fb8306af1dfea0324b2eb.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0433\u0440\u0430\u0444\u0438\u043a, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0438\u0447\u0435.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a\u0438 Shap:<\/p>\n<p>1. \u041a\u0430\u0436\u0434\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0444\u0430\u043a\u0442\u043e\u0440 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>2. \u041a\u0430\u0436\u0434\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u043a\u0442\u043e\u0440\u0430 \u2014 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0435.<\/p>\n<p>3. \u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u0441\u0438 \u0425 \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0443\u043b\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043b\u0438 \u0444\u0438\u0447\u0430 \u0438\u043b\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u00a0\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043e \u0432\u044b\u0431\u043e\u0440\u043a\u0435.<\/p>\n<p>4. \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u2014 \u0447\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u043e\u0442 \u043d\u0443\u043b\u044f, \u0442\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0431\u044b\u043b\u043e \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u0444\u0438\u0447\u0438 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0444\u0438\u0447\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Shap \u0440\u0430\u0432\u043d\u043e\u0435 +0,1%, \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u0447\u0438 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f Shap \u043d\u0430 \u044d\u0442\u0443 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443.<\/p>\n<p>5. \u0421\u043f\u0440\u0430\u0432\u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0448\u043a\u0430\u043b\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0444\u0438\u0447\u0435\u0439. \u0422\u043e\u0447\u043a\u0430 \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u0447\u0438 \u043e\u0447\u0435\u043d\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0435, \u0441\u0438\u043d\u0435\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u2014 \u043d\u0438\u0437\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u0447\u0438. \u0415\u0441\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0434\u0430\u044e\u0442 \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0438\u0447\u0438, \u0442\u043e\u00a0\u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043b\u0438\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0448\u0438\u0440\u0435 (\u0442\u043e\u0447\u043a\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f).<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044f \u043e\u0441\u044c x \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u0430 \u0432 \u043a\u0430\u043a\u0438\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u0440\u0430\u0444\u0438\u043a shap.summary_plot?<\/p>\n<p>\u0412 shap.TreeExplainer \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<p><code>feature_perturbation='tree_path_dependent', model_output = 'raw'.<\/code><\/p>\n<p>\u0414\u043b\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 Shap-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442,\u00a0\u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u043e\u0442\u043a\u043b\u043e\u043d\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0448\u0430\u043d\u0441\u043e\u0432 (log-odds).<\/p>\n<p>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (\u0441\u0440\u0435\u0434\u043d\u0435\u0435): explainer.expected_value (\u0441\u0440\u0435\u0434\u043d\u0438\u0439 log-odds \u043f\u043e \u0432\u044b\u0431\u043e\u0440\u043a\u0435).<\/p>\n<p>\u0424\u043e\u0440\u043c\u0443\u043b\u0430: <img decoding=\"async\" class=\"formula inline\" source=\"log-odds = log\u2061(p \/(p1 \u2212 p))\" alt=\"log-odds = log\u2061(p \/(p1 \u2212 p))\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/617\/9f1\/9cd\/6179f19cd047ccda656d988290e3d615.svg\" width=\"242\" height=\"22\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/617\/9f1\/9cd\/6179f19cd047ccda656d988290e3d615.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/617\/9f1\/9cd\/6179f19cd047ccda656d988290e3d615.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, \u0433\u0434\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"p\" alt=\"p\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f38\/ad7\/b0f\/f38ad7b0f3a695a1bc218e806ca83500.svg\" width=\"11\" height=\"15\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f38\/ad7\/b0f\/f38ad7b0f3a695a1bc218e806ca83500.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f38\/ad7\/b0f\/f38ad7b0f3a695a1bc218e806ca83500.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u2014 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>\u041d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a Shap.summary_plot \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044f\u0445. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u044c feature_perturbation=&#187;interventional&#187;, model_output=&#187;probability&#187;.\u00a0\u041d\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 Shap \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u043e\u0431\u0445\u043e\u0434\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0440\u0443\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 log-odds \u0432 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041a\u043e\u0434 \u0438 \u0433\u0440\u0430\u0444\u0438\u043a \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u043d\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0441\u043c. \u043d\u0438\u0436\u0435:<\/p>\n<p><code><strong>try<\/strong>:<\/code><\/p>\n<p><code>\u00a0 \u00a0\u00a0<em># \u0421\u043f\u043e\u0441\u043e\u0431 1: \u041f\u0440\u044f\u043c\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 (\u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445), \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435<\/em><\/code><\/p>\n<p><code>\u00a0 \u00a0 explainer\u00a0<strong>=<\/strong>\u00a0shap<strong>.<\/strong>TreeExplainer(model,\u00a0feature_perturbation<strong>=<\/strong>\"interventional\",\u00a0model_output<strong>=<\/strong>\"probability\")<\/code><\/p>\n<p><code>\u00a0 \u00a0 shap_values\u00a0<strong>=<\/strong>\u00a0explainer(x_train[features]<strong>.<\/strong>iloc[:,:])<\/code><\/p>\n<p><code><strong>except<\/strong>\u00a0ValueError:<\/code><\/p>\n<p><code>\u00a0 \u00a0\u00a0<em># \u0421\u043f\u043e\u0441\u043e\u0431 2: \u041e\u0431\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u0443\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0440\u0443\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/em><\/code><\/p>\n<p><code>\u00a0 \u00a0 explainer\u00a0<strong>=<\/strong>\u00a0shap<strong>.<\/strong>TreeExplainer(model)<\/code><\/p>\n<p><code>\u00a0 \u00a0 shap_values_raw\u00a0<strong>=<\/strong>\u00a0explainer(x_train[features]<strong>.<\/strong>iloc[:,:])<\/code><\/p>\n<p><code>\u00a0 \u00a0 expected_value\u00a0<strong>=<\/strong>\u00a0explainer<strong>.<\/strong>expected_value<\/code><\/p>\n<p><code>\u00a0 \u00a0 shap_values\u00a0<strong>=<\/strong>\u00a01<strong>\/<\/strong>(1<strong>+<\/strong>np<strong>.<\/strong>exp(<strong>-<\/strong>(expected_value\u00a0<strong>+<\/strong>\u00a0shap_values_raw<strong>.<\/strong>values)))\u00a0<strong>-<\/strong>\u00a01<strong>\/<\/strong>(1<strong>+<\/strong>np<strong>.<\/strong>exp(<strong>-<\/strong>expected_value))<\/code><\/p>\n<p><code>shap<strong>.<\/strong>summary_plot(shap_values,\u00a0x_train[features],\u00a0max_display\u00a0<strong>=<\/strong>\u00a0len(features))<\/code><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5fc\/57c\/652\/5fc57c65236e68f83725f330e794154a.png\" width=\"774\" height=\"340\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/5fc\/57c\/652\/5fc57c65236e68f83725f330e794154a.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5fc\/57c\/652\/5fc57c65236e68f83725f330e794154a.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u043e Shap.summary_plot \u2014 \u043e\u0447\u0435\u043d\u044c \u0432\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a, \u043d\u0430 \u043d\u0435\u043c \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u044b \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0438.\u00a0<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u043e\u0439 \u0444\u0438\u0447\u0435 total_charge \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0441 \u0440\u043e\u0441\u0442\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u0430\u0440\u0433\u0435\u0442\u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0441\u0442\u0435\u0442, \u0430 \u0432\u043e\u0442 \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043d\u0438\u0437\u043a\u0438\u0445 \u0438 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u2014\u00a0\u0438\u0437 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u043e\u0433\u0438\u0435 \u0444\u0438\u0447\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043b\u0443\u0447\u0448\u0435 \u0435\u0449\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435 shap.plots.scatter(shap_values[:,x])<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0438 \u044d\u0442\u0443 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0443\u0434\u043e\u0431\u043d\u0435\u0435\u00a0 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0430 scatter plot. \u041d\u0430 \u043d\u0435\u043c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0432\u0438\u0434\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.\u00a0<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e \u0444\u0438\u0447\u0435 total_charge \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0434\u0430\u0436\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0440\u0433\u0435\u0442\u0430, \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435, \u0430 \u0434\u0430\u043b\u0435\u0435 \u0440\u0435\u0437\u043a\u0438\u0439 \u0440\u043e\u0441\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439.\u00a0<\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435:\u00a0<\/p>\n<p>1) \u041d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0442\u0430\u0440\u0433\u0435\u0442\u0443 (\u0441\u0438\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438);<\/p>\n<p>2) \u0414\u0438\u043d\u0430\u043c\u0438\u043a\u0430 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0444\u0438\u0447\u0438;<\/p>\n<p>3) \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0444\u0438\u0447\u0438 \u043f\u043e \u0432\u044b\u0431\u043e\u0440\u043a\u0435;<\/p>\n<p>4) \u0421\u0440\u0435\u0434\u043d\u0435\u0435 \/ \u043c\u0435\u0434\u0438\u0430\u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0444\u0438\u0447\u0438.<\/p>\n<p><code><em># \u0420\u0443\u0447\u043d\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 scatter plot \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438<\/em><\/code><\/p>\n<p><code>x\u00a0<strong>=<\/strong>\u00a0'total_charge'<\/code><\/p>\n<p><code>shap_values\u00a0<strong>=<\/strong>\u00a0explainer(x_train[features]<strong>.<\/strong>iloc[:,:])<\/code><\/p>\n<p><code><em># \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435<\/em><\/code><\/p>\n<p><code>x_data\u00a0<strong>=<\/strong>\u00a0x_train[x]<\/code><\/p>\n<p><code>y_data\u00a0<strong>=<\/strong>\u00a0shap_values[:,\u00a0x]<strong>.<\/strong>values<\/code><\/p>\n<p><code>y_labels\u00a0<strong>=<\/strong>\u00a0y_train<\/code><\/p>\n<p><code><em># \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0438\u0433\u0443\u0440\u0443 \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043e\u0441\u044c<\/em><\/code><\/p>\n<p><code>fig,\u00a0ax1\u00a0<strong>=<\/strong>\u00a0plt<strong>.<\/strong>subplots(figsize<strong>=<\/strong>(11,\u00a06))<\/code><\/p>\n<p><code>fig<strong>.<\/strong>patch<strong>.<\/strong>set_facecolor('white')<\/code><\/p>\n<p><code>ax1<strong>.<\/strong>set_facecolor('white')<\/code><\/p>\n<p><code>colors\u00a0<strong>=<\/strong>\u00a0np<strong>.<\/strong>where(y_train\u00a0<strong>==<\/strong>\u00a01,\u00a0'blue',\u00a0'red')<\/code><\/p>\n<p><code>scatter\u00a0<strong>=<\/strong>\u00a0ax1<strong>.<\/strong>scatter(<\/code><\/p>\n<p><code>\u00a0 \u00a0 x<strong>=<\/strong>x_train[x],\u00a0y<strong>=<\/strong>shap_values[:,\u00a0x]<strong>.<\/strong>values,\u00a0c<strong>=<\/strong>colors,\u00a0cmap<strong>=<\/strong>'coolwarm',\u00a0alpha<strong>=<\/strong>1,\u00a0edgecolors<strong>=<\/strong>'w',\u00a0linewidths<strong>=<\/strong>0.1)<\/code><\/p>\n<p><code><em>#\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043b\u0438\u043d\u0438\u044e \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/em><\/code><\/p>\n<p><code><em># \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u043d\u0430 20 \u0431\u0438\u043d\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e<\/em><\/code><\/p>\n<p><code>bin_means,\u00a0bin_edges,\u00a0<em>\u00a0<\/em><strong><em>=<\/em><\/strong><em>\u00a0stats<\/em><strong><em>.<\/em><\/strong><em>binned<\/em>statistic(x_data,\u00a0y_data,\u00a0statistic<strong>=<\/strong>'mean',\u00a0bins<strong>=<\/strong>20)<\/code><\/p>\n<p><code>bin_centers\u00a0<strong>=<\/strong>\u00a0bin_edges[:<strong>-<\/strong>1]\u00a0<strong>+<\/strong>\u00a0np<strong>.<\/strong>diff(bin_edges)<strong>\/<\/strong>2<\/code><\/p>\n<p><code><em># \u0420\u0438\u0441\u0443\u0435\u043c \u043b\u0438\u043d\u0438\u044e \u0441\u0440\u0435\u0434\u043d\u0438\u0445<\/em><\/code><\/p>\n<p><code>ax1<strong>.<\/strong>plot(bin_centers,\u00a0bin_means,\u00a0color<strong>=<\/strong>'black',\u00a0linewidth<strong>=<\/strong>2.2,\u00a0linestyle<strong>=<\/strong>'-.',\u00a0label<strong>=<\/strong>'\u0421\u0440\u0435\u0434\u043d\u0435\u0435 SHAP')<\/code><\/p>\n<p><code><em># \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043e\u0441\u0438<\/em><\/code><\/p>\n<p><code>ax1<strong>.<\/strong>set_ylabel('SHAP value',\u00a0fontsize<strong>=<\/strong>14)<\/code><\/p>\n<p><code>ax1<strong>.<\/strong>grid(<strong>True<\/strong>,\u00a0alpha<strong>=<\/strong>0.3)<\/code><\/p>\n<p><code>ax1<strong>.<\/strong>axvline(np<strong>.<\/strong>median(x_data),\u00a0color<strong>=<\/strong>'black',\u00a0linestyle<strong>=<\/strong>'-.',\u00a0label<strong>=<\/strong>'\u041c\u0435\u0434\u0438\u0430\u043d\u0430',\u00a0linewidth<strong>=<\/strong>1)<\/code><\/p>\n<p><code><em>#\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0442\u043e\u0440\u0443\u044e \u043e\u0441\u044c \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f<\/em><\/code><\/p>\n<p><code>ax2\u00a0<strong>=<\/strong>\u00a0ax1<strong>.<\/strong>twinx()\u00a0\u00a0<em># \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0442\u043e\u0440\u0443\u044e \u043e\u0441\u044c \u0441 \u043e\u0431\u0449\u0438\u043c X<\/em><\/code><\/p>\n<p><code>ax2<strong>.<\/strong>hist(x_data,\u00a0bins<strong>=<\/strong>50,\u00a0color<strong>=<\/strong>'skyblue',\u00a0alpha<strong>=<\/strong>0.2,\u00a0density<strong>=True<\/strong>)<\/code><\/p>\n<p><code>ax2<strong>.<\/strong>set_ylabel('\u041f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f',\u00a0fontsize<strong>=<\/strong>14)<\/code><\/p>\n<p><code>ax2<strong>.<\/strong>grid(<strong>False<\/strong>)\u00a0\u00a0<em># \u041e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0439 \u043e\u0441\u0438<\/em><\/code><\/p>\n<p><code><em># \u041e\u0431\u0449\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b<\/em><\/code><\/p>\n<p><code>plt<strong>.<\/strong>title(f'SHAP \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435',\u00a0fontsize<strong>=<\/strong>14)<\/code><\/p>\n<p><u>Text(0.5, 1.0, &#8216;SHAP-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435&#8217;)<\/u><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ee8\/a0d\/731\/ee8a0d73180bf9ec0dd9e5ea53650f83.png\" width=\"992\" height=\"529\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ee8\/a0d\/731\/ee8a0d73180bf9ec0dd9e5ea53650f83.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ee8\/a0d\/731\/ee8a0d73180bf9ec0dd9e5ea53650f83.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0413\u0440\u0430\u0444\u0438\u043a\u0438 PDP (Partial Dependence Plot) \u0438 ICE (Individual Conditional Expectation) \u043c\u043e\u0433\u0443\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c Shap.Summary_plot \u0438 Scatter_plot \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u0444\u0438\u0447\u0438. PDP \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043c\u043e\u0434\u0435\u043b\u0438, \u0435\u0441\u043b\u0438 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u043e\u0439 \u0444\u0438\u0447\u0438, \u0443\u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445. ICE \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u041a\u0430\u043a \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c\u0438\u00bb. \u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u0440\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0438 PDP \u0438 ICE \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0441\u044b\u043b\u043a\u0435: <a href=\"https:\/\/scikit-learn.org\/stable\/modules\/partial_dependence.html\" rel=\"noopener noreferrer nofollow\">https:\/\/scikit-learn.org\/stable\/modules\/partial_dependence.html<\/a><\/p>\n<p>\u041c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u0440\u0430\u0441\u0447\u0435\u0442\u0430 PDP (\u0443\u0441\u0440\u0435\u0434\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u043a\u0440\u0438\u0432\u044b\u0435, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u043e\u0431\u0449\u0438\u0439 \u0442\u0440\u0435\u043d\u0434):<br \/>\u0428\u0430\u0433 1: \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438 \u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0435;<br \/>\u0428\u0430\u0433 2: \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432\u043e \u0432\u0441\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044e;<br \/>\u0428\u0430\u0433 3: \u0434\u0430\u043b\u0435\u0435 \u0443\u0441\u0440\u0435\u0434\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0446\u0435\u043d\u043e\u043a \u043f\u043e \u0432\u0441\u0435\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438;<br \/>\u0428\u0430\u0433 4: \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0441\u0442\u0440\u043e\u0438\u043c \u0433\u0440\u0430\u0444\u0438\u043a PDP.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u0440\u0430\u0441\u0447\u0435\u0442\u0430 ICE (\u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f):<br \/>\u0428\u0430\u0433 1: \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0444\u0438\u0447\u0438;<br \/>\u0428\u0430\u0433 2: \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044e;<br \/>\u0428\u0430\u0433 3: \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043a\u0440\u0438\u0432\u0443\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u2014 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0441 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u043c Shap-value \u0432 \u0440\u0430\u0437\u0440\u0435\u0437\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u043e\u0439 \u0444\u0438\u0447\u0438. PDP \u0434\u043b\u044f total_charge \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0441 \u0440\u043e\u0441\u0442\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f. \u041d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043d\u0430 ICE \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, \u0430 \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0434\u043e\u043b\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0441\u043d\u0438\u0437\u0438\u043b\u043e\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e. \u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0430 \u0441\u0447\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u0441\u043b\u043e\u0436\u0438\u043b\u0430\u0441\u044c \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0422.\u0435. \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ICE \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0430\u043d\u043e\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0435\u0437\u043a\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u043e\u0431\u0449\u0438\u0445.<br \/>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a ICE \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u0440\u0443\u0434\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c (\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043b\u0438\u043d\u0438\u0439). \u0422\u0430\u043a\u0436\u0435 ICE \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0438, \u043d\u043e \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0423 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 ICE \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<br \/>\u041f\u0440\u0438 &#8216;centered&#8217; = True \u0438\u0437 \u0432\u0441\u0435\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u0444\u0438\u0447\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u043a\u0440\u0438\u0432\u044b\u0435 \u0432 \u0442\u043e\u0447\u043a\u0435 \u0441\u0442\u0430\u0440\u0442\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 Y = 0. \u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0442.\u043a. \u0432\u0441\u0435 \u043a\u0440\u0438\u0432\u044b\u0435 \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u044b \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u0435, \u0447\u0442\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f, \u0430\u043a\u0446\u0435\u043d\u0442\u0438\u0440\u0443\u044f \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u0444\u043e\u0440\u043c\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e &#8216;centered&#8217; = False, \u043a\u0440\u0438\u0432\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439.<br \/>\u041e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043d\u0438\u0436\u0435.<\/p>\n<p><code><strong>from<\/strong> sklearn.inspection <strong>import<\/strong> PartialDependenceDisplay fig, ax <strong>=<\/strong> plt<strong>.<\/strong>subplots(figsize<strong>=<\/strong>(10, 4)) fig<strong>.<\/strong>patch<strong>.<\/strong>set_facecolor('white') ax<strong>.<\/strong>set_facecolor('white') features_info <strong>=<\/strong> {\"features\": ['total_charge'], \"kind\": \"both\", \"centered\": <strong>False<\/strong>,} common_params <strong>=<\/strong> {\"subsample\": 500, \"n_jobs\": 2, \"grid_resolution\": 30, \"random_state\": 42, 'method':'auto'} display <strong>=<\/strong> PartialDependenceDisplay<strong>.<\/strong>from_estimator(model, x_train[features]<strong>.<\/strong>iloc[:,:], <strong>features_info, ax = ax, <\/strong>common_params) <em> <\/em><strong><em>=<\/em><\/strong><em> display<\/em><strong><em>.<\/em><\/strong><em>figure<\/em><strong>.<\/strong>suptitle(\"ICE and PDP total_charge\", fontsize<strong>=<\/strong>12)<\/code><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/da1\/712\/fd7\/da1712fd73a0c75f259265a95c8629fc.png\" width=\"846\" height=\"411\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/da1\/712\/fd7\/da1712fd73a0c75f259265a95c8629fc.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/da1\/712\/fd7\/da1712fd73a0c75f259265a95c8629fc.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p><code><strong>from<\/strong> sklearn.inspection <strong>import<\/strong> PartialDependenceDisplay fig, ax <strong>=<\/strong> plt<strong>.<\/strong>subplots(figsize<strong>=<\/strong>(10, 4)) fig<strong>.<\/strong>patch<strong>.<\/strong>set_facecolor('white') ax<strong>.<\/strong>set_facecolor('white') features_info <strong>=<\/strong> {\"features\": ['total_charge'], \"kind\": \"both\", \"centered\": <strong>True<\/strong>,} common_params <strong>=<\/strong> {\"subsample\": 500, \"n_jobs\": 2, \"grid_resolution\": 30, \"random_state\": 42, 'method':'auto'} display <strong>=<\/strong> PartialDependenceDisplay<strong>.<\/strong>from_estimator(model, x_train[features]<strong>.<\/strong>iloc[:,:], <strong>features_info, ax = ax, <\/strong>common_params) <em> <\/em><strong><em>=<\/em><\/strong><em> display<\/em><strong><em>.<\/em><\/strong><em>figure<\/em><strong>.<\/strong>suptitle(\"ICE and PDP total_charge (centered)\", fontsize<strong>=<\/strong>12)<\/code><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a05\/9ee\/d3c\/a059eed3c0bfe3a06586e71228d4bf58.png\" width=\"866\" height=\"411\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/a05\/9ee\/d3c\/a059eed3c0bfe3a06586e71228d4bf58.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a05\/9ee\/d3c\/a059eed3c0bfe3a06586e71228d4bf58.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0413\u0440\u0430\u0444\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438, \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043f\u043e\u0434 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438, \u043d\u043e \u043c\u0430\u043b\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u043f\u043e\u0434 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435.<br \/>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u043d\u0430 Shap.summary_plot, \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0438\u0447\u0438 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0435\u043d\u044b, \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0431\u044b\u043b\u043e \u0441\u043b\u043e\u0436\u043d\u043e.<br \/>\u0413\u0440\u0430\u0444\u0438\u043a plotbar \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0435\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043b\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u0447\u0435\u0439.<br \/>\u0413\u0440\u0430\u0444\u0438\u043a plt.boxplot (\u044f\u0449\u0438\u043a \u0441 \u0443\u0441\u0430\u043c\u0438) \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430 \u043d\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f:<br \/><strong>1. \u042f\u0449\u0438\u043a (Box)<\/strong><br \/>\u0413\u0440\u0430\u043d\u0438\u0446\u044b \u044f\u0449\u0438\u043a\u0430: \u041d\u0438\u0436\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 (Q1) \u2014 \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0432\u0430\u0440\u0442\u0438\u043b\u044c (25-\u0439 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0438\u043b\u044c), \u0412\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 (Q3) \u2014 \u0442\u0440\u0435\u0442\u0438\u0439 \u043a\u0432\u0430\u0440\u0442\u0438\u043b\u044c (75-\u0439 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0438\u043b\u044c).<br \/>\u041b\u0438\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u044f\u0449\u0438\u043a\u0430 (\u043e\u0440\u0430\u043d\u0436\u0435\u0432\u0430\u044f \u043b\u0438\u043d\u0438\u044f): \u041c\u0435\u0434\u0438\u0430\u043d\u0430 (Q2, 50-\u0439 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0438\u043b\u044c).<br \/>\u0428\u0438\u0440\u0438\u043d\u0430 \u044f\u0449\u0438\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0436\u043a\u0432\u0430\u0440\u0442\u0438\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0430\u0445 (Interquartile range) (IQR  = Q3 \u2013 Q1) \u2014 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d, \u0433\u0434\u0435 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0435\u043d\u043e 50% \u0434\u0430\u043d\u043d\u044b\u0445.<br \/><strong>2. \u0423\u0441\u044b (Whiskers)<\/strong><br \/>\u0412\u0435\u0440\u0445\u043d\u0438\u0439 \u0443\u0441:  Q3 + 1.5 <em> IQR (\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044f \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432). \u041d\u0438\u0436\u043d\u0438\u0439 \u0443\u0441: \u041e\u0431\u044b\u0447\u043d\u043e Q1 \u2013 1.5 <\/em> IQR (\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044f \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432). \u0423\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043e 95% \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0438\u043b\u0435\u0439). \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u044f\u0449\u0438\u043a \u043b\u0438\u043d\u0438\u044e \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442\u0438\u0440) \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0449\u0443\u044e \u043b\u0438\u043d\u0438\u044e (\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442\u0438\u0440), \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u044f\u0449\u0438\u043a\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443. \u041d\u0438\u0436\u0435 \u043f\u043e\u0434 \u0433\u0440\u0430\u0444\u0438\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u044f\u0449\u0438\u043a\u0435.<\/p>\n<p><code>x <strong>=<\/strong> 'customer_service_calls' values <strong>=<\/strong> shap_values[:,features<strong>.<\/strong>index(x)] data <strong>=<\/strong> x_train[x] categories <strong>=<\/strong> sorted(list(set(x_train[x]))) groups <strong>=<\/strong> [] means <strong>=<\/strong> [] <strong>for<\/strong> category <strong>in<\/strong> categories:    relevant_values <strong>=<\/strong> values<strong>.<\/strong>values[values<strong>.<\/strong>data <strong>==<\/strong> category]    groups<strong>.<\/strong>append(relevant_values)    means<strong>.<\/strong>append(np<strong>.<\/strong>mean(relevant_values)) labels <strong>=<\/strong> [u <strong>for<\/strong> u <strong>in<\/strong> categories]    <em># \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0435\u0442\u043a\u0443 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432: \u0432\u0435\u0440\u0445 \u2014 boxplot, \u043d\u0438\u0437 \u2014 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430<\/em> fig, (ax_box, ax_hist) <strong>=<\/strong> plt<strong>.<\/strong>subplots(nrows<strong>=<\/strong>2, sharex<strong>=True<\/strong>, gridspec_kw<strong>=<\/strong>{\"height_ratios\": (0.6, 0.4)}, figsize<strong>=<\/strong>(8, 6))    <em>#plt.figure(figsize=(8, 5))<\/em> ax_box<strong>.<\/strong>boxplot(groups, labels <strong>=<\/strong> labels, showmeans<strong>=True<\/strong>, meanline<strong>=True<\/strong>) ax_box<strong>.<\/strong>set_ylabel('Shap values', size<strong>=<\/strong>15) ax_box<strong>.<\/strong>set_xlabel(x, size<strong>=<\/strong>15) <em># \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043b\u0438\u043d\u0438\u0438, \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0438\u0435<\/em> ax_box<strong>.<\/strong>plot(range(1, len(categories) <strong>+<\/strong> 1), means, marker<strong>=<\/strong>'.', color<strong>=<\/strong>'red', linestyle<strong>=<\/strong>'--', linewidth<strong>=<\/strong>1, label<strong>=<\/strong>'\u0421\u0440\u0435\u0434\u043d\u0438\u0435') ax_box<strong>.<\/strong>grid(<strong>True<\/strong>, linestyle<strong>=<\/strong>'--', alpha<strong>=<\/strong>0.5)    <em># \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/em> <strong>for<\/strong> i, category <strong>in<\/strong> enumerate(categories):    ax_hist<strong>.<\/strong>text(i<strong>+<\/strong>1, plt<strong>.<\/strong>ylim()[0], f\"n={len(groups[i])}\", ha<strong>=<\/strong>\"center\", va<strong>=<\/strong>'bottom')           <em># \u0413\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u043d\u0430 \u043d\u0438\u0436\u043d\u0435\u0439 \u043f\u0430\u043d\u0435\u043b\u0438<\/em> counts <strong>=<\/strong> [len(x) <strong>for<\/strong> x <strong>in<\/strong> groups] ax_hist<strong>.<\/strong>bar(range(1, len(categories)<strong>+<\/strong>1), counts, color<strong>=<\/strong>\"skyblue\", edgecolor<strong>=<\/strong>\"black\") ax_hist<strong>.<\/strong>set_ylabel(\"\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\") plt<strong>.<\/strong>tight_layout() plt<strong>.<\/strong>show()<\/code><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6ee\/1d3\/e5c\/6ee1d3e5c39c0f5d33e4b5ce6ec7a230.png\" width=\"790\" height=\"590\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/6ee\/1d3\/e5c\/6ee1d3e5c39c0f5d33e4b5ce6ec7a230.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6ee\/1d3\/e5c\/6ee1d3e5c39c0f5d33e4b5ce6ec7a230.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u0438 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0444\u0438\u0447\u0438 \u0438 shap-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u041a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 shap \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0435\u0439 \u0441 \u0438\u0445 \u0432\u043a\u043b\u0430\u0434\u043e\u043c \u0432 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u0438 \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u0447\u0438, \u0442\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043e\u043d \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435. \u041f\u0440\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u0447\u0438, \u0442\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043e\u043d \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f \u043e\u043a\u043e\u043b\u043e\u043d\u0443\u043b\u0435\u0432\u0430\u044f, \u0442\u043e \u043d\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0444\u0438\u0447\u0438 \u0438 \u0435\u0433\u043e \u0432\u043b\u0438\u044f\u043d\u0438\u0435\u043c. \u041d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u043d\u0438\u0437\u043a\u0438\u0435 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, U-\u043e\u0431\u0440\u0430\u0437\u043d\u0430\u044f \u043a\u0440\u0438\u0432\u0430\u044f) \u0438\u043b\u0438 \u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u0445 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0444\u0438\u0447\u0430\u043c\u0438. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u0435\u0439\u0441\u0435. \u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u043e \u0444\u0438\u0447\u0435 total_charge \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f, \u0447\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0444\u0438\u0447\u0438, \u0430 \u043f\u043e \u0444\u0438\u0447\u0435 total_intl_calls \u2014\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u043d\u0438\u0437\u043a\u0430\u044f. <\/p>\n<p><code><em># \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0439<\/em> features<strong>.<\/strong>remove('customer_service_calls') correlations <strong>=<\/strong> {} <strong>for<\/strong> i, feat <strong>in<\/strong> enumerate(features):    correlations[feat] <strong>=<\/strong> np<strong>.<\/strong>corrcoef(x_train[feat], shap_values<strong>.<\/strong>values[:,i])[0,1] <em># \u0413\u0440\u0430\u0444\u0438\u043a<\/em> plt<strong>.<\/strong>figure(figsize<strong>=<\/strong>(8, 2)) sns<strong>.<\/strong>barplot(x <strong>=<\/strong> list(correlations<strong>.<\/strong>values()), y <strong>=<\/strong> list(correlations<strong>.<\/strong>keys()), palette <strong>=<\/strong> \"vlag\") plt<strong>.<\/strong>axvline(0, color <strong>=<\/strong> 'black', linestyle <strong>=<\/strong> '--') plt<strong>.<\/strong>title('\u041a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0444\u0438\u0447\u0438 \u0441 Shap') plt<strong>.<\/strong>xlabel('\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u041f\u0438\u0440\u0441\u043e\u043d\u0430') plt<strong>.<\/strong>xlim(<strong>-<\/strong>1, 1) plt<strong>.<\/strong>show() features <strong>=<\/strong> fe_stats[0:5]<strong>.<\/strong>feature_names<strong>.<\/strong>to_list()<\/code><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b1c\/fa4\/818\/b1cfa481871a667e5bb5a638508e4109.png\" width=\"840\" height=\"239\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b1c\/fa4\/818\/b1cfa481871a667e5bb5a638508e4109.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b1c\/fa4\/818\/b1cfa481871a667e5bb5a638508e4109.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p> \u0427\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 total_intl_calls \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0444\u0438\u0447\u0430\u043c\u0438, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043d\u0435\u0435 \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 Shap.dependence_plot(). \u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f total_intl_calls \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0435\u0439 \u043d\u0430\u0441 \u0444\u0438\u0447\u0435\u0439 \u043f\u0440\u044f\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0432 \u0435\u0435 \u0432 interaction_index. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u0443\u044e \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0442\u043e shap.dependence_plot \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u0434\u043b\u044f \u0440\u0430\u0441\u043a\u0440\u0430\u0441\u043a\u0438 \u0442\u043e\u0447\u0435\u043a \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0444\u0438\u0447\u0443 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c. \u0427\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 Shap-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0438\u0447\u0438 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u0438\u0447\u0438, \u0442\u0435\u043c \u0432\u044b\u0448\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0424\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e Shap-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043e\u0434\u043d\u043e\u0439 \u0444\u0438\u0447\u0438, \u043e\u0431\u044a\u044f\u0441\u043d\u0451\u043d\u043d\u044b\u0445 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u0438\u0447\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438 \u0432\u044b\u0441\u043e\u043a\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 international_plan Shap-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f total_intl_calls \u0440\u0435\u0437\u043a\u043e \u0432\u044b\u0440\u0430\u0441\u0442\u0443\u0442, \u0430 \u043f\u0440\u0438 \u043d\u0438\u0437\u043a\u043e\u043c \u0441\u043d\u0438\u0437\u044f\u0442\u0441\u044f,<br \/> \u0442\u043e international_plan \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043a\u0440\u0430\u0441\u043a\u0438 \u0442\u043e\u0447\u0435\u043a (\u0441\u043c. \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435).<\/p>\n<p><code># \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0438\u0447\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u0438\u0447\u0430 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c - international_plan<\/code><br \/><code>shap.dependence_plot('total_intl_calls', shap_values.values, x_train[features].iloc[:,:])<\/code><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8ff\/c9f\/3a3\/8ffc9f3a3257bbfab98bb0ba9c8955ed.png\" width=\"662\" height=\"459\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/8ff\/c9f\/3a3\/8ffc9f3a3257bbfab98bb0ba9c8955ed.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8ff\/c9f\/3a3\/8ffc9f3a3257bbfab98bb0ba9c8955ed.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p><code># \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0438\u0447\u0443 \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 - 'number_vmail_messages'<\/code><br \/>shap.dependence_plot(&#8216;total_intl_calls&#8217;, shap_values.values, x_train[features].iloc[:,:], interaction_index = &#8216;number_vmail_messages&#8217;)<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/14e\/d32\/e75\/14ed32e75f0e40bdd5b21175de6e5bc9.png\" width=\"663\" height=\"453\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/14e\/d32\/e75\/14ed32e75f0e40bdd5b21175de6e5bc9.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/14e\/d32\/e75\/14ed32e75f0e40bdd5b21175de6e5bc9.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p> Shap.dependence_plot \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0432\u0435\u0434\u0438\u0442\u044c \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 international_plan \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0437\u0432\u043e\u043d\u043a\u043e\u0432 total_intl_calls. \u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e Shap.dependence_plot \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: <a href=\"https:\/\/shap.readthedocs.io\/en\/latest\/example_notebooks\/tabular_examples\/tree_based_models\/NHANES\" rel=\"noopener noreferrer nofollow\">https:\/\/shap.readthedocs.io\/en\/latest\/example_notebooks\/tabular_examples\/tree_based_models\/NHANES<\/a><a href=\"https:\/\/shap.readthedocs.io\/en\/latest\/example_notebooks\/tabular_examples\/tree_based_models\/NHANES%20I%20Survival%20Model.html\" rel=\"noopener noreferrer nofollow\"> I Survival Model.html<\/a><\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0434\u043b\u044f \u0432\u0430\u0441.<br \/> \u041a\u0430\u043a\u0438\u0435 \u0435\u0449\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0435\u0441\u0442\u044c \u0443 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0431\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0434\u043b\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439, \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/938988\/\"> https:\/\/habr.com\/ru\/articles\/938988\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u042f \u0410\u043d\u0434\u0440\u0435\u0439 \u0411\u043e\u044f\u0440\u0435\u043d\u043a\u043e\u0432, \u043b\u0438\u0434\u0435\u0440 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441\u0442\u0440\u0438\u043c\u0430 &#171;\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u041a\u0418\u0411 \u0438 \u0421\u041c\u0411&#187; \u0431\u0430\u043d\u043a\u0430 \u0412\u0422\u0411.<\/p>\n<p>\u041d\u0430\u0448 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430:<\/p>\n<p>\u00a0&#8212; \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 AutoML,<\/p>\n<p>\u00a0&#8212; \u0437\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432: \u041f\u041e\u0414\u0424\u0422 \\ Precollection \\ \u0416\u0426\u041a (\u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430),<\/p>\n<p>\u00a0&#8212; \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0445 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0431\u0430\u043d\u043a\u0430,\u00a0\u0432 \u0442.\u0447. \u0440\u0438\u0441\u043a-\u0430\u043d\u0434\u0435\u0440\u0440\u0430\u0439\u0442\u0438\u043d\u0433\u0430, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0440\u0438\u0441\u043a\u043e\u0432 \u0438 \u043a\u043e\u043c\u043f\u043b\u0430\u0435\u043d\u0441\u0430.<\/p>\n<p>\u0423\u0447\u0430\u0441\u0442\u0438\u0435 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0430\u0436\u043d\u044b\u043c. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043e\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445:<\/p>\n<p>&#8212; \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 \u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439,<\/p>\n<p>&#8212; \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u043e\u043d\u0433-\u043b\u0438\u0441\u0442\u0430 \u0444\u0438\u0447\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u0438 \u0438\u0445 \u0440\u0430\u0441\u0447\u0435\u0442\u0430,<\/p>\n<p>&#8212; \u043f\u0440\u0438\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 (\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u043c),<\/p>\n<p>&#8212; \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0435\u0439 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0442\u0438\u043f\u044b \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c,\u00a0\u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0435\u0439 \u0432 \u043c\u043e\u0434\u0435\u043b\u044f\u0445. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c, \u0447\u0442\u043e \u0446\u0435\u043b\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0435\u0439 \u043d\u0435 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f,\u00a0\u0430 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0432 \u0446\u0435\u043b\u043e\u043c.\u00a0<\/p>\n<p>\u0413\u0440\u0430\u0444\u0438\u043a\u0438 \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 telecom_churn. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0441\u0441\u044b\u043b\u043a\u0430\u043c:\u00a0<\/p>\n<p>1.\u00a0<a href=\"https:\/\/www.kaggle.com\/datasets\/keyush06\/telecom-churncsv\" rel=\"noopener noreferrer nofollow\">https:\/\/www.kaggle.com\/datasets\/keyush06\/telecom-churncsv<\/a><\/p>\n<p>2.\u00a0<a href=\"https:\/\/www.kaggle.com\/datasets\/nikkitha8\/telecom-churn\" rel=\"noopener noreferrer nofollow\">https:\/\/www.kaggle.com\/datasets\/nikkitha8\/telecom-churn<\/a><\/p>\n<p>3.\u00a0<a href=\"https:\/\/www.kaggle.com\/code\/kashnitsky\/topic-1-exploratory-data-analysis-with-pandas\" rel=\"noopener noreferrer nofollow\">https:\/\/www.kaggle.com\/code\/kashnitsky\/topic-1-exploratory-data-analysis-with-pandas<\/a><\/p>\n<p>4.\u00a0<a href=\"https:\/\/habr.com\/ru\/companies\/ods\/articles\/322626\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/companies\/ods\/articles\/322626\/<\/a><\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 telecom_churn \u0432 \u0446\u0435\u043b\u044f\u0445 \u0435\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>1. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>2. \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c data \u0441 \u0432\u044b\u0431\u043e\u0440\u043a\u043e\u0439 telecom_churn, \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 churn. \u0414\u0435\u0442\u0430\u043b\u044c\u043d\u044b\u0439 EDA (Explanatory Data Analysis) \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0442.\u043a. \u0446\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0447\u0442\u043e\u0431\u044b\u00a0\u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0447\u0435\u0439.<\/p>\n<p>3. \u0414\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0440\u044f\u0434 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u0447\u0435\u0439.<\/p>\n<p>4. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>5. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043b\u043e\u043d\u0433-\u043b\u0438\u0441\u0442 \u0444\u0438\u0447\u0435\u0439 features \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u0447\u0435\u0439 cat_feat.\u00a0<\/p>\n<p>6. \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441\u043e \u0441\u0442\u0440\u0430\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043f\u043e churn \u043d\u0430 train (75%) \u0438 test (25%) \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435.<\/p>\n<p>7. \u0412\u044b\u0431\u043e\u0440\u043a\u0443 train \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043d\u0430 train (60%) \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 val (15%) \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f \u0440\u0430\u043d\u043d\u043e\u0439 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438.<\/p>\n<p>\u041a\u043e\u0434 \u043d\u0430 Python \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441 \u0432\u044b\u0431\u043e\u0440\u043a\u043e\u0439 \u0441\u043c. \u043d\u0438\u0436\u0435:<\/p>\n<p><code><strong>import<\/strong> pandas <strong>as<\/strong> pd <strong>import<\/strong> re <strong>import<\/strong> shap <strong>import<\/strong> numpy <strong>as<\/strong> np <strong>import<\/strong> matplotlib.pyplot <strong>as<\/strong> plt <strong>import<\/strong> seaborn <strong>as<\/strong> sns <strong>from<\/strong> catboost <strong>import<\/strong> CatBoostClassifier <strong>from<\/strong> sklearn.model_selection <strong>import<\/strong> train_test_split <strong>from<\/strong> sklearn <strong>import<\/strong> preprocessing <strong>from<\/strong> sklearn.metrics <strong>import<\/strong> make_scorer, roc_auc_score <strong>from<\/strong> scipy <strong>import<\/strong> stats <strong>import<\/strong> warnings warnings<strong>.<\/strong>filterwarnings('ignore') data <strong>=<\/strong> pd<strong>.<\/strong>read_csv('telecom_churn.csv', sep<strong>=<\/strong>',') <em># \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u0430<\/em> data<strong>.<\/strong>columns <strong>=<\/strong> data<strong>.<\/strong>columns<strong>.<\/strong>str<strong>.<\/strong>replace(' ', '_') <em># \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0441\u0442\u0440\u043e\u043a<\/em> data['churn'] <strong>=<\/strong> data['churn']<strong>.<\/strong>map({<strong>True<\/strong>: 1, <strong>False<\/strong>: 0})<strong>.<\/strong>astype('int32') <em>#\u0440\u0430\u0441\u0447\u0435\u0442 \u0441\u0443\u043c\u043c\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0437\u0430 \u0432\u0441\u0435 \u0432\u0440\u0435\u043c\u044f <\/em> col_minutes <strong>=<\/strong> [x <strong>for<\/strong> x <strong>in<\/strong> data<strong>.<\/strong>columns <strong>if<\/strong> len(re<strong>.<\/strong>findall('total_\\w*_minutes', x)) <strong>!=<\/strong> 0] col_calls <strong>=<\/strong> [x <strong>for<\/strong> x <strong>in<\/strong> data<strong>.<\/strong>columns <strong>if<\/strong> len(re<strong>.<\/strong>findall('total_\\w*_calls', x)) <strong>!=<\/strong> 0] col_charge <strong>=<\/strong> [x <strong>for<\/strong> x <strong>in<\/strong> data<strong>.<\/strong>columns <strong>if<\/strong> len(re<strong>.<\/strong>findall('total_\\w*_charge', x)) <strong>!=<\/strong> 0] data['total_minutes'] <strong>=<\/strong> data[col_minutes]<strong>.<\/strong>sum(axis<strong>=<\/strong>1) data['total_calls'] <strong>=<\/strong> data[col_calls]<strong>.<\/strong>sum(axis<strong>=<\/strong>1) data['total_charge'] <strong>=<\/strong> data[col_charge]<strong>.<\/strong>sum(axis<strong>=<\/strong>1) data['charge_per_minute'] <strong>=<\/strong> data['total_charge'] <strong>\/<\/strong> data['total_minutes'] <em>#\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0439 \u043c\u0438\u043d\u0443\u0442\u044b<\/em> data['charge_per_call'] <strong>=<\/strong> data['total_charge'] <strong>\/<\/strong> data['total_calls'] <em>#\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0432\u043e\u043d\u043a\u0430<\/em> data['minutes_per_call'] <strong>=<\/strong> data['total_minutes'] <strong>\/<\/strong> data['total_calls'] <em>#\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0432\u043e\u043d\u043a\u0430<\/em> <em>#\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u0438\u0447\u0438 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043e\u0442 3 \u0434\u043e 9 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e<\/em> <strong>for<\/strong> column <strong>in<\/strong> data<strong>.<\/strong>columns:    <strong>if<\/strong> data[column]<strong>.<\/strong>nunique() <strong>&lt;<\/strong> 10 <strong>and<\/strong> data[column]<strong>.<\/strong>nunique() <strong>&gt;=<\/strong> 3:        data[column] <strong>=<\/strong> data[column]<strong>.<\/strong>astype('str')        <em>#\u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u0444\u0438\u0447\u0438 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c 2 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u0438\u043f\u0430\u043c\u0438 'object' \u0438\u043b\u0438 'bool'<\/em> bool_columns <strong>=<\/strong> [] <strong>for<\/strong> column <strong>in<\/strong> data<strong>.<\/strong>dtypes[(data<strong>.<\/strong>dtypes<strong>==<\/strong>'object')<strong>|<\/strong>(data<strong>.<\/strong>dtypes<strong>==<\/strong>'bool')]<strong>.<\/strong>index:    <strong>if<\/strong> data[column]<strong>.<\/strong>nunique() <strong>==<\/strong> 2:        bool_columns<strong>.<\/strong>append(column) le <strong>=<\/strong> preprocessing<strong>.<\/strong>LabelEncoder() <strong>for<\/strong> column <strong>in<\/strong> bool_columns:    data[column] <strong>=<\/strong> le<strong>.<\/strong>fit_transform(data[column]) <em># \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0435\u0439 \u0444\u0438\u0447\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043d\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u0447\u0430\u0445<\/em> <em># \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0444\u0438\u0447\u0443 'customer_service_calls' \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u043e\u0439 (\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0432\u0435\u0434\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <\/em> <em># \u043e\u0442 'A' \u0434\u043e 'F', \u0430 \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 6 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e 'G' \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 1% \u0432\u044b\u0431\u043e\u0440\u043a\u0438<\/em> data['customer_service_calls'] <strong>=<\/strong> data['customer_service_calls']<strong>.<\/strong>replace(    {0: 'A', 1: 'B', 2: 'C', 3: 'D', 4: 'E', 5: 'F'})<strong>.<\/strong>mask(data['customer_service_calls'] <strong>&gt;=<\/strong> 6, 'G') <em># \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043b\u043e\u043d\u0433-\u043b\u0438\u0441\u0442 \u0444\u0438\u0447\u0435\u0439 features \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u0447\u0435\u0439 cat_feat (\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 phone_number \u0438 \u0442\u0430\u0440\u0433\u0435\u0442 churn)<\/em> features <strong>=<\/strong> data<strong>.<\/strong>columns<strong>.<\/strong>to_list() features  <strong>=<\/strong> [x <strong>for<\/strong> x <strong>in<\/strong> features <strong>if<\/strong> x <strong>not<\/strong> <strong>in<\/strong> ['phone_number','churn']] cat_feat <strong>=<\/strong> data<strong>.<\/strong>select_dtypes(exclude <strong>=<\/strong> [np<strong>.<\/strong>number])<strong>.<\/strong>columns<strong>.<\/strong>to_list() cat_feat  <strong>=<\/strong> [x <strong>for<\/strong> x <strong>in<\/strong> cat_feat <strong>if<\/strong> x <strong>not<\/strong> <strong>in<\/strong> ['phone_number','churn']] <em># \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441\u043e \u0441\u0442\u0440\u0430\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043f\u043e churn \u043d\u0430 \u0442\u0440\u0435\u0439\u043d(75%) \u0438 \u0442\u0435\u0441\u0442(25%) \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435:<\/em> x_train,x_test,y_train,y_test<strong>=<\/strong>train_test_split(data, data['churn'], stratify <strong>=<\/strong> data['churn'], test_size <strong>=<\/strong> 0.25, random_state<strong>=<\/strong>42) x_train,x_val,y_train,y_val<strong>=<\/strong>train_test_split(x_train, y_train, stratify <strong>=<\/strong> y_train, test_size <strong>=<\/strong> 0.20, random_state <strong>=<\/strong> 42)<\/code><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0444\u0438\u0447\u0430\u0445 \u0438\u0437 \u043b\u043e\u043d\u0433\u2013\u043b\u0438\u0441\u0442\u0430 \u043e\u0431\u0443\u0447\u0438\u043c Catboost \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u0438 c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432.\u00a0\u041d\u0430\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0431\u043e\u043b\u0435\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0444\u0438\u0447\u0435\u0439.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0414\u0436\u0438\u043d\u0438 83,08%.<\/p>\n<p>\u0417\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0446\u0435\u043d\u0438\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e get_feature_importance() \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c PredictionValueChange,\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0444\u0438\u0447\u0435\u0439.<\/p>\n<p>\u041f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0438\u0447\u0438 \u0437\u0430\u043c\u0435\u043d\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u0447\u0438 \u043f\u043e \u0432\u044b\u0431\u043e\u0440\u043a\u0435,\u00a0\u0430 \u0434\u043b\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u2014 \u043d\u0430 \u0441\u0430\u043c\u044b\u0439 \u0447\u0430\u0441\u0442\u044b\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>\u0412\u044b\u0431\u0435\u0440\u0435\u043c \u043f\u044f\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0444\u0438\u0447. \u0418\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u043d\u0438\u0445 \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u044f\u0442\u044c\u044e \u0441\u0430\u043c\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u043c\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438\u0441\u044c: &#8216;total_charge&#8217;, &#8216;customer_service_calls&#8217;, &#8216;international_plan&#8217;, &#8216;total_intl_calls&#8217; \u0438 &#8216;number_vmail_messages&#8217;.<\/p>\n<p>\u0414\u043b\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445.\u00a0\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 describe \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041a\u043e\u0434 \u043d\u0430 Python \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u043c. \u043d\u0438\u0436\u0435:<\/p>\n<p><code><strong>def<\/strong> gini(y_true, y_pred):    gini <strong>=<\/strong> 2 <em> roc_auc_score(y_true, y_pred) <\/em><strong><em>-<\/em><\/strong><em> 1    <\/em><strong><em>return<\/em><\/strong><em> gini<\/em><br \/><em>gini_scorer <\/em><strong><em>=<\/em><\/strong><em> make_scorer(gini, greater_is_better <\/em><strong><em>=<\/em><\/strong><em> <\/em><strong><em>True<\/em><\/strong><em>)<\/em><br \/><em>params <\/em><strong><em>=<\/em><\/strong><em> {    \"verbose\": <\/em><strong><em>False<\/em><\/strong><em>,    \"eval_metric\": 'Logloss',    'iterations':  1000,    'random_state': 42,    'early_stopping_rounds': 10,    'max_depth': 4<\/em><br \/><em>}<\/em><br \/><em>model <\/em><strong><em>=<\/em><\/strong><em> CatBoostClassifier(<\/em><strong>*<\/strong>params)<br \/>model<strong>.<\/strong>fit(x_train[features], y_train, eval_set <strong>=<\/strong> (x_val[features], y_val), cat_features <strong>=<\/strong> cat_feat)<br \/>y_pred_train <strong>=<\/strong> model<strong>.<\/strong>predict_proba(x_train[features])<strong>.<\/strong>T[1]<br \/>y_pred_val <strong>=<\/strong> model<strong>.<\/strong>predict_proba(x_val[features])<strong>.<\/strong>T[1]<br \/>y_pred_test <strong>=<\/strong> model<strong>.<\/strong>predict_proba(x_test[features])<strong>.<\/strong>T[1]<br \/>gini_train <strong>=<\/strong> np<strong>.<\/strong>round(gini(y_train, y_pred_train),3)<br \/>gini_val <strong>=<\/strong> np<strong>.<\/strong>round(gini(y_val, y_pred_val),3)<br \/>gini_test <strong>=<\/strong> np<strong>.<\/strong>round(gini(y_test, y_pred_test),3)<br \/>print('\u0414\u0436\u0438\u043d\u0438 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0444\u0438\u0447\u0430\u0445:', 'train', gini_train, 'val', gini_val, 'test', gini_test)<br \/>fe_stats <strong>=<\/strong> pd<strong>.<\/strong>DataFrame({'feature_importance': model<strong>.<\/strong>get_feature_importance(),               'feature_names':features})<strong>.<\/strong>sort_values(by<strong>=<\/strong>['feature_importance'], ascending<strong>=False<\/strong>)<br \/>display(fe_stats[0:5])<br \/>features <strong>=<\/strong> fe_stats[0:5]<strong>.<\/strong>feature_names<strong>.<\/strong>to_list()<br \/>cat_feat <strong>=<\/strong> ['customer_service_calls']<\/code><\/p>\n<p><code><br \/>target <strong>=<\/strong> ['churn']<br \/>data <strong>=<\/strong> data[features <strong>+<\/strong> target]<strong>.<\/strong>copy()<br \/>data_info <strong>=<\/strong> data<strong>.<\/strong>describe(percentiles <strong>=<\/strong> [0.01, 0.05, 0.5, 0.95, 0.99],                          include<strong>=<\/strong>list(np<strong>.<\/strong>unique(data[data<strong>.<\/strong>columns]<strong>.<\/strong>dtypes<strong>.<\/strong>astype('str')<strong>.<\/strong>values)))<strong>.<\/strong>T<br \/>data_info['type'] <strong>=<\/strong> data[data<strong>.<\/strong>columns]<strong>.<\/strong>dtypes<br \/>data_info['null'] <strong>=<\/strong> data[data<strong>.<\/strong>columns]<strong>.<\/strong>isnull()<strong>.<\/strong>sum()<br \/>data_info['null%'] <strong>=<\/strong> np<strong>.<\/strong>round(data[data<strong>.<\/strong>columns]<strong>.<\/strong>isnull()<strong>.<\/strong>mean() <strong>*<\/strong> 100, 1)<br \/>data_info['nunique'] <strong>=<\/strong> data[data<strong>.<\/strong>columns]<strong>.<\/strong>nunique()<br \/>data_info['count'] <strong>=<\/strong> data_info['count']<strong>.<\/strong>astype('int')<br \/>data_info <strong>=<\/strong> data_info<strong>.<\/strong>drop('unique', axis <strong>=<\/strong> 1)<br \/>data_info<strong>.<\/strong>sort_values(by <strong>=<\/strong> ['type','nunique'], ascending <strong>=<\/strong> [<strong>False<\/strong>, <strong>False<\/strong>], inplace <strong>=<\/strong> <strong>True<\/strong>)<br \/>data_info<strong>=<\/strong>data_info<strong>.<\/strong>loc[:,['type','count','nunique','null','null%','top','freq','min','max','mean','std','1%','5%','50%','95%','99%']]<br \/>data_info[['min','max','mean','std','1%','5%','50%','95%','99%']] <strong>=<\/strong> data_info[['min','max','mean','std','1%','5%','50%','95%','99%']]<strong>.<\/strong>astype(float)<strong>.<\/strong>round(4)<br \/>display(data_info)<\/code><\/p>\n<p><u>\u0414\u0436\u0438\u043d\u0438 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0444\u0438\u0447\u0430\u0445: train 0.934 val 0.859 test 0.831<\/u><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">\n<\/td>\n<td>\n<p align=\"left\"><strong>feature_importance<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>feature_names<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>21<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">39.692171<\/p>\n<\/td>\n<td>\n<p align=\"left\">total_charge<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>18<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">17.874816<\/p>\n<\/td>\n<td>\n<p align=\"left\">customer_service_calls<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>3<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">14.006796<\/p>\n<\/td>\n<td>\n<p align=\"left\">international_plan<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>16<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">6.891904<\/p>\n<\/td>\n<td>\n<p align=\"left\">total_intl_calls<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>5<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">5.593090<\/p>\n<\/td>\n<td>\n<p align=\"left\">number_vmail_messages<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\"><strong>type<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\"><strong>count<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\"><strong>nunique<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\"><strong>null<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\"><strong>null%<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\"><strong>top<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\"><strong>freq<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\"><strong>min<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\"><strong>max<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\"><strong>mean<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\"><strong>std<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\"><strong>1%<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\"><strong>5%<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\"><strong>50%<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\"><strong>95%<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>99%<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>customer_service_calls<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">object<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">7<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">B<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">1181<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td>\n<p align=\"left\">NaN<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>total_charge<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">float64<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">2678<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">22.93<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">96.15<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">59.4498<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">10.5023<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">33.8532<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">42.338<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">59.47<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">76.516<\/p>\n<\/td>\n<td>\n<p align=\"left\">83.8396<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>number_vmail_messages<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">int64<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">46<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">51.00<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">8.0990<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">13.6884<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">0.0000<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">0.000<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">36.000<\/p>\n<\/td>\n<td>\n<p align=\"left\">43.0000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>total_intl_calls<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">int64<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">21<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">20.00<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">4.4794<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">2.4612<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">1.0000<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">1.000<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">4.00<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">9.000<\/p>\n<\/td>\n<td>\n<p align=\"left\">13.0000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>international_plan<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">int32<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">2<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">1.00<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">0.0969<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">0.2959<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">0.0000<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">0.000<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">1.000<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0000<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>churn<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"69\" width=\"69\">\n<p align=\"left\">int32<\/p>\n<\/td>\n<td data-colwidth=\"63\" width=\"63\">\n<p align=\"left\">3333<\/p>\n<\/td>\n<td data-colwidth=\"78\" width=\"78\">\n<p align=\"left\">2<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"60\" width=\"60\">\n<p align=\"left\">0.0<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"51\" width=\"51\">\n<p align=\"left\">NaN<\/p>\n<\/td>\n<td data-colwidth=\"54\" width=\"54\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">1.00<\/p>\n<\/td>\n<td data-colwidth=\"58\" width=\"58\">\n<p align=\"left\">0.1449<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">0.3521<\/p>\n<\/td>\n<td data-colwidth=\"75\" width=\"75\">\n<p align=\"left\">0.0000<\/p>\n<\/td>\n<td data-colwidth=\"56\" width=\"56\">\n<p align=\"left\">0.000<\/p>\n<\/td>\n<td data-colwidth=\"59\" width=\"59\">\n<p align=\"left\">0.00<\/p>\n<\/td>\n<td data-colwidth=\"68\" width=\"68\">\n<p align=\"left\">1.000<\/p>\n<\/td>\n<td>\n<p align=\"center\">1.0000<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u0431\u0443\u0447\u0438\u043c catboost \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u044f\u0442\u0438 \u0441\u0430\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0444\u0438\u0447\u0430\u0445.\u00a0\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0414\u0436\u0438\u043d\u0438 82,5%.<\/p>\n<p><code>params\u00a0<strong>=<\/strong>\u00a0{<\/code><\/p>\n<p><code>\u00a0 <\/code><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-471435","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/471435","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=471435"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/471435\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=471435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=471435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=471435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}