{"id":442784,"date":"2024-12-24T15:07:33","date_gmt":"2024-12-24T15:07:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=442784"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-12-24T15:07:33","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=442784","title":{"rendered":"<span>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u0438\u043b\u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0437\u043d\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0445\u2026<\/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 loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/912\/c87\/aa2\/912c87aa29d3487f8e7eec4fbc9d53b2.jpg\" width=\"768\" height=\"583\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/912\/c87\/aa2\/912c87aa29d3487f8e7eec4fbc9d53b2.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u043e \u0438\u0442\u043e\u0433\u0430\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u0443\u0440\u0441\u0435 <a href=\"https:\/\/otus.pw\/N5rq\/\">Otus ML Basic<\/a> \u0438 \u0432 \u043d\u0435\u0439 \u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0443 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430. \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u0443\u0441\u0442\u0438\u043d\u0433, \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b ? \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u0438 \u0435\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043e\u043c. \u0411\u0443\u0441\u0442\u0438\u043d\u0433 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0442\u043e \u0438\u0437 \u043d\u0438\u0445 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c\u0438 \u0442\u0443\u0440\u043d\u0438\u0440\u0430, \u0447\u044c\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u0431\u0443\u0434\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>Sklearn;<\/p>\n<\/li>\n<li>\n<p>XGBoost;<\/p>\n<\/li>\n<li>\n<p>LightGBM;<\/p>\n<\/li>\n<li>\n<p>Catboost;<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u0434\u0435\u044e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f &#171;\u0441\u0438\u043b\u044c\u043d\u043e\u0439&#187; \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 (\u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0439), \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445  \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0448\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u0438\u043c \u0432\u044b\u0448\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u044f. \u041e\u0431\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0441\u0442\u0440\u043e\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043d\u0438\u044f;<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0430 <a href=\"https:\/\/www.kaggle.com\/datasets\/blastchar\/telco-customer-churn\">\u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/a> \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043e\u0442\u0442\u043e\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0442\u0435\u043b\u0435\u043a\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u041f\u043e\u043b\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e jupyter \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0430 \u0432\u0441\u0435 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/DzenGarden\/Otus-ML\/blob\/main\/articles\/ensemble-of-models\/boosting-algorithms.ipynb\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import numpy as np  import pandas as pd  import seaborn as sns  import matplotlib.pyplot as plt  from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score from sklearn.preprocessing import LabelEncoder, StandardScaler  from sklearn.ensemble import GradientBoostingClassifier from xgboost import XGBClassifier from lightgbm import LGBMClassifier from catboost import CatBoostClassifier  from sklearn.model_selection import GridSearchCV  import warnings warnings.filterwarnings(\"ignore\")<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/p>\n<pre><code class=\"python\">df = pd.read_csv('data\/WA_Fn-UseC_-Telco-Customer-Churn.csv', index_col=0) df.info()<\/code><\/pre>\n<pre><code>    Index: 7043 entries, 7590-VHVEG to 3186-AJIEK     Data columns (total 20 columns):      #   Column            Non-Null Count  Dtype       ---  ------            --------------  -----        0   gender            7043 non-null   object       1   SeniorCitizen     7043 non-null   int64        2   Partner           7043 non-null   object       3   Dependents        7043 non-null   object       4   tenure            7043 non-null   int64        5   PhoneService      7043 non-null   object       6   MultipleLines     7043 non-null   object       7   InternetService   7043 non-null   object       8   OnlineSecurity    7043 non-null   object       9   OnlineBackup      7043 non-null   object       10  DeviceProtection  7043 non-null   object       11  TechSupport       7043 non-null   object       12  StreamingTV       7043 non-null   object       13  StreamingMovies   7043 non-null   object       14  Contract          7043 non-null   object       15  PaperlessBilling  7043 non-null   object       16  PaymentMethod     7043 non-null   object       17  MonthlyCharges    7043 non-null   float64      18  TotalCharges      7043 non-null   object       19  Churn             7043 non-null   object      dtypes: float64(1), int64(2), object(17)     memory usage: 1.1+ MB<\/code><\/pre>\n<p>\u0412 \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c 3 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0438\u0437 20 \u0438\u043c\u0435\u044e\u0442 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u0442\u0438\u043f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0432 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h3>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"python\">df.isna().sum()<\/code><\/pre>\n<pre><code>    gender              0     SeniorCitizen       0     Partner             0     Dependents          0     tenure              0     PhoneService        0     MultipleLines       0     InternetService     0     OnlineSecurity      0     OnlineBackup        0     DeviceProtection    0     TechSupport         0     StreamingTV         0     StreamingMovies     0     Contract            0     PaperlessBilling    0     PaymentMethod       0     MonthlyCharges      0     TotalCharges        0     Churn               0     dtype: int64<\/code><\/pre>\n<p>\u041f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u0442 \u0438 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0435\u0441\u0442\u044c 17 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<pre><code>    Index(['gender', 'Partner', 'Dependents', 'PhoneService', 'MultipleLines',            'InternetService', 'OnlineSecurity', 'OnlineBackup', 'DeviceProtection',            'TechSupport', 'StreamingTV', 'StreamingMovies', 'Contract',            'PaperlessBilling', 'PaymentMethod', 'TotalCharges', 'Churn'],           dtype='object')<\/code><\/pre>\n<p><code> <\/code>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<\/p>\n<pre><code class=\"python\">df.nunique()<\/code><\/pre>\n<pre><code>    gender                 2     SeniorCitizen          2     Partner                2     Dependents             2     tenure                73     PhoneService           2     MultipleLines          3     InternetService        3     OnlineSecurity         3     OnlineBackup           3     DeviceProtection       3     TechSupport            3     StreamingTV            3     StreamingMovies        3     Contract               3     PaperlessBilling       2     PaymentMethod          4     MonthlyCharges      1585     TotalCharges        6531     Churn                  2     dtype: int64<\/code><\/pre>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0437\u0430\u043c\u0435\u043d\u044b \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 1\/0<\/p>\n<details class=\"spoiler\">\n<summary> \u041a\u043e\u0434 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 <\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">bin_cat_cols_list = [] for index, value in df.nunique().items():       if value == 2:             bin_cat_cols_list.append(index)             print(f\"Index : {index}, Value : {value}\") <\/code><\/pre>\n<pre><code>    Index : gender, Value : 2     Index : SeniorCitizen, Value : 2     Index : Partner, Value : 2     Index : Dependents, Value : 2     Index : PhoneService, Value : 2     Index : PaperlessBilling, Value : 2     Index : Churn, Value : 2<\/code><\/pre>\n<pre><code class=\"python\">for col in bin_cat_cols_list:     print(col, df[col].unique())<\/code><\/pre>\n<pre><code>    gender ['Female' 'Male']     SeniorCitizen [0 1]     Partner ['Yes' 'No']     Dependents ['No' 'Yes']     PhoneService ['No' 'Yes']     PaperlessBilling ['Yes' 'No']     Churn ['No' 'Yes']<\/code><\/pre>\n<p>\u0430\u0442\u0440\u0438\u0431\u0443\u0442 SeniorCitizen \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 0\/1, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u043c \u0435\u0433\u043e \u0438\u0437 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/p>\n<pre><code class=\"python\">bin_cat_cols_list.remove('SeniorCitizen')  for col in bin_cat_cols_list:     print(col, df[col].unique())<\/code><\/pre>\n<pre><code>    gender ['Female' 'Male']     Partner ['Yes' 'No']     Dependents ['No' 'Yes']     PhoneService ['No' 'Yes']     PaperlessBilling ['Yes' 'No']     Churn ['No' 'Yes']<\/code><\/pre>\n<p>\u0418\u0442\u043e\u0433\u043e, \u0443 \u043d\u0430\u0441 6 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 &#8212; \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 0\/1<\/p>\n<pre><code class=\"python\">g_dict = {'Female':0, 'Male':1} df['gender'] = df['gender'].map(g_dict)<\/code><\/pre>\n<pre><code class=\"python\">yn_dict = {'Yes':1, 'No':0} for col in bin_cat_cols_list[1:]:     df[col] = df[col].map(yn_dict)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u043e \u0438\u0442\u043e\u0433\u0430\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<\/p>\n<pre><code class=\"python\">df.info()<\/code><\/pre>\n<pre><code>    Index: 7043 entries, 7590-VHVEG to 3186-AJIEK     Data columns (total 20 columns):      #   Column            Non-Null Count  Dtype       ---  ------            --------------  -----        0   gender            7043 non-null   int64        1   SeniorCitizen     7043 non-null   int64        2   Partner           7043 non-null   int64        3   Dependents        7043 non-null   int64        4   tenure            7043 non-null   int64        5   PhoneService      7043 non-null   int64        6   MultipleLines     7043 non-null   object       7   InternetService   7043 non-null   object       8   OnlineSecurity    7043 non-null   object       9   OnlineBackup      7043 non-null   object       10  DeviceProtection  7043 non-null   object       11  TechSupport       7043 non-null   object       12  StreamingTV       7043 non-null   object       13  StreamingMovies   7043 non-null   object       14  Contract          7043 non-null   object       15  PaperlessBilling  7043 non-null   int64        16  PaymentMethod     7043 non-null   object       17  MonthlyCharges    7043 non-null   float64      18  TotalCharges      7043 non-null   object       19  Churn             7043 non-null   int64       dtypes: float64(1), int64(8), object(11)     memory usage: 1.1+ MB<\/code><\/pre>\n<p>\u041f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u043c\u0438\u0441\u044f 11 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u0438 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f TotalCharges \u043a \u0442\u0438\u043f\u0443 float<\/p>\n<pre><code class=\"python\">df['TotalCharges'] = pd.to_numeric(df['TotalCharges'], errors='coerce') df.isna().sum()<\/code><\/pre>\n<pre><code>    gender               0     SeniorCitizen        0     Partner              0     Dependents           0     tenure               0     PhoneService         0     MultipleLines        0     InternetService      0     OnlineSecurity       0     OnlineBackup         0     DeviceProtection     0     TechSupport          0     StreamingTV          0     StreamingMovies      0     Contract             0     PaperlessBilling     0     PaymentMethod        0     MonthlyCharges       0     TotalCharges        11     Churn                0     dtype: int64<\/code><\/pre>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c 11 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 Total Charges, \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u043c \u0438\u0445 \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"python\">df.dropna(inplace = True)<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c LabelEncoder \u043f\u0430\u043a\u0435\u0442\u0430 sklearn<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">obj_cols = df.select_dtypes(include='object').columns  for col in obj_cols:     print(col, df[col].unique())<\/code><\/pre>\n<pre><code>    MultipleLines ['No phone service' 'No' 'Yes']     InternetService ['DSL' 'Fiber optic' 'No']     OnlineSecurity ['No' 'Yes' 'No internet service']     OnlineBackup ['Yes' 'No' 'No internet service']     DeviceProtection ['No' 'Yes' 'No internet service']     TechSupport ['No' 'Yes' 'No internet service']     StreamingTV ['No' 'Yes' 'No internet service']     StreamingMovies ['No' 'Yes' 'No internet service']     Contract ['Month-to-month' 'One year' 'Two year']     PaymentMethod ['Electronic check' 'Mailed check' 'Bank transfer (automatic)'      'Credit card (automatic)']<\/code><\/pre>\n<pre><code class=\"python\">label_encoder = LabelEncoder()  for col in obj_cols:     df[col] = label_encoder.fit_transform(df[col])  for col in obj_cols:     print(col, df[col].unique())<\/code><\/pre>\n<pre><code>    MultipleLines [1 0 2]     InternetService [0 1 2]     OnlineSecurity [0 2 1]     OnlineBackup [2 0 1]     DeviceProtection [0 2 1]     TechSupport [0 2 1]     StreamingTV [0 2 1]     StreamingMovies [0 2 1]     Contract [0 1 2]     PaymentMethod [2 3 0 1]<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439:<\/p>\n<pre><code class=\"python\">df.info()<\/code><\/pre>\n<pre><code>    Index: 7032 entries, 7590-VHVEG to 3186-AJIEK     Data columns (total 20 columns):      #   Column            Non-Null Count  Dtype       ---  ------            --------------  -----        0   gender            7032 non-null   int64        1   SeniorCitizen     7032 non-null   int64        2   Partner           7032 non-null   int64        3   Dependents        7032 non-null   int64        4   tenure            7032 non-null   int64        5   PhoneService      7032 non-null   int64        6   MultipleLines     7032 non-null   int64        7   InternetService   7032 non-null   int64        8   OnlineSecurity    7032 non-null   int64        9   OnlineBackup      7032 non-null   int64        10  DeviceProtection  7032 non-null   int64        11  TechSupport       7032 non-null   int64        12  StreamingTV       7032 non-null   int64        13  StreamingMovies   7032 non-null   int64        14  Contract          7032 non-null   int64        15  PaperlessBilling  7032 non-null   int64        16  PaymentMethod     7032 non-null   int64        17  MonthlyCharges    7032 non-null   float64      18  TotalCharges      7032 non-null   float64      19  Churn             7032 non-null   int64       dtypes: float64(2), int64(18)     memory usage: 1.4+ MB<\/code><\/pre>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u0438 \u043d\u0430\u0448 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0433\u043e\u0442\u043e\u0432 \u043a \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435. \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430, \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0440\u0430\u0437\u0432\u0435\u0434\u043e\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445, aka Exploratory Data Analysis, \u043e\u043d \u0436\u0435 EDA<\/p>\n<h3>EDA<\/h3>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044e \u0432 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"python\">fig, ax = plt.subplots(figsize=(12, 6)) sns.heatmap(df.corr(), annot=True, linewidths=.5, fmt= '.1f',ax=ax);<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e2f\/3dd\/99e\/e2f3dd99ef7f073e0fc491099f60c5d5.png\" alt=\"png\" title=\"\" width=\"1006\" height=\"617\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e2f\/3dd\/99e\/e2f3dd99ef7f073e0fc491099f60c5d5.png\"\/><\/figure>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u0440\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432<\/p>\n<pre><code class=\"python\">sns.pairplot(data=df[['tenure','Contract','MonthlyCharges','TotalCharges','Churn']], hue='Churn') plt.show;<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/101\/acd\/182\/101acd1825eb6c192a4cba0129b1e819.png\" alt=\"png\" title=\"\" width=\"1054\" height=\"986\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/101\/acd\/182\/101acd1825eb6c192a4cba0129b1e819.png\"\/><\/figure>\n<p>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0435\u0441\u0442\u044c, \u043d\u043e \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h4>\u041a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438<\/h4>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044e \u043e\u0442\u0442\u043e\u043a\u0430 (Churn) \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438<\/p>\n<pre><code class=\"python\">plt.figure(figsize=(8,6)) df.corr()['Churn'].sort_values(ascending = False).plot(kind='bar')<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d51\/77e\/dc9\/d5177edc97f48f478b2478ecd98e6889.png\" alt=\"png\" title=\"\" width=\"683\" height=\"611\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d51\/77e\/dc9\/d5177edc97f48f478b2478ecd98e6889.png\"\/><\/figure>\n<h4>\u0427\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f<\/h4>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0432 \u0440\u0430\u0437\u0440\u0435\u0437\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">fig = plt.subplots(nrows = 1,ncols = 3,figsize = (20,7))  plt.subplot(1,3,1) ax = sns.kdeplot(df.MonthlyCharges[(df[\"Churn\"] == 0)], color='#008080', fill= True, alpha=.7, linewidth=0) ax = sns.kdeplot(df.MonthlyCharges[(df[\"Churn\"] == 1)], color='#FF6347', fill= True, alpha=.7, linewidth=0) ax.legend([\"Not Churn\",\"Churn\"],loc='upper right') ax.set_ylabel('Density') ax.set_xlabel('Monthly Charges') ax.set_title('Distribution of Monthly Charges by Churn')  plt.subplot(1,3,2) ax = sns.kdeplot(df.TotalCharges[(df[\"Churn\"] == 0)], color='#008080', fill= True, alpha=.7, linewidth=0) ax = sns.kdeplot(df.TotalCharges[(df[\"Churn\"] == 1)], color='#FF6347', fill= True, alpha=.7, linewidth=0) ax.legend([\"Not Churn\",\"Churn\"],loc='upper right') ax.set_ylabel('Density') ax.set_xlabel('Total Charges') ax.set_title('Distribution of Total Charges by Churn')  plt.subplot(1,3,3) ax = sns.kdeplot(df.tenure[(df[\"Churn\"] == 0)], color='#008080', fill= True, alpha=.7, linewidth=0) ax = sns.kdeplot(df.tenure[(df[\"Churn\"] == 1)], color='#FF6347', fill= True, alpha=.7, linewidth=0) ax.legend([\"Not Churn\",\"Churn\"],loc='upper right') ax.set_ylabel('Density') ax.set_xlabel('Tenure') ax.set_title('Distribution of Tenure by Churn')  plt.show();<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/421\/429\/559\/421429559b724cc51dfa16b294a91205.png\" alt=\"png\" title=\"\" width=\"1648\" height=\"622\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/421\/429\/559\/421429559b724cc51dfa16b294a91205.png\"\/><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0432\u043e\u0434\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0435\u0436\u0435\u0439 (Monthly Charges) \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043a \u043e\u0442\u0442\u043e\u043a\u0443 \u0441\u043a\u043b\u043e\u043d\u043d\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0441\u0443\u043c\u043c\u0430\u043c\u0438 \u043f\u043b\u0430\u0442\u0435\u0436\u0435\u0439, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0447\u0435\u0442\u0430 \u0437\u0430 \u0440\u043e\u0443\u043c\u0438\u043d\u0433 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u043b\u043e\u044f\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u0449\u0435\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 \u0441\u0447\u0435\u0442\u043e\u0432 (Total Charges) \u0432\u044b\u0448\u0435 \u0434\u043e\u043b\u044f \u043b\u043e\u044f\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 (Tenure) \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043b\u0443\u0447\u0448\u0435\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 &#8212; \u043b\u043e\u044f\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u0434\u0430\u0432\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043d\u043e\u0432\u044b\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u043a\u043b\u043e\u043d\u043d\u044b \u043a \u043e\u0442\u0442\u043e\u043a\u0443;<\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">palette = ['#008080','#FF6347', '#E50000', '#D2691E']  l1 = list(df['Churn'].value_counts()) pie_values = [l1[0] \/ sum(l1) * 100, l1[1] \/ sum(l1) * 100]  fig = plt.subplots(nrows = 1,ncols = 2,figsize = (20,7))  plt.subplot(1,2,1) plt.pie(pie_values,labels = ['Not-Churn Customers','Churn Customers'],          autopct = '%1.2f%%',         explode = (0.1,0),         colors = palette,         wedgeprops = {'edgecolor': 'black','linewidth': 1, 'antialiased' : True}) plt.title('Churn and Not-Churn Customers %');  plt.subplot(1,2,2) ax = sns.countplot(data = df,                     x='Churn',                    palette = palette,                     edgecolor = 'black') for i in ax.containers:     ax.bar_label(i,) ax.set_xticklabels(['Not-Churn Customers','Churn Customers'])      plt.title('Churn and Not-Churn Customers') plt.show()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/01c\/1b4\/042\/01c1b4042fc57859be183195ba5b7ee9.png\" width=\"1541\" height=\"622\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/01c\/1b4\/042\/01c1b4042fc57859be183195ba5b7ee9.png\"\/><\/figure>\n<p>\u0414\u043e\u043b\u044f \u0441\u043a\u043b\u043e\u043d\u043d\u044b\u0445 \u043a \u043e\u0442\u0442\u043e\u043a\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0438 \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0431\u0430\u0437\u044b &#8212; \u0443\u0433\u0440\u043e\u0436\u0430\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u043b\u044e\u0431\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u0432\u044f\u0437\u0438, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0434\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043a\u0430\u043a-\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f&#8230; \u041d\u0443 \u0430 \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<h4>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0443\u044e \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0438<\/h4>\n<p>\u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0443\u044e (train) \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e (test) \u0432\u044b\u0431\u043e\u0440\u043a\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e train_test_split \u043f\u0430\u043a\u0435\u0442\u0430 sklearn \u0438 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 stratify, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043d\u0435\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"python\">X = df.drop('Churn', axis=1) y = df['Churn']  X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y, test_size = 0.3, random_state = 13)<\/code><\/pre>\n<h4>\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432<\/h4>\n<p>\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0449\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 StandardScaler \u043c\u043e\u0434\u0443\u043b\u044f preprocessing \u043f\u0430\u043a\u0435\u0442\u0430 sklearn. StandardScaler \u0446\u0435\u043d\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u043b\u044f, \u0432\u044b\u0447\u0438\u0442\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442 \u0438\u0445, \u0434\u0435\u043b\u044f \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"z = \\frac{(x - \\mu)}{\\sigma}\" alt=\"z = \\frac{(x - \\mu)}{\\sigma}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b8f\/756\/8ba\/b8f7568ba621b935d19b4e96b0ce1203.svg\" width=\"105\" height=\"45\"\/><\/p>\n<p>\u0433\u0434\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"\\mu\" alt=\"\\mu\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c\/c9\/c9f\/c9faf6ead2cd2c2187bd943488de1d0a.svg\" width=\"auto\" height=\"auto\"\/> \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0438\u0437 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430, <img decoding=\"async\" class=\"formula inline\" source=\"\\sigma\" alt=\"\\sigma\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/a\/a2\/a2a\/a2ab7d71a0f07f388ff823293c147d21.svg\" width=\"auto\" height=\"auto\"\/>  &#8212; \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435<\/p>\n<pre><code class=\"python\">numeric_columns = ['tenure', 'MonthlyCharges', 'TotalCharges'] std_scaler = StandardScaler()  X_train[numeric_columns] = std_scaler.fit_transform(X_train[numeric_columns]) X_test[numeric_columns]= std_scaler.transform(X_test[numeric_columns])<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<h3>Sklearn<\/h3>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0442\u0443\u0440\u043d\u0438\u0440 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043e\u0442 sklearn \u0438 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0443\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 &#8212; accuracy, precision, recall, f1-score \u0438 ROC-AUC. \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u0443\u0436 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c )<\/p>\n<pre><code class=\"python\">def quality(true_y, prediction_y):     \"\"\"     Evaluates and returns the following metrics: Accuracy, Precision, Recall, F1-score, AUC     \"\"\"     accuracy = round(accuracy_score(true_y, prediction_y), 3)     precision = round(precision_score(true_y, prediction_y), 3)     recall = round(recall_score(true_y, prediction_y), 3)     f1 = round(f1_score(true_y, prediction_y), 3)     auc = round(roc_auc_score(true_y, prediction_y), 3)     print(f\" Accuracy: {accuracy}\")     print(f\"Precision: {precision}\")     print(f\"   Recall: {recall}\")     print(f\" F1-score: {f1}\")     print(f\"      AUC: {auc}\")     return [accuracy, precision, recall, f1, auc]<\/code><\/pre>\n<p>\u0418\u0437\u043c\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a \u0431\u0443\u0434\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c<\/p>\n<pre><code class=\"python\">results = {}<\/code><\/pre>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u043e\u0447\u043a\u0438 \u043e\u0442\u0441\u0447\u0435\u0442\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u0435\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 sklearn<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\"># first run with default parameters sgb_clf = GradientBoostingClassifier(random_state=13)  sgb_clf.fit(X_train, y_train) y_pred = sgb_clf.predict(X_test)  results['Sklearn'] = quality(y_test, y_pred)<\/code><\/pre>\n<pre><code>     Accuracy: 0.807     Precision: 0.678        Recall: 0.522      F1-score: 0.59           AUC: 0.716<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/p>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c baseline \u0438 \u043f\u043e\u0440\u0430 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<h4>Sklearn: \u043a\u0440\u0438\u0432\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432<\/h4>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u044d\u0442\u043e n_estimators \u0438\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u044d\u0442\u0430\u043f\u043e\u0432 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 &#8212; \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0447\u0438\u0441\u043b\u0430 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 (decision trees), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u0418 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043a\u0440\u0438\u0432\u0443\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 (\u043f\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0435 ROC-AUC) \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">n_trees = [1, 3, 5, 10, 50, 100, 200, 300, 400, 500] quals_train = [] quals_test = [] for n in n_trees:     clf = GradientBoostingClassifier(n_estimators=n, random_state=13)     clf.fit(X_train, y_train)     q_train = roc_auc_score(y_train, clf.predict(X_train))     q_test = roc_auc_score(y_test, clf.predict(X_test))      quals_train.append(q_train)     quals_test.append(q_test)  plt.figure(figsize=(8, 5)) plt.plot(n_trees, quals_train, marker='.', label='train') plt.plot(n_trees, quals_test, marker='.', label='test') plt.xlabel('Number of trees') plt.ylabel('AUC-ROC') plt.title('Sklearn GB Validation Curve') plt.legend()  plt.show();<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4ff\/d34\/a57\/4ffd34a57dfbec30d4c1e529101519bf.png\" alt=\"png\" title=\"\" width=\"700\" height=\"468\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4ff\/d34\/a57\/4ffd34a57dfbec30d4c1e529101519bf.png\"\/><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438<\/p>\n<pre><code class=\"python\">sorted(list(zip(quals_test, n_trees)), reverse=True)<\/code><\/pre>\n<pre><code>    [(0.7162731634117349, 100),      (0.7099715876725712, 200),      (0.7046383786215936, 400),      (0.7040699019205077, 300),      (0.7035014252194217, 500),      (0.7016757404293955, 50),      (0.6225124828967916, 10),      (0.5, 5),      (0.5, 3),      (0.5, 1)]<\/code><\/pre>\n<p>\u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0442\u0441\u044f \u043d\u0430 100 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u0445<\/p>\n<h4>Sklearn: \u043a\u0440\u0438\u0432\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f (learning rate)<\/h4>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u043b\u0438\u044f\u0435\u0442 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 learning rate \u043d\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u0441\u043a\u043b\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e. \u0414\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u044b\u0445 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c staged_predict, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430, \u043f\u043e \u043c\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"python\">for learning_rate in [1, 0.5, 0.3, 0.2, 0.1]:      gbm = GradientBoostingClassifier(n_estimators=150, learning_rate=learning_rate, random_state=13).fit(X_train, y_train)          test_deviance = np.zeros((gbm.n_estimators,), dtype=np.float64)     for i, y_pred in enumerate(gbm.staged_predict(X_test)):         test_deviance[i] = roc_auc_score(y_test, y_pred)          train_deviance = np.zeros((gbm.n_estimators,), dtype=np.float64)     for i, y_pred in enumerate(gbm.staged_predict(X_train)):         train_deviance[i] = roc_auc_score(y_train, y_pred)      plt.figure()     plt.plot(test_deviance, 'r', linewidth=2)     plt.plot(train_deviance, 'g', linewidth=2)     plt.legend(['test', 'train'])          plt.title('GBM lr=%.1f, test roc-auc=%.3f, best_est=%d' % (learning_rate, test_deviance.max(), test_deviance.argmax()+1))     plt.xlabel('Number of trees')     plt.ylabel('Metric')<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/153\/de8\/7ff\/153de87ffad419b785fe7066f2447aaf.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/153\/de8\/7ff\/153de87ffad419b785fe7066f2447aaf.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/82f\/dbf\/8b4\/82fdbf8b4c03edf4e93d6dd0736804a5.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/82f\/dbf\/8b4\/82fdbf8b4c03edf4e93d6dd0736804a5.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ff2\/1ac\/afb\/ff21acafbdd4820df7e948aaa6d22581.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ff2\/1ac\/afb\/ff21acafbdd4820df7e948aaa6d22581.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/140\/7a8\/086\/1407a808642b91d7b9f334e9e4e1f6d6.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/140\/7a8\/086\/1407a808642b91d7b9f334e9e4e1f6d6.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b48\/177\/69a\/b4817769aae4970423c24e58e175f9a2.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b48\/177\/69a\/b4817769aae4970423c24e58e175f9a2.png\"\/><\/figure>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 ROC-AUC \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 learning rate (lr) \u0440\u0430\u0432\u043d\u043e\u043c 0.1 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u044d\u0442\u0430\u043f\u043e\u0432 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 (n_estimators) \u0440\u0430\u0432\u043d\u043e\u043c 79.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 sklearn \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 ROC-AUC \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 lr=0.1, n_estimators=79<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 sklearn \u0441 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">sgb_clf = GradientBoostingClassifier(n_estimators=79, learning_rate=0.1, random_state=13)  sgb_clf.fit(X_train, y_train) y_pred = sgb_clf.predict(X_test)  results['Sklearn-VC'] = quality(y_test, y_pred)<\/code><\/pre>\n<pre><code>     Accuracy: 0.809     Precision: 0.684        Recall: 0.528      F1-score: 0.596           AUC: 0.72<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u0440\u0438\u0432\u044b\u0445 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u043b\u0438\u0441\u044c.<\/p>\n<h4>Sklearn: \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0441\u0435\u0442\u043a\u0435 \u0441 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439<\/h4>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043a\u0440\u0438\u0432\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u044d\u0442\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0448\u0442\u0430\u0442\u043d\u043e\u0433\u043e \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 sklearn \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f GridSearchCV \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0441\u0435\u0442\u043a\u0435 \u0441 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043d\u0430\u043c \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0441\u0435\u0442\u043a\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GridSearchCV<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\"># Define Gradient Boosting classifier with default parameters clf = GradientBoostingClassifier(random_state=13)  # Estimate grid of the classifier hyperparameters parameters = {'n_estimators':[10,50,80,150],               'max_depth':[1,2,3,5],               'learning_rate':[1,0.5,0.3,0.2,0.1]              }  # Define GridSearch parameters gs = GridSearchCV(clf,                 # Classifier object to optimize                   parameters,          # Grid of the hyperparameters                   scoring='roc_auc',   # Classification quality metric to optimize                   cv=5                 # Number of folds in KFolds cross-validation                  )  # Run Grid Search optimization gs.fit(X_train, y_train) gs.best_params_<\/code><\/pre>\n<pre><code>    {'learning_rate': 0.2, 'max_depth': 1, 'n_estimators': 150}<\/code><\/pre>\n<pre><code class=\"python\">pred_gs = gs.predict(X_test)  results['Sklearn-GS'] = quality(y_test, pred_gs)<\/code><\/pre>\n<pre><code>     Accuracy: 0.808     Precision: 0.681        Recall: 0.522      F1-score: 0.591           AUC: 0.717<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 sklearn:<\/p>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GridSearch \u043c\u0435\u0442\u0440\u0438\u043a\u0430 ROC-AUC \u0447\u0443\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u0443\u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u043a\u0440\u0438\u0432\u044b\u0445 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.<\/p>\n<h3>XGBoost<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 xgboost \u0438 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 xgboost \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">xgb_clf = XGBClassifier(random_state=13)  xgb_clf.fit(X_train, y_train) y_pred = xgb_clf.predict(X_test)  results['XGBoost'] = quality(y_test, y_pred)<\/code><\/pre>\n<pre><code>     Accuracy: 0.786     Precision: 0.621        Recall: 0.503      F1-score: 0.556           AUC: 0.696<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.786<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.621<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.503<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.556<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.696<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0418 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c baseline \u0434\u043b\u044f xgboost&#8230;<\/p>\n<h4>XGBoost: \u043a\u0440\u0438\u0432\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432<\/h4>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043a\u0440\u0438\u0432\u0443\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 n_estimators<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">n_trees = [1, 3, 5, 10, 50, 100, 200, 300, 400, 500] quals_train = [] quals_test = [] for n in n_trees:     clf = XGBClassifier(n_estimators=n, random_state=13)     clf.fit(X_train, y_train)     q_train = roc_auc_score(y_train, clf.predict(X_train))     q_test = roc_auc_score(y_test, clf.predict(X_test))      quals_train.append(q_train)     quals_test.append(q_test)  plt.figure(figsize=(8, 5)) plt.plot(n_trees, quals_train, marker='.', label='train') plt.plot(n_trees, quals_test, marker='.', label='test') plt.xlabel('Number of trees') plt.ylabel('AUC-ROC') plt.title('XGBoost Validation Curve') plt.legend()  plt.show()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/210\/c74\/8fe\/210c748fea1c3fbaa8c066344329b4d7.png\" alt=\"png\" title=\"\" width=\"691\" height=\"468\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/210\/c74\/8fe\/210c748fea1c3fbaa8c066344329b4d7.png\"\/><\/figure>\n<p>\u041e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438<\/p>\n<pre><code class=\"python\">sorted(list(zip(quals_test, n_trees)), reverse=True)<\/code><\/pre>\n<pre><code>    [(0.7062379385699934, 10),      (0.7055296442187416, 50),      (0.6958172082730621, 100),      (0.6847365156520968, 200),      (0.6816628288735529, 300),      (0.6809401499903911, 500),      (0.6796489944061432, 400),      (0.6699756843872593, 5),      (0.6428717739810286, 3),      (0.5, 1)]<\/code><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043b\u044f n_estimators = 10<\/p>\n<h4>XGBoost: \u043a\u0440\u0438\u0432\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/h4>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u043b\u0438\u044f\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 learning rate \u043d\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u0441\u043a\u043b\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u044b\u0445 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">for learning_rate in [1, 0.5, 0.3, 0.2, 0.1]:      xgb = XGBClassifier(n_estimators=150, learning_rate=learning_rate, random_state=13, verbose=-1).fit(X_train, y_train)      test_deviance = np.zeros((xgb.n_estimators,), dtype=np.float64)     for i in range(xgb.n_estimators):         y_pred_test = xgb.predict(X_test, iteration_range=(0,i))         test_deviance[i] = roc_auc_score(y_test, y_pred_test)      train_deviance = np.zeros((xgb.n_estimators,), dtype=np.float64)     for i in range(xgb.n_estimators):         y_pred_train = xgb.predict(X_train, iteration_range=(0,i))         train_deviance[i] = roc_auc_score(y_train, y_pred_train)      plt.figure()     plt.plot(test_deviance[1:], 'r', linewidth=2)     plt.plot(train_deviance[1:], 'g', linewidth=2)     plt.legend(['test', 'train'])          plt.title('XGBoost lr=%.1f, test roc-auc=%.3f, best_est=%d' % (learning_rate, test_deviance.max(), test_deviance.argmax()))     plt.xlabel('Number of trees')     plt.ylabel('Metric')<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8b7\/8e1\/350\/8b78e1350b100b37c3c4535e4b838936.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8b7\/8e1\/350\/8b78e1350b100b37c3c4535e4b838936.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/232\/5a9\/77e\/2325a977e2b23f82c58589ef5d0d9d6b.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/232\/5a9\/77e\/2325a977e2b23f82c58589ef5d0d9d6b.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/16c\/d83\/97c\/16cd8397c14b9123a4d326a90f98e498.png\" alt=\"png\" title=\"\" width=\"567\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/16c\/d83\/97c\/16cd8397c14b9123a4d326a90f98e498.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c59\/7c0\/aa0\/c597c0aa0e1298997ae7e21b773da59c.png\" alt=\"png\" title=\"\" width=\"567\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c59\/7c0\/aa0\/c597c0aa0e1298997ae7e21b773da59c.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/686\/42f\/c31\/68642fc31ee38c66a40a0321c13fd453.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/686\/42f\/c31\/68642fc31ee38c66a40a0321c13fd453.png\"\/><\/figure>\n<p>\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 ROC-AUC \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 learning rate (lr) \u0440\u0430\u0432\u043d\u043e\u043c 0.5 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u044d\u0442\u0430\u043f\u043e\u0432 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 (n_estimators) \u0440\u0430\u0432\u043d\u043e\u043c 10.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 lr=0.5, n_estimators=10<\/p>\n<pre><code class=\"python\">xgb_clf = XGBClassifier(n_estimators=10, learning_rate=0.5, random_state=13) xgb_clf.fit(X_train, y_train) y_pred = xgb_clf.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">results['XGBoost-VC'] = quality(y_test, y_pred)<\/code><\/pre>\n<pre><code>     Accuracy: 0.803     Precision: 0.661        Recall: 0.531      F1-score: 0.589           AUC: 0.716<\/code><\/pre>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.786<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.621<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.503<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.556<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.696<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.661<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.531<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.589<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b xgboost \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u043b\u0438\u0441\u044c.<\/p>\n<h4>XGBoost: \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0441\u0435\u0442\u043a\u0435 \u0441 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439<\/h4>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430\u043c \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0441\u0435\u0442\u043a\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GridSearchCV<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GridSearchCV<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\"># Define Gradient Boosting classifier with default parameters clf = XGBClassifier(random_state=13)  # Estimate grid of the classifier hyperparameters parameters = {'n_estimators':[10,50,100],               'max_depth':[1,2,3,5],               'learning_rate':[1,0.5,0.3]              }  # Define GridSearch parameters gs = GridSearchCV(clf,                 # Classifier object to optimize                   parameters,          # Grid of the hyperparameters                   scoring='roc_auc',   # Classification quality metric to optimize                   cv=5                 # Number of folds in KFolds cross-validation                  )  # Run Grid Search optimization gs.fit(X_train, y_train) gs.best_params_<\/code><\/pre>\n<pre><code>    {'learning_rate': 0.5, 'max_depth': 1, 'n_estimators': 50}<\/code><\/pre>\n<pre><code class=\"python\">pred_gs = gs.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">results['XGBoost-GS'] = quality(y_test, pred_gs)<\/code><\/pre>\n<pre><code>     Accuracy: 0.806     Precision: 0.668        Recall: 0.535      F1-score: 0.594           AUC: 0.719<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\">\n<\/td>\n<td>\n<p align=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.786<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.621<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.503<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.556<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.696<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.661<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.531<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.589<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.668<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.535<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.594<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GridSearchCV \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0435\u0449\u0435 \u0443\u043b\u0443\u0447\u0448\u0438\u043b\u0438\u0441\u044c \u0438 \u043f\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0435 ROC-AUC xgboost \u0432\u044b\u0448\u0435\u043b \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e.<\/p>\n<h3>LightGBM<\/h3>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a &#8212; \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 LightGBM \u0438, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187;, \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 LightGBM \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">lgbm_clf = LGBMClassifier(verbose=-1, random_state=13)  lgbm_clf.fit(X_train, y_train) y_pred = lgbm_clf.predict(X_test)  results['LightGBM'] = quality(y_test, y_pred)<\/code><\/pre>\n<pre><code>     Accuracy: 0.794     Precision: 0.643        Recall: 0.504      F1-score: 0.565           AUC: 0.702<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.786<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.621<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.503<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.556<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.696<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.661<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.531<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.589<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.668<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.535<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.594<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.794<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.643<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.504<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.565<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.702<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041d\u0443 \u0447\u0442\u043e \u0436, \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430&#8230;<\/p>\n<h4>LightGBM: \u043a\u0440\u0438\u0432\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432<\/h4>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043a\u0440\u0438\u0432\u0443\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 n_estimators<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">n_trees = [1, 3, 5, 10, 50, 100, 200, 300, 400, 500] quals_train = [] quals_test = [] for n in n_trees:     clf = LGBMClassifier(n_estimators=n, verbose=-1, random_state=13)     clf.fit(X_train, y_train)     q_train = roc_auc_score(y_train, clf.predict(X_train))     q_test = roc_auc_score(y_test, clf.predict(X_test))      quals_train.append(q_train)     quals_test.append(q_test)  plt.figure(figsize=(8, 5)) plt.plot(n_trees, quals_train, marker='.', label='train') plt.plot(n_trees, quals_test, marker='.', label='test') plt.xlabel('Number of trees') plt.ylabel('AUC-ROC') plt.title('LightGBM Validation Curve') plt.legend()  plt.show();<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5f2\/ebb\/91b\/5f2ebb91b2e7cbe2aebab9f1882f9d7e.png\" alt=\"png\" title=\"\" width=\"691\" height=\"468\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5f2\/ebb\/91b\/5f2ebb91b2e7cbe2aebab9f1882f9d7e.png\"\/><\/figure>\n<p>\u041e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438<\/p>\n<pre><code class=\"python\">sorted(list(zip(quals_test, n_trees)), reverse=True)<\/code><\/pre>\n<pre><code>    [(0.7075290941542413, 50),      (0.7015503073111397, 100),      (0.6927435214945183, 200),      (0.6884557802227645, 300),      (0.6865961479374308, 500),      (0.682139819951691, 400),      (0.6565635468343097, 10),      (0.5301488281209544, 5),      (0.5, 3),      (0.5, 1)]<\/code><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0447\u0438\u0441\u043b\u0430 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0440\u0430\u0432\u043d\u043e\u0433\u043e 50, \u043d\u043e \u043c\u044b \u0435\u0449\u0435 \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u0438 learning rate&#8230;<\/p>\n<h4>LightGBM: \u043a\u0440\u0438\u0432\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/h4>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u043b\u0438\u044f\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 learning_rate \u043d\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u0441\u043a\u043b\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u044b\u0445 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">for learning_rate in [1, 0.5, 0.3, 0.2, 0.1]:      lgb = LGBMClassifier(n_estimators=150, learning_rate=learning_rate, random_state=13, verbose=-1).fit(X_train, y_train)      test_deviance = np.zeros((lgb.n_estimators,), dtype=np.float64)     for i in range(lgb.n_estimators):         y_pred_test = lgb.predict(X_test, num_iteration=i)         test_deviance[i] = roc_auc_score(y_test, y_pred_test)      train_deviance = np.zeros((lgb.n_estimators,), dtype=np.float64)     for i in range(lgb.n_estimators):         y_pred_train = lgb.predict(X_train, num_iteration=i)         train_deviance[i] = roc_auc_score(y_train, y_pred_train)      plt.figure()     plt.plot(test_deviance[1:], 'r', linewidth=2)     plt.plot(train_deviance[1:], 'g', linewidth=2)     plt.legend(['test', 'train'])          plt.title('LightGBM lr=%.1f, test roc-auc=%.3f, best_est=%d' % (learning_rate, test_deviance.max(), test_deviance.argmax()))     plt.xlabel('Number of trees')     plt.ylabel('Metric')<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a25\/1e9\/d70\/a251e9d70df075450709afe8f318ad2d.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a25\/1e9\/d70\/a251e9d70df075450709afe8f318ad2d.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a3a\/8a2\/b04\/a3a8a2b04e64551cc496d6ca6b018ded.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a3a\/8a2\/b04\/a3a8a2b04e64551cc496d6ca6b018ded.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4db\/186\/340\/4db186340591f93b4cc26b6bef76a1bd.png\" alt=\"png\" title=\"\" width=\"567\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4db\/186\/340\/4db186340591f93b4cc26b6bef76a1bd.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/372\/837\/5c8\/3728375c8c5bfb1bb817e83c29699ee2.png\" alt=\"png\" title=\"\" width=\"567\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/372\/837\/5c8\/3728375c8c5bfb1bb817e83c29699ee2.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/799\/dc2\/f33\/799dc2f338d29ec7ae64e8104f03089d.png\" alt=\"png\" title=\"\" width=\"576\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/799\/dc2\/f33\/799dc2f338d29ec7ae64e8104f03089d.png\"\/><\/figure>\n<p>\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 ROC-AUC \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c learning rate \u0440\u0430\u0432\u043d\u044b\u043c 0.3 \u0438 n_estimators \u0440\u0430\u0432\u043d\u044b\u043c 12.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 lr=0.3, n_estimators=12<\/p>\n<pre><code class=\"python\">lgbm = LGBMClassifier(n_estimators=12, learning_rate=0.3, verbose=-1, random_state=13) lgbm.fit(X_train, y_train) y_pred = lgbm.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">results['LightGBM-VC'] = quality(y_test, y_pred)<\/code><\/pre>\n<pre><code>     Accuracy: 0.803     Precision: 0.664        Recall: 0.524      F1-score: 0.586           AUC: 0.714<\/code><\/pre>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.786<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.621<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.503<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.556<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.696<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.661<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.531<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.589<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.668<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.535<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.594<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.794<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.643<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.504<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.565<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.702<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.664<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.524<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.586<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.714<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0443\u043b\u0443\u0447\u0448\u0438\u043b\u0438\u0441\u044c.<\/p>\n<h4>LightGBM: \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GridSearchCV<\/h4>\n<p>\u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043f\u043e \u0441\u0435\u0442\u043a\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GridSearchCV<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GridSearchCV<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\"># Define Gradient Boosting classifier with default parameters clf = LGBMClassifier(verbose=-1, random_state=13)  # Estimate grid of the classifier hyperparameters parameters = {'n_estimators':[10,50,100,150],               'max_depth':[1,2,3,5],               'learning_rate':[1,0.5,0.3,0.2,0.1]              }  # Define GridSearch parameters gs = GridSearchCV(clf,                 # Classifier object to optimize                   parameters,          # Grid of the hyperparameters                   scoring='roc_auc',   # Classification quality metric to optimize                   cv=5                 # Number of folds in KFolds cross-validation                  )  # Run Grid Search optimization gs.fit(X_train, y_train) gs.best_params_<\/code><\/pre>\n<pre><code>    {'learning_rate': 0.2, 'max_depth': 1, 'n_estimators': 150}<\/code><\/pre>\n<pre><code class=\"python\">pred_gs = gs.predict(X_test) results['LightGBM-GS'] = quality(y_test, pred_gs)<\/code><\/pre>\n<pre><code>     Accuracy: 0.806     Precision: 0.669        Recall: 0.533      F1-score: 0.593           AUC: 0.719<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.786<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.621<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.503<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.556<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.696<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.661<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.531<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.589<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.668<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.535<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.594<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.794<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.643<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.504<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.565<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.702<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.664<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.524<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.586<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.714<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.669<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.533<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.593<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0430 GridSearchCV \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b LightGBM \u043f\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0435 ROC-AUC \u0441\u0440\u0430\u0432\u043d\u044f\u043b\u0438\u0441\u044c \u0441 xgboost &#8212; \u043f\u043b\u043e\u0442\u043d\u0430\u044f \u0431\u043e\u0440\u044c\u0431\u0430&#8230;<\/p>\n<h3>CatBoost<\/h3>\n<p>\u041d\u0430 \u0434\u0435\u0441\u0435\u0440\u0442 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 catboost \u043e\u0442 Yandex \u0438 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0446\u0435\u043d\u0438\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 &#171;\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438&#187;, \u0442\u043e \u0435\u0441\u0442\u044c, \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/p>\n<pre><code class=\"python\">catboost = CatBoostClassifier(logging_level='Silent', random_state=13)  catboost.fit(X_train, y_train) pred = catboost.predict(X_test)  results['Catboost'] = quality(y_test, pred)<\/code><\/pre>\n<pre><code>     Accuracy: 0.799     Precision: 0.656        Recall: 0.51      F1-score: 0.574           AUC: 0.706<\/code><\/pre>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.786<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.621<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.503<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.556<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.696<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.661<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.531<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.589<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.668<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.535<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.594<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.794<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.643<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.504<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.565<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.702<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.664<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.524<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.586<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.714<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.669<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.533<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.593<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Catboost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.799<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.656<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.510<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.574<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.706<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0418 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 catboost, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c<\/p>\n<h4>Catboost: \u043a\u0440\u0438\u0432\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432<\/h4>\n<p>\u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043d\u0430\u0447\u043d\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0441 \u043a\u0440\u0438\u0432\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 (n_estimators)<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f n_estimators<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">n_trees = [1, 3, 5, 10, 50, 100, 200, 300, 400, 500] quals_train = [] quals_test = [] for n in n_trees:     clf = CatBoostClassifier(iterations=n, logging_level='Silent', random_state=13)     clf.fit(X_train, y_train)     q_train = roc_auc_score(y_train, clf.predict(X_train))     q_test = roc_auc_score(y_test, clf.predict(X_test))      quals_train.append(q_train)     quals_test.append(q_test)  plt.figure(figsize=(8, 5)) plt.plot(n_trees, quals_train, marker='.', label='train') plt.plot(n_trees, quals_test, marker='.', label='test') plt.xlabel('Number of trees') plt.ylabel('AUC-ROC') plt.title('Catboost Validation Curve') plt.legend()  plt.show();<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6ac\/b82\/f38\/6acb82f3875d56fa687d48ab32cae1eb.png\" alt=\"png\" title=\"\" width=\"700\" height=\"468\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6ac\/b82\/f38\/6acb82f3875d56fa687d48ab32cae1eb.png\"\/><\/figure>\n<p>\u041e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438<\/p>\n<pre><code class=\"python\">sorted(list(zip(quals_test, n_trees)), reverse=True)<\/code><\/pre>\n<pre><code>    [(0.7219435458906844, 100),      (0.7210522802935365, 10),      (0.7113398443478572, 300),      (0.7110170554517953, 50),      (0.7071292041671413, 400),      (0.7028414628953876, 500),      (0.6999363628308299, 200),      (0.69259449774393, 5),      (0.680159932979589, 1),      (0.6744320123729989, 3)]<\/code><\/pre>\n<p>\u041b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f 100 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432<\/p>\n<h4>Catboost: \u043a\u0440\u0438\u0432\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/h4>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 learning rate \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u0441\u043a\u043b\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u044b\u0445 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f learning rate<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">n_iterations = 150 for learning_rate in [1, 0.5, 0.3, 0.2, 0.1]:      cbt = CatBoostClassifier(iterations=n_iterations, learning_rate=learning_rate, logging_level='Silent', random_state=13).fit(X_train, y_train)          test_deviance = np.zeros((n_iterations,), dtype=np.float64)     for i, y_pred in enumerate(cbt.staged_predict(X_test, prediction_type='Class', ntree_start=0, ntree_end=i)):         test_deviance[i] = roc_auc_score(y_test, y_pred)          train_deviance = np.zeros((n_iterations,), dtype=np.float64)     for i, y_pred in enumerate(cbt.staged_predict(X_train, prediction_type='Class', ntree_start=0, ntree_end=i)):         train_deviance[i] = roc_auc_score(y_train, y_pred)      plt.figure()     plt.plot(test_deviance, 'r', linewidth=2)     plt.plot(train_deviance, 'g', linewidth=2)     plt.legend(['test', 'train'])          plt.title('Catboost lr=%.1f, test roc-auc=%.3f, best_est=%d' % (learning_rate, test_deviance.max(), test_deviance.argmax()+1))     plt.xlabel('Number of trees')     plt.ylabel('Metric')<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/561\/4eb\/ee0\/5614ebee03e57dd5c53e09e83cb4be06.png\" alt=\"png\" title=\"\" width=\"567\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/561\/4eb\/ee0\/5614ebee03e57dd5c53e09e83cb4be06.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cc3\/adf\/9f8\/cc3adf9f8cdd5b4018de572af23579e5.png\" alt=\"png\" title=\"\" width=\"567\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cc3\/adf\/9f8\/cc3adf9f8cdd5b4018de572af23579e5.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/46a\/691\/03d\/46a69103d59b18dc1cb1e243183b57c4.png\" alt=\"png\" title=\"\" width=\"567\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/46a\/691\/03d\/46a69103d59b18dc1cb1e243183b57c4.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b20\/973\/93b\/b2097393bb2e9e656b281350f16d1380.png\" alt=\"png\" title=\"\" width=\"567\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b20\/973\/93b\/b2097393bb2e9e656b281350f16d1380.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7b7\/10f\/f05\/7b710ff05591b20778cab374f1dcef9a.png\" alt=\"png\" title=\"\" width=\"567\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7b7\/10f\/f05\/7b710ff05591b20778cab374f1dcef9a.png\"\/><\/figure>\n<p>\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 ROC-AUC \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 learning rate (lr) \u0440\u0430\u0432\u043d\u043e\u043c 0.1 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u044d\u0442\u0430\u043f\u043e\u0432 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 (n_estimators) \u0440\u0430\u0432\u043d\u043e\u043c 98.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u043c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 lr=0.1, n_estimators=98<\/p>\n<pre><code class=\"python\">catboost = CatBoostClassifier(iterations=98, learning_rate=0.1, logging_level='Silent', random_state=13) catboost.fit(X_train, y_train) pred = catboost.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">results['Catboost-VC'] = quality(y_test, pred)<\/code><\/pre>\n<pre><code>     Accuracy: 0.81     Precision: 0.677        Recall: 0.545      F1-score: 0.604           AUC: 0.726<\/code><\/pre>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.786<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.621<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.503<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.556<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.696<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.661<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.531<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.589<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.668<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.535<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.594<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.794<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.643<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.504<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.565<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.702<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.664<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.524<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.586<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.714<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.669<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.533<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.593<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Catboost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.799<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.656<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.510<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.574<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.706<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Catboost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.810<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.677<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.545<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.604<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.726<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0418 \u0443 \u043d\u0430\u0441 \u0441\u043c\u0435\u043d\u0430 \u043b\u0438\u0434\u0435\u0440\u0430 &#8212; catboost \u0432\u044b\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043f\u0435\u0440\u0435\u0434 !<\/p>\n<h4>Catboost: \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0441\u0435\u0442\u043a\u0435 \u0441 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439<\/h4>\n<p>\u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043f\u043e \u0441\u0435\u0442\u043a\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GridSearchCV<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 catboost \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GridSearchCV<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\"># Define Gradient Boosting classifier with default parameters clf = CatBoostClassifier(logging_level='Silent', random_state=13)  # Estimate grid of the classifier hyperparameters parameters = {'n_estimators':[10,50,100,150],               'max_depth':[1,2,3,5],               'learning_rate':[1,0.5,0.3,0.2,0.1]              }  # Define GridSearch parameters gs = GridSearchCV(clf,                 # Classifier object to optimize                   parameters,          # Grid of the hyperparameters                   scoring='roc_auc',   # Classification quality metric to optimize                   cv=5                 # Number of folds in KFolds cross-validation                  )  # Run Grid Search optimization gs.fit(X_train, y_train) gs.best_params_<\/code><\/pre>\n<pre><code>    {'learning_rate': 0.1, 'max_depth': 3, 'n_estimators': 100}<\/code><\/pre>\n<pre><code class=\"python\">pred_gs = gs.predict(X_test) results['CatBoost-GS'] = quality(y_test, pred_gs)<\/code><\/pre>\n<pre><code>     Accuracy: 0.808     Precision: 0.676        Recall: 0.533      F1-score: 0.596           AUC: 0.72<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"python\">pd.DataFrame(results, index = ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']).T<\/code><\/pre>\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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.786<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.621<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.503<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.556<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.696<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.661<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.531<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.589<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.668<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.535<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.594<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.794<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.643<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.504<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.565<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.702<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.664<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.524<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.586<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.714<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.669<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.533<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.593<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Catboost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.799<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.656<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.510<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.574<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.706<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Catboost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.810<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.677<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.545<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.604<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.726<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Catboost-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.676<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.533<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.720<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0418 \u043d\u0430 GridSearchCV catboost \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0447\u0443\u0442\u044c \u0445\u0443\u0436\u0435&#8230;<\/p>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438 \u0432\u044b\u0432\u043e\u0434\u044b<\/h3>\n<h4>\u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043b\u0438\u0434\u0435\u0440\u043e\u0432<\/h4>\n<p>\u041e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u0442\u0443\u0440\u043d\u0438\u0440\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u043c\u0435\u0442\u0440\u0438\u043a\u0438 ROC-AUC<\/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=\"center\"><strong>Accuracy<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>Precision<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\"><strong>Recall<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>F1-Score<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>AUC<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Catboost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.810<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.677<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.545<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.604<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.726<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.809<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.684<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.528<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.72<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Catboost-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.676<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.533<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.596<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.720<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.668<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.535<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.594<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.806<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.669<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.533<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.593<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.719<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn-GS<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.808<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.681<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.591<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.717<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Sklearn<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.807<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.678<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.522<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.59<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.661<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.531<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.589<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.716<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM-VC<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.803<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.664<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.524<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.586<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.714<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>Catboost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.799<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.656<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.510<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.574<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.706<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>LightGBM<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.794<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.643<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.504<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.565<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.702<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><strong>XGBoost<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\">0.786<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.621<\/p>\n<\/td>\n<td data-colwidth=\"117\" width=\"117\">\n<p align=\"center\">0.503<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.556<\/p>\n<\/td>\n<td>\n<p align=\"center\">0.696<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0418 \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u043e\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f catboost !<\/p>\n<h4>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432<\/h4>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043e\u0434\u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0441\u0442\u043e\u0438\u0442 \u0442\u044b\u0441\u044f\u0447\u0438 \u0441\u043b\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">plt.figure(figsize=(15, 6)) x = np.arange(5)  for key, value in results.items():     plt.plot(x, results[key], marker='x', label=key);      plt.xticks(x, ['Accuracy', 'Precision', 'Recall', 'F1-score', 'AUC']); plt.ylim(0.49, 0.82) plt.legend(prop ={'size': 10});<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/764\/13e\/255\/76413e25568f1c2d9d9e843d3363fc46.png\" alt=\"png\" title=\"\" width=\"1223\" height=\"505\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/764\/13e\/255\/76413e25568f1c2d9d9e843d3363fc46.png\"\/><\/figure>\n<h4>\u0412\u044b\u0432\u043e\u0434\u044b<\/h4>\n<ul>\n<li>\n<p>\u0418\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Sklearn, \u043f\u043e\u0442\u043e\u043c Catboost, \u0437\u0430\u0442\u0435\u043c LightGBM \u0438 XGBoost \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0448\u0435\u043b Catboost, Sklearn \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043b\u0441\u044f \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0435, \u0430 \u0442\u0440\u0435\u0442\u044c\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u043b\u0438 XGBoost \u0438 LightGBM \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0442\u0441\u0442\u0430\u0432\u0430\u043d\u0438\u0435\u043c \u043e\u0442 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 );<\/p>\n<\/li>\n<li>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0431\u043b\u0438\u0437\u043e\u0441\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b \u0438 \u0432\u0441\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\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\/869372\/\"> https:\/\/habr.com\/ru\/articles\/869372\/<\/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! \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u043e \u0438\u0442\u043e\u0433\u0430\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u0443\u0440\u0441\u0435 <a href=\"https:\/\/otus.pw\/N5rq\/\">Otus ML Basic<\/a> \u0438 \u0432 \u043d\u0435\u0439 \u044f \u043f\u0440\u043e\u0432\u0435\u0434\u0443 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430. \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u0443\u0441\u0442\u0438\u043d\u0433, \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b ? \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u0438 \u0435\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043e\u043c. \u0411\u0443\u0441\u0442\u0438\u043d\u0433 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0442\u043e \u0438\u0437 \u043d\u0438\u0445 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c\u0438 \u0442\u0443\u0440\u043d\u0438\u0440\u0430, \u0447\u044c\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u0431\u0443\u0434\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>Sklearn;<\/p>\n<\/li>\n<li>\n<p>XGBoost;<\/p>\n<\/li>\n<li>\n<p>LightGBM;<\/p>\n<\/li>\n<li>\n<p>Catboost;<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u0434\u0435\u044e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f &#171;\u0441\u0438\u043b\u044c\u043d\u043e\u0439&#187; \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 (\u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0439), \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445  \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0438\u0448\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u0438\u043c \u0432\u044b\u0448\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u044f. \u041e\u0431\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0441\u0442\u0440\u043e\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043d\u0438\u044f;<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0430 <a href=\"https:\/\/www.kaggle.com\/datasets\/blastchar\/telco-customer-churn\">\u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/a> \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043e\u0442\u0442\u043e\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0442\u0435\u043b\u0435\u043a\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u041f\u043e\u043b\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e jupyter \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0430 \u0432\u0441\u0435 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/DzenGarden\/Otus-ML\/blob\/main\/articles\/ensemble-of-models\/boosting-algorithms.ipynb\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import numpy as np  import pandas as pd  import seaborn as sns  import matplotlib.pyplot as plt  from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score from sklearn.preprocessing import LabelEncoder, StandardScaler  from sklearn.ensemble import GradientBoostingClassifier from xgboost import XGBClassifier from lightgbm import LGBMClassifier from catboost import CatBoostClassifier  from sklearn.model_selection import GridSearchCV  import warnings warnings.filterwarnings(\"ignore\")<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/p>\n<pre><code class=\"python\">df = pd.read_csv('data\/WA_Fn-UseC_-Telco-Customer-Churn.csv', index_col=0) df.info()<\/code><\/pre>\n<pre><code>    Index: 7043 entries, 7590-VHVEG to 3186-AJIEK     Data columns (total 20 columns):      #   Column            Non-Null Count  Dtype       ---  ------            --------------  -----        0   gender            7043 non-null   object       1   SeniorCitizen     7043 non-null   int64        2   Partner           7043 non-null   object       3   Dependents        7043 non-null   object       4   tenure            7043 non-null   int64        5   PhoneService      7043 non-null   object       6   MultipleLines     7043 non-null   object       7   InternetService   7043 non-null   object       8   OnlineSecurity    7043 non-null   object       9   OnlineBackup      7043 non-null   object       10  DeviceProtection  7043 non-null   object       11  TechSupport       7043 non-null   object       12  StreamingTV       7043 non-null   object       13  StreamingMovies   7043 non-null   object       14  Contract          7043 non-null   object       15  PaperlessBilling  7043 non-null   object       16  PaymentMethod     7043 non-null   object       17  MonthlyCharges    7043 non-null   float64      18  TotalCharges      7043 non-null   object       19  Churn             7043 non-null   object      dtypes: float64(1), int64(2), object(17)     memory usage: 1.1+ MB<\/code><\/pre>\n<p>\u0412 \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c 3 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0438\u0437 20 \u0438\u043c\u0435\u044e\u0442 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u0442\u0438\u043f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0432 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h3>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"python\">df.isna().sum()<\/code><\/pre>\n<pre><code>    gender              0     SeniorCitizen       0     Partner             0     Dependents          0     tenure              0     PhoneService        0     MultipleLines       0     InternetService     0     OnlineSecurity      0     OnlineBackup        0     DeviceProtection    0     TechSupport         0     StreamingTV         0     StreamingMovies     0     Contract            0     PaperlessBilling    0     PaymentMethod       0     MonthlyCharges      0     TotalCharges        0     Churn               0     dtype: int64<\/code><\/pre>\n<p>\u041f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u0442 \u0438 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0435\u0441\u0442\u044c 17 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<pre><code>    Index(['gender', 'Partner', 'Dependents', 'PhoneService', 'MultipleLines',            'InternetService', 'OnlineSecurity', 'OnlineBackup', 'DeviceProtection',            'TechSupport', 'StreamingTV', 'StreamingMovies', 'Contract',            'PaperlessBilling', 'PaymentMethod', 'TotalCharges', 'Churn'],           dtype='object')<\/code><\/pre>\n<p><code> <\/code>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<\/p>\n<pre><code class=\"python\">df.nunique()<\/code><\/pre>\n<pre><code>    gender                 2     SeniorCitizen          2     Partner                2     Dependents             2     tenure                73     PhoneService           2     MultipleLines          3     InternetService        3     OnlineSecurity         3     OnlineBackup           3     DeviceProtection       3     TechSupport            3     StreamingTV            3     StreamingMovies        3     Contract               3     PaperlessBilling       2     PaymentMethod          4     MonthlyCharges      1585     TotalCharges        6531     Churn                  2     dtype: int64<\/code><\/pre>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0437\u0430\u043c\u0435\u043d\u044b \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 1\/0<\/p>\n<details class=\"spoiler\">\n<summary> \u041a\u043e\u0434 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 <\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">bin_cat_cols_list = [] for index, value in df.nunique().items():       if value == 2:             bin_cat_cols_list.append(index)             print(f\"Index : {index}, Value : {value}\") <\/code><\/pre>\n<pre><code>    Index : gender, Value : 2     Index : SeniorCitizen, Value : 2     Index : Partner, Value : 2     Index : Dependents, Value : 2     Index : PhoneService, Value : 2     Index : PaperlessBilling, Value : 2     Index : Churn, Value : 2<\/code><\/pre>\n<pre><code class=\"python\">for col in bin_cat_cols_list:     print(col, df[col].unique())<\/code><\/pre>\n<pre><code>    gender ['Female' 'Male']     SeniorCitizen [0 1]     Partner ['Yes' 'No']     Dependents ['No' 'Yes']     PhoneService ['No' 'Yes']     PaperlessBilling ['Yes' 'No']     Churn ['No' 'Yes']<\/code><\/pre>\n<p>\u0430\u0442\u0440\u0438\u0431\u0443\u0442 SeniorCitizen \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 0\/1, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u043c \u0435\u0433\u043e \u0438\u0437 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/p>\n<pre><code class=\"python\">bin_cat_cols_list.remove('SeniorCitizen')  for col in bin_cat_cols_list:     print(col, df[col].unique())<\/code><\/pre>\n<pre><code>    gender ['Female' 'Male']     Partner ['Yes' 'No']     Dependents ['No' 'Yes']     PhoneService ['No' 'Yes']     PaperlessBilling ['Yes' 'No']     Churn ['No' 'Yes']<\/code><\/pre>\n<p>\u0418\u0442\u043e\u0433\u043e, \u0443 \u043d\u0430\u0441 6 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 &#8212; \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 0\/1<\/p>\n<pre><code class=\"python\">g_dict = {'Female':0, 'Male':1} df['gender'] = df['gender'].map(g_dict)<\/code><\/pre>\n<pre><code class=\"python\">yn_dict = {'Yes':1, 'No':0} for col in bin_cat_cols_list[1:]:     df[col] = df[col].map(yn_dict)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u043e \u0438\u0442\u043e\u0433\u0430\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<\/p>\n<pre><code class=\"python\">df.info()<\/code><\/pre>\n<pre><code>    Index: 7043 entries, 7590-VHVEG to 3186-AJIEK     Data columns (total 20 columns):      #   Column            Non-Null Count  Dtype       ---  ------            --------------  -----        0   gender            7043 non-null   int64        1   SeniorCitizen     7043 non-null   int64        2   Partner           7043 non-null   int64        3   Dependents        7043 non-null   int64        4   tenure            7043 non-null   int64        5   PhoneService      7043 non-null   int64        6   MultipleLines     7043 non-null   object       7   InternetService   7043 non-null   object       8   OnlineSecurity    7043 non-null   object       9   OnlineBackup      7043 non-null   object       10  DeviceProtection  7043 non-null   object       11  TechSupport       7043 non-null   object       12  StreamingTV       7043 non-null   object       13  StreamingMovies   7043 non-null   object       14  Contract          7043 non-null   object       15  PaperlessBilling  7043 non-null   int64        16  PaymentMethod     7043 non-null   object       17  MonthlyCharges    7043 non-null   float64      18  TotalCharges      7043 non-null   object       19  Churn             7043 non-null   int64       dtypes: float64(1), int64(8), object(11)     memory usage: 1.1+ MB<\/code><\/pre>\n<p>\u041f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u043c\u0438\u0441\u044f 11 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u0438 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f TotalCharges \u043a \u0442\u0438\u043f\u0443 float<\/p>\n<pre><code class=\"python\">df['TotalCharges'] = pd.to_numeric(df['TotalCharges'], errors='coerce') df.isna().sum()<\/code><\/pre>\n<pre><code>    gender               0     SeniorCitizen        0     Partner              0     Dependents           0     tenure               0     PhoneService         0     MultipleLines        0     InternetService      0     OnlineSecurity       0     OnlineBackup         0     DeviceProtection     0     TechSupport          0     StreamingTV          0     StreamingMovies      0     Contract             0     PaperlessBilling     0     PaymentMethod        0     MonthlyCharges       0     TotalCharges        11     Churn                0     dtype: int64<\/code><\/pre>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c 11 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 Total Charges, \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u043c \u0438\u0445 \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"python\">df.dropna(inplace = True)<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c LabelEncoder \u043f\u0430\u043a\u0435\u0442\u0430 sklearn<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">obj_cols = df.select_dtypes(include='object').columns  for col in obj_cols:     print(col, df[col].unique())<\/code><\/pre>\n<pre><code>    MultipleLines ['No phone service' 'No' 'Yes']     InternetService ['DSL' 'Fiber optic' 'No']     OnlineSecurity ['No' 'Yes' 'No internet service']     OnlineBackup ['Yes' 'No' 'No internet service']     DeviceProtection ['No' 'Yes' 'No internet service']     TechSupport ['No' 'Yes' 'No internet service']     StreamingTV ['No' 'Yes' 'No internet service']     StreamingMovies ['No' 'Yes' 'No internet service']     Contract ['Month-to-month' 'One year' 'Two year']     PaymentMethod ['Electronic check' 'Mailed check' 'Bank transfer (automatic)'      'Credit card (automatic)']<\/code><\/pre>\n<pre><code class=\"python\">label_encoder = LabelEncoder()  for col in obj_cols:     df[col] = label_encoder.fit_transform(df[col])  for col in obj_cols:     print(col, df[col].unique())<\/code><\/pre>\n<pre><code><\/code><\/pre>\n<\/div>\n<\/details>\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-442784","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/442784","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=442784"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/442784\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=442784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=442784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=442784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}