{"id":349608,"date":"2023-06-30T15:01:14","date_gmt":"2023-06-30T15:01:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=349608"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=349608","title":{"rendered":"<span>\u041f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438 \u0442\u0443\u0440\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430<\/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\/w1560\/getpro\/habr\/upload_files\/736\/d69\/499\/736d69499eb2dc4f52949a58685728bc.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/736\/d69\/499\/736d69499eb2dc4f52949a58685728bc.png\"\/><\/figure>\n<div class=\"persona\" persona=\"true\"><img decoding=\"async\" persona=\"true\" class=\"image persona__image\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/be5\/447\/f00\/be5447f00816000e2aa2bf956c6cb81c.jpg\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/be5\/447\/f00\/be5447f00816000e2aa2bf956c6cb81c.jpg\" data-blurred=\"true\"\/><\/p>\n<h5 class=\"persona__heading\" persona=\"true\">\u0410\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438: Alieva Natalie<\/h5>\n<p>\u0412\u044b\u043f\u0443\u0441\u043a\u043d\u0438\u0446\u0430 OTUS<\/p>\n<\/div>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<strong> <\/strong>\u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0430\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438 \u0442\u0443\u0440\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 ML, \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u043a\u0443\u0440\u0441\u0435 Machine Learning. Basic \u043e\u0442 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u0434\u043b\u044f IT-\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432 OTUS.\u00a0<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u044f \u0431\u0440\u0430\u043b\u0430 \u0441 Kaggle:\u00a0 <a href=\"https:\/\/www.kaggle.com\/datasets\/sellingstories\/travel-company-insurance-prediction\"><u>https:\/\/www.kaggle.com\/datasets\/sellingstories\/travel-company-insurance-prediction<\/u><\/a> . <\/p>\n<p>\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043c\u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u043f\u043e \u0434\u0432\u0443\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c:<\/p>\n<ul>\n<li>\n<p> \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u043b\u0438\u0441\u044c \u0434\u0432\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430: \u043e\u0434\u0438\u043d \u0441 \u0446\u0435\u043b\u0435\u0432\u044b\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c, \u0432\u0442\u043e\u0440\u043e\u0439 \u2013 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e. <\/p>\n<\/li>\n<li>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u0440\u0438 \u0431\u0435\u0433\u043b\u043e\u043c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0435 \u0442\u0430\u043a\u0430\u044f \u0443\u0436 \u0438 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438\u043c\u0435\u044e\u0442 \u043d\u0438\u0437\u043a\u0443\u044e \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044e, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0431\u043e\u0440\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.\u00a0 <\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0430, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0448\u0430\u043d\u0441 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f, \u043d\u043e \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0438\u043b\u044b \u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u044c\u0438, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043b\u0430 \u043a \u0440\u0430\u0431\u043e\u0442\u0435.\u00a0 \u042f\u0437\u044b\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Python, \u0441\u0440\u0435\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Jupiter Notebook.\u00a0<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441 \u0446\u0435\u043b\u0435\u0432\u044b\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c, \u044f \u043e\u0431\u0443\u0447\u0438\u043b\u0430 10 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0435\u043b\u0430\u043b\u0430 \u043f\u043e\u0434\u0431\u043e\u0440 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0430 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430. \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0438 (<em>f1-score<\/em>, <em>auc-roc-score<\/em>), \u044f \u0432\u044b\u0431\u0440\u0430\u043b\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u0434\u0430\u043b\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0431\u0435\u0437 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438.\u00a0<\/p>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0438 \u043d\u0438\u0437\u043a\u043e\u0439 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0435\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0432\u0441\u0435 \u043c\u043e\u0438 \u0443\u0445\u0438\u0449\u0440\u0435\u043d\u0438\u044f \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c \u0438 \u043f\u043e\u0434\u0431\u043e\u0440\u0443 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c, \u0446\u0435\u043b\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u2013 \u0437\u043d\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u044b, \u043d\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u043b\u0438\u0431\u043e \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043b\u0438\u0431\u043e \u043f\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c.\u00a0<\/p>\n<h2>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c \u21161\u00a0<\/h2>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">import numpy as np import numpy.linalg as la import matplotlib import matplotlib.pyplot as plt import pandas as pd import seaborn as sns sns.set_style('darkgrid')  import plotly.express as px  from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from sklearn import datasets from sklearn import preprocessing from sklearn.preprocessing import StandardScaler from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score  %matplotlib inline np.random.seed(123)  import warnings warnings.filterwarnings(\"ignore\")<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437. \u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 9 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0441\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435.\u00a0<\/p>\n<pre><code class=\"python\">data = pd.read_csv('Travel_Company_Old_Clients.csv', sep = ';') data.head()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d3f\/3bc\/4dd\/d3f3bc4ddf9bd3e4336ddb8a95851c4c.png\" width=\"974\" height=\"170\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d3f\/3bc\/4dd\/d3f3bc4ddf9bd3e4336ddb8a95851c4c.png\"\/><\/figure>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432<\/p>\n<ol>\n<li>\n<p>Age &#8212; Age Of The Customer;<\/p>\n<\/li>\n<li>\n<p>Employment Type &#8212; The Sector In Which Customer Is Employed;<\/p>\n<\/li>\n<li>\n<p>GraduateOrNot &#8212; Whether The Customer Is College Graduate Or Not;<\/p>\n<\/li>\n<li>\n<p>AnnualIncome &#8212; The Yearly Income Of The Customer In Indian Rupees;<\/p>\n<\/li>\n<li>\n<p>FamilyMembers &#8212; Number Of Members In Customer&#8217;s Family;<\/p>\n<\/li>\n<li>\n<p>ChronicDisease &#8212; Whether The Customer Suffers From Any Major Disease Or Conditions Like Diabetes\/High BP or Asthama,etc.;<\/p>\n<\/li>\n<li>\n<p>FrequentFlyer &#8212; Derived Data Based On Customer&#8217;s History Of Booking Air Tickets On Atleast 4 Different Instances In The Last 2 Years 2017-2019;<\/p>\n<\/li>\n<li>\n<p>EverTravelledAbroad &#8212; Has The Customer Ever Travelled To A Foreign Country;<\/p>\n<\/li>\n<li>\n<p>TravelInsurance (1st File Only) &#8212; Did The Customer Buy Travel Insurance Package During Introductory Offering.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430: 682 \u0441\u0442\u0440\u043e\u0447\u043a\u0438, 9 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.\u00a0<\/p>\n<pre><code class=\"python\">data.shape<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b0f\/937\/7f8\/b0f9377f87af41b9f0ac828a36aed47b.png\" width=\"96\" height=\"32\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b0f\/937\/7f8\/b0f9377f87af41b9f0ac828a36aed47b.png\"\/><\/figure>\n<p>\u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 4 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430. \u041d\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.\u00a0<\/p>\n<pre><code class=\"python\">data.info()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6b8\/3d8\/a3c\/6b83d8a3cbb0b601fc94b92f9caabefb.png\" width=\"455\" height=\"321\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6b8\/3d8\/a3c\/6b83d8a3cbb0b601fc94b92f9caabefb.png\"\/><\/figure>\n<pre><code class=\"python\">data.isnull().sum()<\/code><\/pre>\n<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/392\/19f\/83b\/39219f83bdee87c3bc831b994ccd1590.png\" width=\"253\" height=\"226\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/392\/19f\/83b\/39219f83bdee87c3bc831b994ccd1590.png\"\/><\/figure>\n<p>\u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 113 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432. \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b, \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f 569 \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.\u00a0\u00a0<\/p>\n<pre><code class=\"python\">data.duplicated().sum()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/de1\/46b\/7a2\/de146b7a2b04200630d4cae72cd34504.png\" width=\"56\" height=\"28\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/de1\/46b\/7a2\/de146b7a2b04200630d4cae72cd34504.png\"\/><\/figure>\n<pre><code class=\"python\">data.drop_duplicates(inplace = True) data = data.reset_index(drop = True) data.info()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d26\/d01\/61f\/d26d0161f333077639dff99e42832389.png\" width=\"467\" height=\"335\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d26\/d01\/61f\/d26d0161f333077639dff99e42832389.png\"\/><\/figure>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438.\u00a0<\/p>\n<pre><code class=\"python\">data.hist(figsize=(20, 20))<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d9e\/682\/16f\/d9e68216ffefb13bb6aed460c508988b.png\" width=\"974\" height=\"314\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d9e\/682\/16f\/d9e68216ffefb13bb6aed460c508988b.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/670\/df2\/659\/670df2659fa7d82f44352647e93f3a76.png\" width=\"974\" height=\"309\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/670\/df2\/659\/670df2659fa7d82f44352647e93f3a76.png\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bb1\/771\/529\/bb1771529f9344e4574c690a26ec8e96.png\" width=\"451\" height=\"312\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bb1\/771\/529\/bb1771529f9344e4574c690a26ec8e96.png\"\/><\/figure>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0438 \u0435\u0433\u043e \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e \u0442\u0430\u0440\u0433\u0435\u0442\u0443. \u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 25 \u0434\u043e 35 \u043b\u0435\u0442. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 28 \u043b\u0435\u0442, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['Age'], hue=data['TravelInsurance']) # \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u0430\u044f \u0432 % data['Age'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/30f\/855\/f63\/30f855f6307121043b06adfb30fd43df.png\" width=\"199\" height=\"196\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/30f\/855\/f63\/30f855f6307121043b06adfb30fd43df.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3b7\/e77\/093\/3b7e770939546af44bfd28bb6eeafb4c.png\" width=\"530\" height=\"396\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3b7\/e77\/093\/3b7e770939546af44bfd28bb6eeafb4c.png\"\/><\/figure>\n<p>84% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438\u043c\u0435\u044e\u0442 \u0432\u044b\u0441\u0448\u0435\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u0430\u043a \u043b\u044e\u0434\u0438 \u0441 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0442\u0430\u043a \u0438 \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e\u0442 \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['GraduateOrNot'],hue=data['TravelInsurance']) data['GraduateOrNot'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2b4\/914\/73f\/2b491473f6e014ca9fd067a3aad09c45.png\" width=\"548\" height=\"474\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2b4\/914\/73f\/2b491473f6e014ca9fd067a3aad09c45.png\"\/><\/figure>\n<p>\u0421\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e\u0442 \u043f\u043e\u043a\u0443\u043f\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0441 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0434\u043e\u0445\u043e\u0434\u0430.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['AnnualIncome'],hue=data['TravelInsurance']) plt.xticks(rotation = 90) plt.show() data['AnnualIncome'].value_counts(normalize=True)*100<\/code><\/pre>\n<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3a9\/816\/1a4\/3a98161a4ad26a56f4554ab52da42b59.png\" width=\"596\" height=\"490\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3a9\/816\/1a4\/3a98161a4ad26a56f4554ab52da42b59.png\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ba0\/bce\/99d\/ba0bce99d288ae697b5457f5b7045e4a.png\" width=\"188\" height=\"200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ba0\/bce\/99d\/ba0bce99d288ae697b5457f5b7045e4a.png\"\/><\/figure>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432 \u0441\u0435\u043c\u044c\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442 3 \u0434\u043e 5 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041d\u0435 \u043f\u0440\u043e\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0442\u0430\u0432\u043e\u043c \u0441\u0435\u043c\u044c\u0438 \u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438.\u00a0<\/p>\n<pre><code>sns.countplot(x = data['FamilyMembers'],hue=data['TravelInsurance']) data['FamilyMembers'].value_counts(normalize=True)*100<\/code><\/pre>\n<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/582\/80d\/fbf\/58280dfbfb87d29e85f700949d88dcaa.png\" width=\"568\" height=\"595\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/582\/80d\/fbf\/58280dfbfb87d29e85f700949d88dcaa.png\"\/><\/figure>\n<p>\u0412\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0438\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0445\u0440\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0431\u043e\u043b\u0435\u0432\u0430\u043d\u0438\u0439 \u043b\u044e\u0434\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e\u0442 \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['ChronicDiseases'],hue=data['TravelInsurance']) data['ChronicDiseases'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e76\/f5e\/82c\/e76f5e82c3370943a5def8546d71ba9c.png\" width=\"564\" height=\"482\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e76\/f5e\/82c\/e76f5e82c3370943a5def8546d71ba9c.png\"\/><\/figure>\n<p>77% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0443\u0441\u043b\u0443\u0433\u0430\u043c\u0438 \u0430\u0432\u0438\u0430\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043b\u0435\u0442\u0435, \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['FrequentFlyer'],hue=data['TravelInsurance']) data['FrequentFlyer'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bdb\/1e0\/ecf\/bdb1e0ecfbd513c8e1b5b901f8cb47a9.png\" width=\"532\" height=\"464\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bdb\/1e0\/ecf\/bdb1e0ecfbd513c8e1b5b901f8cb47a9.png\"\/><\/figure>\n<p>80% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u044e\u0442 \u043f\u043e\u0435\u0437\u0434\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0440\u0430\u043d\u044b. \u041f\u043e\u0434\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0430\u0433\u0440\u0430\u043d\u0438\u0446\u0443, \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['EverTravelledAbroad'],hue=data['TravelInsurance']) data['EverTravelledAbroad'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/db5\/4d6\/b2b\/db54d6b2b76a46f8c7c8f5accbcffea2.png\" width=\"566\" height=\"484\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/db5\/4d6\/b2b\/db54d6b2b76a46f8c7c8f5accbcffea2.png\"\/><\/figure>\n<p>73% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u043d\u0435\u0433\u043e\u0441\u0443\u0434\u0430\u0440\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u043a\u0442\u043e\u0440\u0435. \u041e\u043d\u0438 \u0447\u0430\u0449\u0435 \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443, \u0447\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u044b, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0432 \u0433\u043e\u0441\u043a\u043e\u0440\u043f\u043e\u0440\u0430\u0446\u0438\u044f\u0445.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['Employment Type'],hue=data['TravelInsurance']) data['Employment Type'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/436\/c03\/a4a\/436c03a4a62e2d22b29d324858c3827c.png\" width=\"586\" height=\"497\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/436\/c03\/a4a\/436c03a4a62e2d22b29d324858c3827c.png\"\/><\/figure>\n<p>\u041f\u043e\u043a\u0443\u043f\u043a\u0430 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u2013 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a. 64% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043d\u0435 \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442.\u00a0\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['TravelInsurance'],hue=data['TravelInsurance']) data['TravelInsurance'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ced\/6c5\/8d8\/ced6c58d8bcc077bf2a26788b72b0584.png\" width=\"556\" height=\"464\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ced\/6c5\/8d8\/ced6c58d8bcc077bf2a26788b72b0584.png\"\/><\/figure>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e plotly. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u0432\u0430\u0440\u0442\u0438\u043b\u0438, \u043d\u0430\u043b\u0438\u0447\u0438\u0435\/\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432. \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432. \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438\u0437 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432\u044b\u0431\u0440\u043e\u0441\u044b, \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430\u0434 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044f\u043c\u0438.\u00a0<\/p>\n<pre><code class=\"python\">fig = px.histogram(data, x='Age', color='TravelInsurance', marginal = 'box') fig.show() <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/21c\/cb0\/99d\/21ccb099d26dc33e4635abd7a7f505f6.png\" width=\"974\" height=\"532\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/21c\/cb0\/99d\/21ccb099d26dc33e4635abd7a7f505f6.png\"\/><\/figure>\n<pre><code class=\"python\">fig = px.histogram(data, x='AnnualIncome', color='TravelInsurance', marginal = 'box') fig.show()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/af3\/017\/bfb\/af3017bfbc533456e1634beac1467e27.png\" width=\"974\" height=\"520\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/af3\/017\/bfb\/af3017bfbc533456e1634beac1467e27.png\"\/><\/figure>\n<pre><code class=\"python\">fig = px.histogram(data, x='FamilyMembers', color='TravelInsurance', marginal = 'box') fig.show()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5ba\/d14\/7fe\/5bad147fe69120497ef8eb93740fb499.png\" width=\"974\" height=\"520\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ba\/d14\/7fe\/5bad147fe69120497ef8eb93740fb499.png\"\/><\/figure>\n<\/p>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e seaborn. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0430\u0440\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f.\u00a0<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0442\u0443\u0440\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043d\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u0430\u0433\u0440\u0430\u043d\u0438\u0446\u0443, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0435, \u043a\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442 \u0435\u0437\u0434\u0438\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0440\u0430\u043d\u044b, \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u0438 \u0434\u043e\u0445\u043e\u0434\u0430. \u041a\u043b\u0438\u0435\u043d\u0442\u044b, \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u0443, \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u0438 \u043f\u0440\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0434\u043e\u0445\u043e\u0434\u0430.\u00a0\u00a0<\/p>\n<pre><code class=\"python\">sns.relplot(data=data, x='AnnualIncome', y='Age', hue='TravelInsurance', col='EverTravelledAbroad', palette='bright', height=4)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ee9\/8a3\/684\/ee98a3684a4e57d207797317d2f38bc3.png\" width=\"974\" height=\"428\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ee9\/8a3\/684\/ee98a3684a4e57d207797317d2f38bc3.png\"\/><\/figure>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0444\u0430\u043a\u0442 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f\/\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0445\u0440\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0431\u043e\u043b\u0435\u0432\u0430\u043d\u0438\u0439, \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430, \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043e\u0445\u043e\u0434\u0430.\u00a0<\/p>\n<pre><code class=\"python\">sns.relplot(data=data, x='AnnualIncome', y='Age', hue='TravelInsurance', col='ChronicDiseases', palette='bright', height=4)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9ba\/63b\/3f1\/9ba63b3f1dcf820ee28f3f4204e99078.png\" width=\"974\" height=\"415\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9ba\/63b\/3f1\/9ba63b3f1dcf820ee28f3f4204e99078.png\"\/><\/figure>\n<p>\u0414\u0430\u0436\u0435 \u043f\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0432\u044b\u0448\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u043c \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0442 \u043d\u0438\u0437\u043a\u043e\u0439 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0435\u0439. \u041d\u043e \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043f\u043e\u0437\u0436\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.\u00a0<\/p>\n<p>\u0410 \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438. \u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b Yes\/No, \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 1\/0.\u00a0<\/p>\n<p>\u041f\u0440\u0438\u0437\u043d\u0430\u043a Employment Type \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043d\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f: 149 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Government Sector \u0438 420 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Private Sector\/Self Employed. \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f, \u0442\u043e \u0438\u0437-\u0437\u0430 \u043d\u0435\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u0432\u0435\u0440\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u0438\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0432\u0435\u0441. \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u044d\u0442\u043e\u0439 \u043d\u0435\u0432\u0435\u0440\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e One Hot Encoding.\u00a0<\/p>\n<pre><code class=\"python\">data['GraduateOrNot'].unique()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/002\/20a\/77a\/00220a77a0972cc9ca6de923336f2183.png\" width=\"314\" height=\"33\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/002\/20a\/77a\/00220a77a0972cc9ca6de923336f2183.png\"\/><\/figure>\n<pre><code class=\"python\">data['FrequentFlyer'].unique()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9d6\/52a\/fc7\/9d652afc7904e907a1025d532b0d68e8.png\" width=\"314\" height=\"33\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9d6\/52a\/fc7\/9d652afc7904e907a1025d532b0d68e8.png\"\/><\/figure>\n<pre><code>data['EverTravelledAbroad'].unique()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/55e\/9d4\/082\/55e9d408239e9bb6e4a503a9854fd61c.png\" width=\"314\" height=\"33\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/55e\/9d4\/082\/55e9d408239e9bb6e4a503a9854fd61c.png\"\/><\/figure>\n<pre><code class=\"python\">data['Employment Type'].unique() print(data['Employment Type']. value_counts ()['Government Sector']) print(data['Employment Type']. value_counts ()['Private Sector\/Self Employed'])<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f0b\/fe5\/8dc\/f0bfe58dc27a309fd42da6f4927c1cb3.png\" width=\"666\" height=\"31\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f0b\/fe5\/8dc\/f0bfe58dc27a309fd42da6f4927c1cb3.png\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/59e\/ce9\/d71\/59ece9d71d19d4006c76010509560981.png\" width=\"44\" height=\"49\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/59e\/ce9\/d71\/59ece9d71d19d4006c76010509560981.png\"\/><\/figure>\n<pre><code class=\"python\">data['GraduateOrNot'] = data['GraduateOrNot'].apply(lambda x: 1 if x=='Yes' else 0) data['FrequentFlyer'] = data['FrequentFlyer'].apply(lambda x: 1 if x=='Yes' else 0) data['EverTravelledAbroad'] = data['EverTravelledAbroad'].apply(lambda x: 1 if x=='Yes' else 0)<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c One Hot Encoding \u0434\u043b\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 Employment Type. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>head()<\/code>.<\/p>\n<pre><code class=\"python\">from category_encoders import OneHotEncoder  enc = OneHotEncoder() enc.fit_transform(data[['Employment Type']]).head()<\/code><\/pre>\n<pre><code class=\"python\">data = data.drop(['Employment Type'], axis = 1).join(enc.fit_transform(data[['Employment Type']], axis = 0)) data.head()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0f4\/143\/06d\/0f414306d99528a6b4f9ba145f0417f6.png\" width=\"974\" height=\"181\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0f4\/143\/06d\/0f414306d99528a6b4f9ba145f0417f6.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432.\u00a0 \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c \u0438\u0437 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0439 \u0438 \u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u044b, \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u0443\u044e\u0442 \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u0430\u0431\u043e. \u0415\u0441\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0441 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438.\u00a0<\/p>\n<pre><code class=\"python\">data.describe()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/556\/474\/90c\/55647490c474acff1d3653d5d20a25d9.png\" width=\"974\" height=\"239\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/556\/474\/90c\/55647490c474acff1d3653d5d20a25d9.png\"\/><\/figure>\n<pre><code class=\"python\">data.corr()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/462\/03f\/c75\/46203fc755aa9e7180ca9fed7a573146.png\" width=\"974\" height=\"314\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/462\/03f\/c75\/46203fc755aa9e7180ca9fed7a573146.png\"\/><\/figure>\n<pre><code>plt.subplots(figsize=(10,7)) sns.heatmap(data.corr(), cbar=True, annot=True, square=True, fmt='.2f', annot_kws={'size': 10},\\             cmap=sns.color_palette(\"coolwarm\", 10000), vmin=-1, center=0) plt.show()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/479\/b3b\/c1a\/479b3bc1aaa2c8b8e1ea1f1adf5b1fd8.png\" width=\"974\" height=\"813\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/479\/b3b\/c1a\/479b3bc1aaa2c8b8e1ea1f1adf5b1fd8.png\"\/><\/figure>\n<p>\u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0433\u043e\u0442\u043e\u0432 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e.\u00a0 \u0420\u0430\u0437\u043e\u0431\u044c\u0435\u043c \u0435\u0433\u043e \u043d\u0430 X \u0438 \u0443.\u00a0<\/p>\n<pre><code class=\"python\">X = data.copy() X.drop(['TravelInsurance'], axis=1, inplace=True)  y = data['TravelInsurance']<\/code><\/pre>\n<p>\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043e\u043a <code>train<\/code>, <code>test<\/code>.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 42)  scaler = StandardScaler() X_train = scaler.fit_transform(X_train) X_test = scaler.transform(X_test)<\/code><\/pre>\n<pre><code class=\"python\">X_train.shape, X_test.shape, y_train.shape, y_test.shape<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2bc\/9ee\/c4f\/2bc9eec4f47b6889526904c522bf0e66.png\" width=\"292\" height=\"30\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2bc\/9ee\/c4f\/2bc9eec4f47b6889526904c522bf0e66.png\"\/><\/figure>\n<p>\u0414\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438: <code>accuracy_score<\/code>, <code>recision_score<\/code>, <code>recall_score<\/code>, <code>f1_score<\/code>, <code>roc_auc_score<\/code>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 <code>f1_score<\/code> \u0438 <code>roc_auc_score<\/code>, \u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score  def quality_report(prediction, actual):     print(\"Accuracy: {:.3f}\\nPrecision: {:.3f}\\nRecall: {:.3f}\\nf1_score: {:.3f}\".format(         accuracy_score(prediction, actual),         precision_score(prediction, actual),         recall_score(prediction, actual),         f1_score(prediction, actual)     ))<\/code><\/pre>\n<p><strong>\u041e\u0431\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439<\/strong>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u0445.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.neighbors import KNeighborsClassifier  knn = KNeighborsClassifier(n_neighbors=13) knn.fit(X_train, y_train) knn_predictions_y = knn.predict(X_test) ----------------------------------------------------------------------------------------------------------------------------------------- print(\"Train quality:\") quality_report(knn.predict(X_train), y_train) print(\"\\nTest quality:\") quality_report(knn.predict(X_test), y_test) <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9c7\/b85\/f0f\/9c7b85f0f618e8bc1bf08b8fb06a3551.png\" width=\"186\" height=\"252\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9c7\/b85\/f0f\/9c7b85f0f618e8bc1bf08b8fb06a3551.png\"\/><\/figure>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043e\u0448\u0438\u0431\u043e\u043a.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.metrics import confusion_matrix  cm = confusion_matrix(y_test, knn_predictions_y) cm <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/06c\/77d\/1b8\/06c77d1b84343953328d92c767787952.png\" width=\"254\" height=\"48\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/06c\/77d\/1b8\/06c77d1b84343953328d92c767787952.png\"\/><\/figure>\n<p>\u0414\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u0438\u043c \u0433\u0440\u0430\u0444\u0438\u043a Roc- Auc, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0435\u043c <code>roc_auc_score<\/code>.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.metrics import roc_auc_score import sklearn.metrics as metrics from sklearn.metrics import roc_curve  def roc_auc(model, X_test, y_test ):     y_scores = model.predict_proba(X_test)     fpr, tpr, thresh = roc_curve(y_test, y_scores[:,1], pos_label = 1)     roc_auc = metrics.auc(fpr, tpr)     plt.title('Receiver Operating Characteristic')     plt.plot(fpr, tpr, 'b', label = 'AUC = %0.2f' % roc_auc)     plt.legend(loc = 'lower right')     plt.plot([0, 1], [0, 1],'r--')     plt.ylabel('True Positive Rate')     plt.xlabel('False Positive Rate')     plt.show()<\/code><\/pre>\n<pre><code class=\"python\">roc_auc(knn, X_test, y_test )<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/03f\/eef\/837\/03feef83793ebccabe266aeb392e2b5a.png\" width=\"564\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/03f\/eef\/837\/03feef83793ebccabe266aeb392e2b5a.png\"\/><\/figure>\n<p>\u0412\u043e\u0442 \u043e\u043d, \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0441\u0442\u0438\u043d\u044b\u2026 \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0435 \u0441\u0430\u043c\u044b\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438.\u00a0<\/p>\n<p>\u041f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0441\u043f\u0443\u0441\u043a\u0430. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043b\u0443\u0447\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 k = 13.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.model_selection import GridSearchCV  def grid_optimization(model, parameters, X_train, y_train, X_test):     gs = GridSearchCV(model,               # Classifier object to optimize                       parameters,          # Grid of the hyperparameters                       scoring='accuracy',  # Claasification quality metric to optimize                       cv=5,                # Number of folds in KFolds cross-validation (CV)                       n_jobs=-1,                        verbose=True                      )      # Run Grid Search optimization     gs.fit(X_train, y_train)     print('Best parameters: ', gs.best_params_)         print('Best Accuracy Through Grid Search : {:.3f}'.format(gs.best_score_))<\/code><\/pre>\n<pre><code class=\"python\">knn = KNeighborsClassifier()  # Estimate grid of the classifier hyperparameters parameters = {'n_neighbors': [3,5,7,9,11,13,15,17,19,21,23,25,27,29,31]}  grid_optimization(knn, parameters, X_train, y_train, X_test)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/20e\/c1e\/973\/20ec1e973e52927fdc9363045c2aa4cf.png\" width=\"554\" height=\"75\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/20e\/c1e\/973\/20ec1e973e52927fdc9363045c2aa4cf.png\"\/><\/figure>\n<p>\u0421 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u043c\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.\u00a0\u00a0<\/p>\n<h3>\u041b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/h3>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u0431\u0443\u0447\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<pre><code class=\"python\">from sklearn.linear_model import LogisticRegression   lr = LogisticRegression(penalty = 'l2') lr.fit(X_train, y_train) lr_y_prediction = lr.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">print(\"Train quality:\") quality_report(lr.predict(X_train), y_train) print(\"\\nTest quality:\") quality_report(lr.predict(X_test), y_test)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3ed\/341\/ffd\/3ed341ffd44dfba7a6b5025597a227da.png\" width=\"168\" height=\"219\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3ed\/341\/ffd\/3ed341ffd44dfba7a6b5025597a227da.png\"\/><\/figure>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 Roc-Auc.\u00a0<\/p>\n<pre><code class=\"python\">cm = confusion_matrix(y_test, lr_y_prediction) cm<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a7f\/855\/6c0\/a7f8556c060a40b7c996c0e6139fb25b.png\" width=\"252\" height=\"43\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a7f\/855\/6c0\/a7f8556c060a40b7c996c0e6139fb25b.png\"\/><\/figure>\n<pre><code class=\"python\">roc_auc(lr, X_test, y_test )<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4c2\/036\/3d7\/4c20363d7af13d93e75324890ebf8572.png\" width=\"579\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4c2\/036\/3d7\/4c20363d7af13d93e75324890ebf8572.png\"\/><\/figure>\n<p>\u041f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u043c\u0435\u0442\u0440\u0438\u043a \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043d\u0435 \u0441\u0430\u043c\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c.\u00a0<\/p>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<pre><code class=\"python\">featureImportance = pd.DataFrame({'feature': X.columns,  'importance': lr.coef_[0]}) featureImportance<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1bd\/410\/41b\/1bd41041b57040166481e6c66c5ffdea.png\" width=\"344\" height=\"415\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1bd\/410\/41b\/1bd41041b57040166481e6c66c5ffdea.png\"\/><\/figure>\n<pre><code class=\"python\">featureImportance.set_index('feature', inplace=True) featureImportance.sort_values(['importance'], ascending=False, inplace=True) featureImportance['importance'].plot.bar()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b09\/6f7\/f8d\/b096f7f8df9fbd5900f7e2743c0c040f.png\" width=\"566\" height=\"594\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b09\/6f7\/f8d\/b096f7f8df9fbd5900f7e2743c0c040f.png\"\/><\/figure>\n<p>\u041f\u043e\u0434\u0431\u0438\u0440\u0430\u0435\u043c \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438.\u00a0<\/p>\n<pre><code class=\"python\">log_reg = LogisticRegression() parameters = {'penalty': ['l1', 'l2', 'elasticnet', None], 'C': [0.001, 0.01, 0.1, 1] } grid_optimization(log_reg, parameters, X_train, y_train, X_test)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/588\/da3\/81c\/588da381c735dfb917cb61c74b6b3c58.png\" width=\"594\" height=\"77\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/588\/da3\/81c\/588da381c735dfb917cb61c74b6b3c58.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043f\u043e\u0438\u0441\u043a \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e: \u043e\u0431\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0435\u043c \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.\u00a0<\/p>\n<h3>\u0414\u0435\u0440\u0435\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/h3>\n<p>\u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043d\u0435 \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432. \u0416\u0435\u043b\u0430\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043f\u0440\u0438\u0448\u043b\u043e \u043d\u0435 \u0441\u0440\u0430\u0437\u0443: \u0434\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0435\u0440\u0435\u0432\u0430, \u0443 \u043c\u0435\u043d\u044f \u0447\u0442\u043e-\u0442\u043e \u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b\u0430, \u0447\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u0448\u043d\u0438\u043c \u0438\u043c\u0435\u0442\u044c \u0432 \u0441\u0432\u043e\u0435\u043c \u0443\u0447\u0435\u0431\u043d\u043e\u043c \u0430\u0440\u0441\u0435\u043d\u0430\u043b\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432.\u00a0\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.tree import DecisionTreeClassifier  dt = DecisionTreeClassifier(max_depth=3, min_samples_leaf=10, min_samples_split=2, criterion='gini') dt.fit(X_train, y_train) dt_y_pred = dt.predict(X_test)<\/code><\/pre>\n<p>\u041a\u043e\u0434 \u043d\u0438\u0436\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442 \u0434\u0435\u0440\u0435\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.tree import export_text  tree_rules = export_text(dt, feature_names = list(X.columns)) print(tree_rules) <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3d6\/70e\/475\/3d670e47559720fcb29be14382b67857.png\" width=\"366\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3d6\/70e\/475\/3d670e47559720fcb29be14382b67857.png\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u043e \u0436\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0432 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0432\u0438\u0434\u0435. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438.\u00a0<\/p>\n<p><strong>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u21161<\/strong><\/p>\n<pre><code class=\"python\">fig = plt.figure(figsize=(20,6), dpi=80, facecolor='w', edgecolor='k') _ = tree.plot_tree(dt, feature_names=X.columns, class_names=True, filled=True)<\/code><\/pre>\n<p><strong>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u21162<\/strong><\/p>\n<pre><code class=\"python\">import os os.environ[\"PATH\"] += os.pathsep + \"C:\/Program Files\/Graphviz\/bin\/\" import graphviz # DOT data dot_data = tree.export_graphviz(dt, out_file=None,                                  feature_names=list(X.columns),                                   class_names=True,                                 filled=True)  # Draw graph graph = graphviz.Source(dot_data, format=\"png\")  graph<\/code><\/pre>\n<p>\u041a\u043e\u0434 \u043d\u0438\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0432 \u0432\u0438\u0434\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438.\u00a0<\/p>\n<pre><code class=\"python\">graph.render(\"decision_tree_graphivz\")<\/code><\/pre>\n<p><strong>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u21163<\/strong><\/p>\n<pre><code class=\"python\">from sklearn.tree import export_graphviz import os, graphviz,pydotplus  os.environ[\"PATH\"] += os.pathsep + 'C:\/Program Files (x86)\/Graphviz2.38\/bin\/' def plot_tree(model, cols, fname='temp_tree.png'):     dot_data = export_graphviz(model, filled=True, rounded=True, feature_names=cols, out_file=None)     pydot_graph = pydotplus.graph_from_dot_data(dot_data)     pydot_graph.write_png(fname)     img = plt.imread(fname)     plt.imshow(img)<\/code><\/pre>\n<pre><code class=\"python\">plt.figure(figsize=(25, 25)) plt.axis('off') plot_tree(dt, list(X.columns)) <\/code><\/pre>\n<p>\u0412\u043e \u0432\u0441\u0435\u0445 \u0442\u0440\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5ec\/4d2\/bdb\/5ec4d2bdb7773d7dceb1c9930be043fa.png\" width=\"974\" height=\"447\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ec\/4d2\/bdb\/5ec4d2bdb7773d7dceb1c9930be043fa.png\"\/><\/figure>\n<p>\u0422.\u043a. \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u044f \u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0431\u043e\u0439 \u0446\u0435\u043b\u044c \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u044c\u044f, \u0442\u043e \u0440\u0435\u0448\u0438\u043b\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.\u00a0\u00a0<\/p>\n<pre><code class=\"python\">from dtreeviz import * from dtreeviz.models.shadow_decision_tree import ShadowDecTree  shadow_tree = ShadowDecTree.get_shadow_tree(dt,X_train, y_train, feature_names = list(X.columns), target_name='TravelInsurance') model = DTreeVizAPI(shadow_tree) model.view(scale=2.0)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/724\/860\/226\/7248602266c37dd0e46c58da7c5c21a1.png\" width=\"974\" height=\"561\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/724\/860\/226\/7248602266c37dd0e46c58da7c5c21a1.png\"\/><\/figure>\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c \u0438 \u043f\u043e\u0434\u0431\u043e\u0440\u0443 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.\u00a0<\/p>\n<pre><code class=\"python\">print(\"Train quality:\") quality_report(dt.predict(X_train), y_train) print(\"\\nTest quality:\") quality_report(dt.predict(X_test), y_test)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/749\/959\/f8d\/749959f8d72e5f06b9f9e6b4745ea9c6.png\" width=\"180\" height=\"241\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/749\/959\/f8d\/749959f8d72e5f06b9f9e6b4745ea9c6.png\"\/><\/figure>\n<pre><code class=\"python\">cm = confusion_matrix(y_test, dt_y_pred) cm<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0b5\/772\/e77\/0b5772e77217965d8367af5bb370d9f5.png\" width=\"279\" height=\"49\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0b5\/772\/e77\/0b5772e77217965d8367af5bb370d9f5.png\"\/><\/figure>\n<pre><code class=\"python\">roc_auc(dt, X_test, y_test )<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/39e\/4ba\/8ee\/39e4ba8ee75306703eb59eb3aaa74a30.png\" width=\"521\" height=\"397\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/39e\/4ba\/8ee\/39e4ba8ee75306703eb59eb3aaa74a30.png\"\/><\/figure>\n<p>\u041f\u043e\u0434\u0431\u0438\u0440\u0430\u0435\u043c \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.\u00a0<\/p>\n<pre><code class=\"python\">dt = DecisionTreeClassifier()  parameters = {'max_depth':[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, None],                'min_samples_split' : [2,5,10,20],               'min_samples_leaf':[1, 5, 10,50],               'criterion' :['gini', 'entropy', 'log_loss']              }  grid_optimization(dt, parameters, X_train, y_train, X_test)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/754\/f63\/593\/754f63593b0dc61be2bc4c4d957bfc04.png\" width=\"932\" height=\"68\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/754\/f63\/593\/754f63593b0dc61be2bc4c4d957bfc04.png\"\/><\/figure>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0434\u0435\u0440\u0435\u0432\u0430.\u00a0<\/p>\n<pre><code class=\"python\">dt.feature_importances_<\/code><\/pre>\n<pre><code class=\"python\">pd.DataFrame(dt.feature_importances_, index = list(X.columns), columns = ['feature importance']).sort_values('feature importance', ascending = False)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f5b\/658\/a52\/f5b658a52329a6cd1ba8992ce3199dfa.png\" width=\"322\" height=\"314\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f5b\/658\/a52\/f5b658a52329a6cd1ba8992ce3199dfa.png\"\/><\/figure>\n<h3>Bagging<\/h3>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u0430\u043d\u0441\u0430\u043c\u0431\u043b\u044c \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.ensemble import BaggingClassifier  bagging_model = BaggingClassifier(base_estimator=DecisionTreeClassifier(max_depth=3), n_jobs=-1, n_estimators=350) bagging_model.fit(X_train, y_train) bagging_model_y_pred = bagging_model.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">print(\"Train quality:\") quality_report(bagging_model.predict(X_train), y_train) print(\"\\nTest quality:\") quality_report(bagging_model.predict(X_test), y_test)  <\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/205\/5b1\/505\/2055b1505489fc10798ad71d1057190d.png\" width=\"180\" height=\"232\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/205\/5b1\/505\/2055b1505489fc10798ad71d1057190d.png\"\/><\/figure>\n<pre><code class=\"python\">cm = confusion_matrix(y_test, bagging_model_y_pred) cm<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/59e\/b42\/d0b\/59eb42d0b4d97ade15a9f2b48755de3f.png\" width=\"287\" height=\"48\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/59e\/b42\/d0b\/59eb42d0b4d97ade15a9f2b48755de3f.png\"\/><\/figure>\n<pre><code class=\"python\">roc_auc(bagging_model, X_test, y_test )<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/431\/857\/578\/431857578e17bd200bae890737ce8f1b.png\" width=\"494\" height=\"388\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/431\/857\/578\/431857578e17bd200bae890737ce8f1b.png\"\/><\/figure>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f Bagging \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 (<code>f1_score<\/code>, <code>roc_auc_score<\/code>).\u00a0<\/p>\n<h2>Random Forest\u00a0<\/h2>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c Random Forest \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c\u044b\u0435 \u0441 Bagging.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.ensemble import RandomForestClassifier  rf = RandomForestClassifier(n_estimators=50, n_jobs=-1, max_depth = 3, max_features = None, oob_score=True,                              min_samples_split = 3, min_samples_leaf = 5, bootstrap = True, criterion = 'log_loss') rf.fit(X_train, y_train) rf_y_pred = rf.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">print(\"Train quality:\") quality_report(rf.predict(X_train), y_train) print(\"\\nTest quality:\") quality_report(rf.predict(X_test), y_test)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ecf\/ffb\/226\/ecfffb226c1c357d1d7941dc74f4c9be.png\" width=\"178\" height=\"238\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ecf\/ffb\/226\/ecfffb226c1c357d1d7941dc74f4c9be.png\"\/><\/figure>\n<pre><code class=\"python\">roc_auc(rf, X_test, y_test )<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/357\/861\/fed\/357861fed342e5d9dd3bb0c2ada131af.png\" width=\"503\" height=\"388\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/357\/861\/fed\/357861fed342e5d9dd3bb0c2ada131af.png\"\/><\/figure>\n<pre><code class=\"python\">rf = RandomForestClassifier()  parameters = {'n_estimators': [5,10,50, 100, 200, 300],                'max_features' : [None, 1, 3, 5, 7],                'max_depth':[None, 1, 2, 3, 4, 5, 6, 7],                'criterion': ['gini', 'entropy', 'log_loss'],               'bootstrap': [True, False]              }  grid_optimization(rf, parameters, X_train, y_train, X_test)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8cc\/a79\/9e9\/8cca799e9501affe352c16ad7d9c1f6f.png\" width=\"974\" height=\"64\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8cc\/a79\/9e9\/8cca799e9501affe352c16ad7d9c1f6f.png\"\/><\/figure>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0438. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430. \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c <code>CatBoostClassifier<\/code> \u0438 <code>LGBMClassifier<\/code>.<\/p>\n<h3>\u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0431\u0443\u0441\u0442\u0438\u043d\u0433<\/h3>\n<p>\u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0431\u0443\u0441\u0442\u0438\u043d\u0433 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c <code>f1_score<\/code>, \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0441\u044f <code>roc_auc_score<\/code>.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.ensemble import GradientBoostingClassifier  gb = GradientBoostingClassifier(n_estimators=10, learning_rate=1.0, max_depth=3, random_state=0, max_features = None) gb.fit(X_train, y_train) gb_y_pred = gb.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">print(\"Train quality:\") quality_report(gb.predict(X_train), y_train) print(\"\\nTest quality:\") quality_report(gb.predict(X_test), y_test)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eb5\/270\/11a\/eb527011ab557693f0be078ddf019f53.png\" width=\"171\" height=\"230\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eb5\/270\/11a\/eb527011ab557693f0be078ddf019f53.png\"\/><\/figure>\n<pre><code class=\"python\">roc_auc(gb, X_test, y_test )<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ccb\/6be\/65b\/ccb6be65b1ea949cc83374fe2f55334c.png\" width=\"486\" height=\"379\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ccb\/6be\/65b\/ccb6be65b1ea949cc83374fe2f55334c.png\"\/><\/figure>\n<pre><code class=\"python\">gb = GradientBoostingClassifier()  parameters = {'max_depth':[1, 3, 5, 7, 10, None],                'n_estimators': [5,10,50, 100, 500]              }  grid_optimization(gb, parameters, X_train, y_train, X_test)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/84e\/3c7\/ffa\/84e3c7ffac01991cb08735f24119ae7f.png\" width=\"653\" height=\"76\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/84e\/3c7\/ffa\/84e3c7ffac01991cb08735f24119ae7f.png\"\/><\/figure>\n<h3>CatBoost\u00a0<\/h3>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c CatBoost \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c <code>roc_auc_score<\/code> \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u043c \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u043e\u043c.\u00a0<\/p>\n<pre><code class=\"python\">from catboost import CatBoostClassifier   cb = CatBoostClassifier(iterations=10, learning_rate=0.5) cb.fit(X_train, y_train) cb_y_pred = cb.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">print(\"Train quality:\") quality_report(cb.predict(X_train), y_train) print(\"\\nTest quality:\") quality_report(cb.predict(X_test), y_test)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5a9\/dce\/b26\/5a9dceb26c990f9e3a2a88c235d11d82.png\" width=\"158\" height=\"226\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5a9\/dce\/b26\/5a9dceb26c990f9e3a2a88c235d11d82.png\"\/><\/figure>\n<pre><code class=\"python\">roc_auc(cb, X_test, y_test )<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2cc\/8d7\/c24\/2cc8d7c241c021870ab952c2d253aade.png\" width=\"511\" height=\"401\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2cc\/8d7\/c24\/2cc8d7c241c021870ab952c2d253aade.png\"\/><\/figure>\n<pre><code class=\"python\">cb = CatBoostClassifier()  parameters = {'iterations': [5,10,50, 70, 100],                'learning_rate':[0.01, 0.1, 0.15, 0.3, 0.5],              }  grid_optimization(cb, parameters, X_train, y_train, X_test)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6d9\/cf6\/7e8\/6d9cf67e8a5dd13c6c484ff942855ed2.png\" width=\"622\" height=\"275\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6d9\/cf6\/7e8\/6d9cf67e8a5dd13c6c484ff942855ed2.png\"\/><\/figure>\n<h2>LightGBM<\/h2>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 LightGBM \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u043b\u043e \u0441\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c <code>roc_auc_score<\/code> \u0431\u0435\u0437 \u0443\u0445\u0443\u0434\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f <code>f1_score<\/code>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0434\u0430\u043b\u0435\u043a\u0438 \u043e\u0442 \u0438\u0434\u0435\u0430\u043b\u0430, \u043d\u043e \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438.\u00a0<\/p>\n<pre><code class=\"python\">from lightgbm import LGBMClassifier   lgbm = LGBMClassifier(n_estimators=10) lgbm.fit(X_train, y_train) lgbm_y_pred = lgbm.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">print(\"Train quality:\") quality_report(lgbm.predict(X_train), y_train) print(\"\\nTest quality:\") quality_report(lgbm.predict(X_test), y_test)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1cb\/8a0\/44e\/1cb8a044eec77238be24bb3ecba95f06.png\" width=\"189\" height=\"243\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1cb\/8a0\/44e\/1cb8a044eec77238be24bb3ecba95f06.png\"\/><\/figure>\n<pre><code class=\"python\">roc_auc(lgbm, X_test, y_test )<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/01d\/5b6\/2e0\/01d5b62e074f778eecbcb228be47f5de.png\" width=\"478\" height=\"380\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/01d\/5b6\/2e0\/01d5b62e074f778eecbcb228be47f5de.png\"\/><\/figure>\n<pre><code class=\"python\">lgbm = LGBMClassifier()  parameters = {'n_estimators': [5,10,50, 100, 200, 300]} grid_optimization(lgbm, parameters, X_train, y_train, X_test)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2ae\/5be\/019\/2ae5be0191b9e0152ad30a1e3de96603.png\" width=\"573\" height=\"71\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ae\/5be\/019\/2ae5be0191b9e0152ad30a1e3de96603.png\"\/><\/figure>\n<h3>SVC<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434 \u043e\u043f\u043e\u0440\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0443\u0445\u0443\u0434\u0448\u0435\u043d\u0438\u0435 <code>f1_score<\/code>.<\/p>\n<pre><code class=\"python\">from sklearn.svm import SVC  svm = SVC(kernel='rbf', degree=1, gamma='scale', C=1.0, probability=True) svm.fit(X_train, y_train) svm_y_pred = svm.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">print(\"Train quality:\") quality_report(svm.predict(X_train), y_train) print(\"\\nTest quality:\") quality_report(svm.predict(X_test), y_test)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8a0\/7c6\/1be\/8a07c61be1783abeb71f1198323d5e85.png\" width=\"226\" height=\"278\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8a0\/7c6\/1be\/8a07c61be1783abeb71f1198323d5e85.png\"\/><\/figure>\n<pre><code class=\"python\">roc_auc(svm, X_test, y_test )<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9e4\/ab2\/e6a\/9e4ab2e6a429e2448006431c8af42b19.png\" width=\"486\" height=\"378\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9e4\/ab2\/e6a\/9e4ab2e6a429e2448006431c8af42b19.png\"\/><\/figure>\n<pre><code><\/code><\/pre>\n<pre><code class=\"python\">svm = SVC()  parameters = {'C':[1.0, 10.0, 20.0, None,],                'kernel': ['linear', 'poly', 'rbf', 'sigmoid', 'rbf'],               'gamma' : ['scale', 'auto'],               'degree' : [1, 3]               }  grid_optimization(svm, parameters, X_train, y_train, X_test)<\/code><\/pre>\n<h3>Naive bayes<\/h3>\n<p>Naive bayes \u043f\u043e\u043d\u0438\u0437\u0438\u043b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 <code>roc_auc_score<\/code>.\u00a0<\/p>\n<pre><code class=\"python\">from sklearn.naive_bayes import GaussianNB  gnb = GaussianNB(priors = None, var_smoothing = 1e-09) gnb.fit(X_train, y_train) gnb_y_pred = gnb.predict(X_test)<\/code><\/pre>\n<pre><code class=\"python\">print(\"Train quality:\") quality_report(gnb.predict(X_train), y_train) print(\"\\nTest quality:\") quality_report(gnb.predict(X_test), y_test)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f2d\/451\/0f0\/f2d4510f0aa770000ec01b94d3d13e11.png\" width=\"190\" height=\"244\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f2d\/451\/0f0\/f2d4510f0aa770000ec01b94d3d13e11.png\"\/><\/figure>\n<pre><code class=\"python\">roc_auc(gnb, X_test, y_test )<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7c5\/0b7\/eda\/7c50b7edaff3acbadbc960fa4e15a980.png\" width=\"520\" height=\"402\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7c5\/0b7\/eda\/7c50b7edaff3acbadbc960fa4e15a980.png\"\/><\/figure>\n<pre><code class=\"python\">gnb = GaussianNB()  parameters = { 'priors': [None, [0.1,]* len(['TravelInsurance']),],                'var_smoothing': [1e-9, 1e-6, 1e-12],              }  grid_optimization(gnb, parameters, X_train, y_train, X_test)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eae\/49e\/46a\/eae49e46ac38ba96b7479f24e0b6f654.png\" width=\"669\" height=\"85\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eae\/49e\/46a\/eae49e46ac38ba96b7479f24e0b6f654.png\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u0411\u0443\u0434\u0435\u043c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 <code>f1_score<\/code> \u0438 <code>roc_auc_score<\/code>.\u00a0<\/p>\n<pre><code class=\"python\">compare_models = pd.DataFrame({     'Model Name': ['KNN', 'LR', 'DecisionTree', 'Bagging', 'RandomForest',                     'GBoost', 'CatBoost', 'LightGBM', 'SVM', 'Naive Bayes'],     'True Positive': [confusion_matrix(y_test, knn_predictions_y).ravel()[0],                        confusion_matrix(y_test, lr_y_prediction).ravel()[0],                        confusion_matrix(y_test, dt_y_pred).ravel()[0],                        confusion_matrix(y_test, bagging_model_y_pred).ravel()[0],                        confusion_matrix(y_test, rf_y_pred).ravel()[0],                        confusion_matrix(y_test, gb_y_pred).ravel()[0],                        confusion_matrix(y_test, cb_y_pred).ravel()[0],                        confusion_matrix(y_test, lgbm_y_pred).ravel()[0],                        confusion_matrix(y_test, svm_y_pred).ravel()[0],                        confusion_matrix(y_test, gnb_y_pred).ravel()[0]],     'True Negative': [confusion_matrix(y_test, knn_predictions_y).ravel()[1],                        confusion_matrix(y_test, lr_y_prediction).ravel()[1],                        confusion_matrix(y_test, dt_y_pred).ravel()[1],                        confusion_matrix(y_test, bagging_model_y_pred).ravel()[1],                       confusion_matrix(y_test, rf_y_pred).ravel()[1],                        confusion_matrix(y_test, gb_y_pred).ravel()[1],                        confusion_matrix(y_test, cb_y_pred).ravel()[1],                        confusion_matrix(y_test, lgbm_y_pred).ravel()[1],                        confusion_matrix(y_test, svm_y_pred).ravel()[1],                        confusion_matrix(y_test, gnb_y_pred).ravel()[1]],     'False Positive': [confusion_matrix(y_test, knn_predictions_y).ravel()[2],                        confusion_matrix(y_test, lr_y_prediction).ravel()[2],                        confusion_matrix(y_test, dt_y_pred).ravel()[2],                        confusion_matrix(y_test, bagging_model_y_pred).ravel()[2],                         confusion_matrix(y_test, rf_y_pred).ravel()[2],                        confusion_matrix(y_test, gb_y_pred).ravel()[2],                        confusion_matrix(y_test, cb_y_pred).ravel()[2],                        confusion_matrix(y_test, lgbm_y_pred).ravel()[2],                        confusion_matrix(y_test, svm_y_pred).ravel()[2],                        confusion_matrix(y_test, gnb_y_pred).ravel()[2]],     'False Negative': [confusion_matrix(y_test, knn_predictions_y).ravel()[3],                        confusion_matrix(y_test, lr_y_prediction).ravel()[3],                        confusion_matrix(y_test, dt_y_pred).ravel()[3],                        confusion_matrix(y_test, bagging_model_y_pred).ravel()[3],                        confusion_matrix(y_test, rf_y_pred).ravel()[3],                        confusion_matrix(y_test, gb_y_pred).ravel()[3],                        confusion_matrix(y_test, cb_y_pred).ravel()[3],                        confusion_matrix(y_test, lgbm_y_pred).ravel()[3],                        confusion_matrix(y_test, svm_y_pred).ravel()[3],                        confusion_matrix(y_test, gnb_y_pred).ravel()[3]],     'Accuracy': [accuracy_score(y_test, knn_predictions_y),                   accuracy_score(y_test, lr_y_prediction),                   accuracy_score(y_test, dt_y_pred),                   accuracy_score(y_test, bagging_model_y_pred),                   accuracy_score(y_test, rf_y_pred),                   accuracy_score(y_test, gb_y_pred),                   accuracy_score(y_test, cb_y_pred),                  accuracy_score(y_test, lgbm_y_pred),                   accuracy_score(y_test, svm_y_pred),                   accuracy_score(y_test, gnb_y_pred)],                 'Precision' : [precision_score(y_test, knn_predictions_y),                     precision_score(y_test, lr_y_prediction),                     precision_score(y_test, dt_y_pred),                     precision_score(y_test, bagging_model_y_pred),                     precision_score(y_test, rf_y_pred),                     precision_score(y_test, gb_y_pred),                     precision_score(y_test, cb_y_pred),                     precision_score(y_test, lgbm_y_pred),                     precision_score(y_test, svm_y_pred),                     precision_score(y_test, gnb_y_pred)],          'Recall' : [recall_score(y_test, knn_predictions_y),                  recall_score(y_test, lr_y_prediction),                  recall_score(y_test, dt_y_pred),                 recall_score(y_test, bagging_model_y_pred),                 recall_score(y_test, rf_y_pred),                  recall_score(y_test, gb_y_pred),                  recall_score(y_test, cb_y_pred),                  recall_score(y_test, lgbm_y_pred),                  recall_score(y_test, svm_y_pred),                  recall_score(y_test, gnb_y_pred)],               'F1 Score' : [f1_score(y_test, knn_predictions_y),                    f1_score(y_test, lr_y_prediction),                    f1_score(y_test, dt_y_pred),                    f1_score(y_test, bagging_model_y_pred),                    f1_score(y_test, rf_y_pred),                    f1_score(y_test, gb_y_pred),                    f1_score(y_test, cb_y_pred),                    f1_score(y_test, lgbm_y_pred),                    f1_score(y_test, svm_y_pred),                    f1_score(y_test, gnb_y_pred)],       'AUC Score' : [roc_auc_score(y_test, knn.predict_proba(X_test)[:,1]),                    roc_auc_score(y_test, lr.predict_proba(X_test)[:,1]),                    roc_auc_score(y_test, dt.predict_proba(X_test)[:,1]),                   roc_auc_score(y_test, bagging_model.predict_proba(X_test)[:,1]),                   roc_auc_score(y_test, rf.predict_proba(X_test)[:,1]),                    roc_auc_score(y_test, gb.predict_proba(X_test)[:,1]),                    roc_auc_score(y_test, cb.predict_proba(X_test)[:,1]),                    roc_auc_score(y_test, lgbm.predict_proba(X_test)[:,1]),                    roc_auc_score(y_test, svm.predict_proba(X_test)[:,1]),                    roc_auc_score(y_test, gnb.predict_proba(X_test)[:,1])],   }) compare_models <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e8f\/2d4\/1a0\/e8f2d41a0d7ebded24a932d4fdf8657e.png\" width=\"974\" height=\"342\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e8f\/2d4\/1a0\/e8f2d41a0d7ebded24a932d4fdf8657e.png\"\/><\/figure>\n<p>\u041f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f 10 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0438\u0445 \u043d\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u043b\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 <code>roc_auc_score<\/code> \u0438 <code>f1_score<\/code> \u0445\u043e\u0442\u044f \u0431\u044b \u043a 0,90\u20130,95. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u043d\u0438\u0437\u043a\u043e\u0439 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0435\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u0440\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430. \u0421\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c <code>roc_auc_score<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0435\u043b\u0435\u0439: <strong>KNN<\/strong>, <strong>SVM<\/strong>. \u0421\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 <code>f1_score<\/code>, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u043c\u043e\u0434\u0435\u043b\u0438: <strong>GBoost<\/strong>, <strong>Decision<\/strong> <strong>Tree<\/strong>, <strong>Bagging<\/strong>, <strong>Random<\/strong> <strong>Forest<\/strong>, <strong>Cat<\/strong> <strong>Boost<\/strong>, <strong>LightGBM<\/strong>. \u0414\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u044f \u0432\u044b\u0431\u0440\u0430\u043b\u0430 \u043c\u043e\u0434\u0435\u043b\u044c <strong>LightGBM<\/strong>, \u0442. \u043a. \u043e\u043d\u0430 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043f\u043e \u043e\u0431\u043e\u0438\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c.\u00a0<\/p>\n<h2>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438<\/h2>\n<p>\u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u21162 \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 1303 \u0441\u0442\u0440\u043e\u043a\u0438, 8 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u041d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430. 4 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430. \u041d\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432. 483 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u0430. \u041f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 820 \u0441\u0442\u0440\u043e\u043a.\u00a0<\/p>\n<pre><code class=\"python\">data_new = pd.read_csv('Travel_Company_New_Clients.csv', sep = ';') data_new.head()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8db\/1c4\/c9f\/8db1c4c9f49e9f0b777db0ff39f3c106.png\" width=\"968\" height=\"189\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8db\/1c4\/c9f\/8db1c4c9f49e9f0b777db0ff39f3c106.png\"\/><\/figure>\n<pre><code class=\"python\">data_new.shape<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/050\/bfe\/738\/050bfe7381584c7158bf765954e53c49.png\" width=\"99\" height=\"31\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/050\/bfe\/738\/050bfe7381584c7158bf765954e53c49.png\"\/><\/figure>\n<pre><code class=\"python\">data_new.info()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/762\/5ab\/554\/7625ab5543df4d73e5bedd154df233b0.png\" width=\"495\" height=\"324\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/762\/5ab\/554\/7625ab5543df4d73e5bedd154df233b0.png\"\/><\/figure>\n<pre><code class=\"python\">data_new.duplicated().sum()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b23\/2ec\/7c7\/b232ec7c7b8a963227546f9addeaa057.png\" width=\"66\" height=\"25\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b23\/2ec\/7c7\/b232ec7c7b8a963227546f9addeaa057.png\"\/><\/figure>\n<pre><code class=\"python\">data_new.drop_duplicates(inplace = True) data_new = data_new.reset_index(drop = True) data_new.info()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3e4\/cf5\/6c7\/3e4cf56c7021e3f83a230f89a50a9db2.png\" width=\"425\" height=\"286\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3e4\/cf5\/6c7\/3e4cf56c7021e3f83a230f89a50a9db2.png\"\/><\/figure>\n<p>\u041f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0442\u0435\u043c \u0436\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435.\u00a0<\/p>\n<pre><code class=\"python\">data_new['GraduateOrNot'].unique()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d64\/6ab\/7e4\/d646ab7e472a482e506cafa3d9d94f40.png\" width=\"312\" height=\"30\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d64\/6ab\/7e4\/d646ab7e472a482e506cafa3d9d94f40.png\"\/><\/figure>\n<pre><code class=\"python\">data_new['GraduateOrNot'] = data_new['GraduateOrNot'].apply(lambda x: 1 if x=='Yes' else 0)<\/code><\/pre>\n<pre><code class=\"python\">data_new['FrequentFlyer'].unique()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dd3\/fe1\/199\/dd3fe1199a1b65a2b22bce5fde7e0df7.png\" width=\"320\" height=\"27\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dd3\/fe1\/199\/dd3fe1199a1b65a2b22bce5fde7e0df7.png\"\/><\/figure>\n<pre><code class=\"python\">data_new['FrequentFlyer'] = data_new['FrequentFlyer'].apply(lambda x: 1 if x=='Yes' else 0)<\/code><\/pre>\n<pre><code class=\"python\">data_new['EverTravelledAbroad'].unique()<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e5d\/ede\/6f4\/e5dede6f472ffc1cd1a574a84e6430a1.png\" width=\"316\" height=\"35\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e5d\/ede\/6f4\/e5dede6f472ffc1cd1a574a84e6430a1.png\"\/><\/figure>\n<pre><code class=\"python\">data_new['EverTravelledAbroad'] = data_new['EverTravelledAbroad'].apply(lambda x: 1 if x=='Yes' else 0)<\/code><\/pre>\n<pre><code class=\"python\">data_new['Employment Type'].unique()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c05\/26e\/81e\/c0526e81e7215d86c28acf367ea13149.png\" width=\"657\" height=\"28\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c05\/26e\/81e\/c0526e81e7215d86c28acf367ea13149.png\"\/><\/figure>\n<pre><code class=\"python\">print(data_new['Employment Type']. value_counts ()['Government Sector']) print(data_new['Employment Type']. value_counts ()['Private Sector\/Self Employed'])<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/446\/0f6\/07a\/4460f607a94d0d9f611379cdee5a8eb1.png\" width=\"54\" height=\"44\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/446\/0f6\/07a\/4460f607a94d0d9f611379cdee5a8eb1.png\"\/><\/figure>\n<pre><code class=\"python\">enc = OneHotEncoder() enc.fit_transform(data_new[['Employment Type']])<\/code><\/pre>\n<pre><code class=\"python\">data_new = data_new.drop(['Employment Type'], axis = 1).join(enc.fit_transform(data_new[['Employment Type']], axis = 0)) data_new.head()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9e9\/cd9\/1fb\/9e9cd91fb0a5ec9467664c76229dc090.png\" width=\"974\" height=\"176\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9e9\/cd9\/1fb\/9e9cd91fb0a5ec9467664c76229dc090.png\"\/><\/figure>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0443, \u0432 \u043d\u043e\u0432\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043d\u0438\u0437\u043a\u043e \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439.\u00a0<\/p>\n<pre><code class=\"python\">data_new.describe()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2cd\/e0c\/9c2\/2cde0c9c295924d576e41e29b800321a.png\" width=\"974\" height=\"253\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2cd\/e0c\/9c2\/2cde0c9c295924d576e41e29b800321a.png\"\/><\/figure>\n<pre><code class=\"python\">data_new.corr()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/25f\/f73\/369\/25ff733691d23ef703c8c0f1ea115e16.png\" width=\"974\" height=\"267\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/25f\/f73\/369\/25ff733691d23ef703c8c0f1ea115e16.png\"\/><\/figure>\n<pre><code class=\"python\">plt.subplots(figsize=(10,7)) sns.heatmap(data_new.corr(), cbar=True, annot=True, square=True, fmt='.2f', annot_kws={'size': 10},\\             cmap=sns.color_palette(\"coolwarm\", 10000), vmin=-1, center=0) plt.show()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3d4\/8b5\/309\/3d48b5309e2a3a12839f2430e7b77cc9.png\" width=\"974\" height=\"800\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3d4\/8b5\/309\/3d48b5309e2a3a12839f2430e7b77cc9.png\"\/><\/figure>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043c\u043e\u0436\u0435\u043c \u043b\u0438 \u043c\u044b \u0432 \u0440\u0430\u043d\u0435\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c LightGBM \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0442\u043e\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u0443\u0447\u0430\u043b\u0430\u0441\u044c \u043c\u043e\u0434\u0435\u043b\u044c. \u041c\u043e\u0436\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u043f\u0430\u0440\u043d\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0432 \u0440\u044f\u0434\u043e\u043c \u0434\u0432\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0438\u0445 \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u043e. \u041b\u0438\u0431\u043e \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 compare (\u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b keep_equal, keep_shape, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f).\u00a0<\/p>\n<pre><code class=\"python\">data_1.compare(data_2, result_names=('data_old', 'data_new'), align_axis=0)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c21\/2fb\/6ad\/c212fb6ad065a7d0011300afdb8ca949.png\" width=\"974\" height=\"348\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c21\/2fb\/6ad\/c212fb6ad065a7d0011300afdb8ca949.png\"\/><\/figure>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u0432 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0443 \u0432 \u0441\u0442\u0430\u0440\u043e\u043c \u0438 \u043d\u043e\u0432\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435, \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b \u043f\u043e\u0445\u043e\u0436\u0438, \u0437\u043d\u0430\u0447\u0438\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 \u0440\u0430\u043d\u0435\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442.\u00a0 \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c LightGBM \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u043e\u0432\u043e\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u2013 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438.\u00a0\u00a0\u00a0<\/p>\n<pre><code class=\"python\">X_new_test = scaler.transform(data_new)<\/code><\/pre>\n<pre><code class=\"python\">X_train.shape, X_new_test.shape, y_train.shape<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fe7\/757\/3e7\/fe77573e7bcbb5436ff5d4e673c2ec31.png\" width=\"257\" height=\"28\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fe7\/757\/3e7\/fe77573e7bcbb5436ff5d4e673c2ec31.png\"\/><\/figure>\n<pre><code class=\"python\">lgbm_predictions_new_y = lgbm.predict(X_new_test)<\/code><\/pre>\n<pre><code class=\"python\">data_new['predicted_TravelInsurance'] = lgbm_predictions_new_y<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043b\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u2013 \u043f\u043e\u043a\u0443\u043f\u043a\u0443 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438 \u0442\u0443\u0440\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430.\u00a0 \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0435 \u043f\u044f\u0442\u044c \u0441\u0442\u0440\u043e\u043a \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043a\u043e\u043b\u043e\u043d\u043a\u0430 <code>Predicted_TravelInsurance<\/code> c\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438.\u00a0<\/p>\n<pre><code class=\"python\">data_new.head()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/68b\/fa8\/44b\/68bfa844b5892a4d02b6d62bd36b93b1.png\" width=\"974\" height=\"175\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/68b\/fa8\/44b\/68bfa844b5892a4d02b6d62bd36b93b1.png\"\/><\/figure>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0430, \u0447\u0442\u043e 25% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 (205 \u0447\u0435\u043b\u043e\u0432\u0435\u043a) \u043a\u0443\u043f\u044f\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 75% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 (615 \u0447\u0435\u043b\u043e\u0432\u0435\u043a) \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043a\u0443\u043f\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443.\u00a0<\/p>\n<pre><code class=\"python\">data_new['Predicted_TravelInsurance'].value_counts(normalize=True)*100<\/code><\/pre>\n<pre><code class=\"python\">print(data_new['Predicted_TravelInsurance']. value_counts ()[0]) print(data_new['Predicted_TravelInsurance']. value_counts ()[1])<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8bd\/4bd\/6cf\/8bd4bd6cf8e6110d4c901744dc57c921.png\" width=\"49\" height=\"42\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8bd\/4bd\/6cf\/8bd4bd6cf8e6110d4c901744dc57c921.png\"\/><\/figure>\n<p>\u041f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043d\u0435 \u0442\u0430\u043a \u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a <code>f1_score<\/code> \u0438 <code>roc_auc_score<\/code>. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0447\u0435\u043c \u0432\u044b\u0448\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0442\u0435\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0435\u0435 \u043c\u043e\u0434\u0435\u043b\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0438\u0445 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u044f\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u0431\u0438\u0440\u0430\u043b\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>train_test_split():\u00a0 test_size = 0.2, test_size = 0.25, test_size = 0.3<\/code>. \u0411\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043c\u0435\u0442\u0440\u0438\u043a \u0431\u044b\u043b\u0438 \u043f\u0440\u0438 <code>test_size = 0.2<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u044f\u043b\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>stratify<\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>train_test_split(): stratify = None<\/code>, <code>stratify = y<\/code>. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>stratify<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041e\u043d \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0442. \u0435. \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438) \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0447\u0430\u0449\u0435, \u0447\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (\u043f\u043e\u043a\u0443\u043f\u043a\u0430 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0431\u044b\u043b\u0438 \u0432\u044b\u0448\u0435 \u0441 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c <code>stratify<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0430 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0441 \u0441\u0430\u043c\u043e\u0439 \u043d\u0438\u0437\u043a\u043e\u0439 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0435\u0439 (<code>GraduateOrNot<\/code>, <code>ChronicDiseases<\/code>), \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043d\u0435 \u043c\u0435\u0448\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u0438. \u042d\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u043a \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e \u043c\u0435\u0442\u0440\u0438\u043a.\u00a0<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0430\u0432\u0430\u043b\u0430 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u043e\u043f\u0438\u044e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0441\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0435\u0439 (<code>EverTravelledAbroad<\/code>, <code>AnnualIncome<\/code>, <code>FrequentFlyer<\/code>). \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438.\u00a0<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u2013 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438 \u0442\u0443\u0440 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430, \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432. \u041d\u043e \u044f \u0445\u043e\u0442\u0435\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0432 \u043f\u0440\u043e\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0434\u0431\u043e\u0440 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438.\u00a0\u00a0<\/p>\n<p>\u042f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0430\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0438 \u0434\u043e\u0445\u043e\u0434\u0447\u0438\u0432\u043e, \u0447\u0442\u043e\u0431\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0442\u0430\u043a\u043e\u043c\u0443 \u0436\u0435 \u043d\u043e\u0432\u0438\u0447\u043a\u0443, \u043a\u0430\u043a \u044f.\u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0440\u0435\u0434\u0438 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430\u0439\u0434\u0443\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u044b\u0442\u043d\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u0433\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u0434\u0430\u0442\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e \u043c\u0435\u0442\u0440\u0438\u043a, \u043b\u0438\u0431\u043e \u0434\u0440\u0443\u0433\u0438\u0435, \u043f\u043e \u0438\u0445 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0446\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438, \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u0430 \u0437\u0430 \u0441\u043e\u0432\u0435\u0442\u044b.\u00a0<\/p>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/SiPW\/\">Machine Learning. Basic<\/a> OTUS \u0432\u043e \u0433\u043b\u0430\u0432\u0435 \u0441 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c \u041c\u0430\u0440\u0438\u0435\u0439 \u0422\u0438\u0445\u043e\u043d\u043e\u0432\u043e\u0439 <a class=\"mention\" href=\"\/users\/mashkka_t\">@mashkka_t<\/a> \u0437\u0430 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u0438\u0437\u043c, \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043a \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435, \u0444\u043e\u0440\u043c\u0430\u0442 \u043f\u0440\u0435\u043f\u043e\u0434\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043c\u0435\u043d\u0442\u043e\u0440\u0441\u0442\u0432\u043e, \u043f\u043e\u0437\u0438\u0442\u0438\u0432, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0438 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/otus\/articles\/744854\/\"> https:\/\/habr.com\/ru\/companies\/otus\/articles\/744854\/<\/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<div class=\"persona\" persona=\"true\">\n<h5 class=\"persona__heading\" persona=\"true\">\u0410\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438: Alieva Natalie<\/h5>\n<p>\u0412\u044b\u043f\u0443\u0441\u043a\u043d\u0438\u0446\u0430 OTUS<\/p>\n<\/div>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<strong> <\/strong>\u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0430\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438 \u0442\u0443\u0440\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 ML, \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u043a\u0443\u0440\u0441\u0435 Machine Learning. Basic \u043e\u0442 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u0434\u043b\u044f IT-\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432 OTUS.\u00a0<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u044f \u0431\u0440\u0430\u043b\u0430 \u0441 Kaggle:\u00a0 <a href=\"https:\/\/www.kaggle.com\/datasets\/sellingstories\/travel-company-insurance-prediction\"><u>https:\/\/www.kaggle.com\/datasets\/sellingstories\/travel-company-insurance-prediction<\/u><\/a> . <\/p>\n<p>\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043c\u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u043f\u043e \u0434\u0432\u0443\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c:<\/p>\n<ul>\n<li>\n<p> \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u043b\u0438\u0441\u044c \u0434\u0432\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430: \u043e\u0434\u0438\u043d \u0441 \u0446\u0435\u043b\u0435\u0432\u044b\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c, \u0432\u0442\u043e\u0440\u043e\u0439 \u2013 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e. <\/p>\n<\/li>\n<li>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u0440\u0438 \u0431\u0435\u0433\u043b\u043e\u043c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0435 \u0442\u0430\u043a\u0430\u044f \u0443\u0436 \u0438 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438\u043c\u0435\u044e\u0442 \u043d\u0438\u0437\u043a\u0443\u044e \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044e, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0431\u043e\u0440\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.\u00a0 <\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0430, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0448\u0430\u043d\u0441 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f, \u043d\u043e \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0438\u043b\u044b \u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u044c\u0438, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043b\u0430 \u043a \u0440\u0430\u0431\u043e\u0442\u0435.\u00a0 \u042f\u0437\u044b\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Python, \u0441\u0440\u0435\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Jupiter Notebook.\u00a0<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441 \u0446\u0435\u043b\u0435\u0432\u044b\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c, \u044f \u043e\u0431\u0443\u0447\u0438\u043b\u0430 10 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0435\u043b\u0430\u043b\u0430 \u043f\u043e\u0434\u0431\u043e\u0440 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0430 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0431\u0443\u0441\u0442\u0438\u043d\u0433\u0430. \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0438 (<em>f1-score<\/em>, <em>auc-roc-score<\/em>), \u044f \u0432\u044b\u0431\u0440\u0430\u043b\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u0434\u0430\u043b\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0431\u0435\u0437 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438.\u00a0<\/p>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0438 \u043d\u0438\u0437\u043a\u043e\u0439 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0435\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0432\u0441\u0435 \u043c\u043e\u0438 \u0443\u0445\u0438\u0449\u0440\u0435\u043d\u0438\u044f \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c \u0438 \u043f\u043e\u0434\u0431\u043e\u0440\u0443 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c, \u0446\u0435\u043b\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u2013 \u0437\u043d\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u044b, \u043d\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u043b\u0438\u0431\u043e \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043b\u0438\u0431\u043e \u043f\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c.\u00a0<\/p>\n<h2>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c \u21161\u00a0<\/h2>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">import numpy as np import numpy.linalg as la import matplotlib import matplotlib.pyplot as plt import pandas as pd import seaborn as sns sns.set_style('darkgrid')  import plotly.express as px  from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from sklearn import datasets from sklearn import preprocessing from sklearn.preprocessing import StandardScaler from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score  %matplotlib inline np.random.seed(123)  import warnings warnings.filterwarnings(\"ignore\")<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437. \u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 9 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0441\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435.\u00a0<\/p>\n<pre><code class=\"python\">data = pd.read_csv('Travel_Company_Old_Clients.csv', sep = ';') data.head()<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432<\/p>\n<ol>\n<li>\n<p>Age &#8212; Age Of The Customer;<\/p>\n<\/li>\n<li>\n<p>Employment Type &#8212; The Sector In Which Customer Is Employed;<\/p>\n<\/li>\n<li>\n<p>GraduateOrNot &#8212; Whether The Customer Is College Graduate Or Not;<\/p>\n<\/li>\n<li>\n<p>AnnualIncome &#8212; The Yearly Income Of The Customer In Indian Rupees;<\/p>\n<\/li>\n<li>\n<p>FamilyMembers &#8212; Number Of Members In Customer&#8217;s Family;<\/p>\n<\/li>\n<li>\n<p>ChronicDisease &#8212; Whether The Customer Suffers From Any Major Disease Or Conditions Like Diabetes\/High BP or Asthama,etc.;<\/p>\n<\/li>\n<li>\n<p>FrequentFlyer &#8212; Derived Data Based On Customer&#8217;s History Of Booking Air Tickets On Atleast 4 Different Instances In The Last 2 Years 2017-2019;<\/p>\n<\/li>\n<li>\n<p>EverTravelledAbroad &#8212; Has The Customer Ever Travelled To A Foreign Country;<\/p>\n<\/li>\n<li>\n<p>TravelInsurance (1st File Only) &#8212; Did The Customer Buy Travel Insurance Package During Introductory Offering.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430: 682 \u0441\u0442\u0440\u043e\u0447\u043a\u0438, 9 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.\u00a0<\/p>\n<pre><code class=\"python\">data.shape<\/code><\/pre>\n<figure class=\"\"><\/figure>\n<p>\u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 4 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430. \u041d\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.\u00a0<\/p>\n<pre><code class=\"python\">data.info()<\/code><\/pre>\n<figure class=\"\"><\/figure>\n<pre><code class=\"python\">data.isnull().sum()<\/code><\/pre>\n<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 113 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432. \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b, \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f 569 \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.\u00a0\u00a0<\/p>\n<pre><code class=\"python\">data.duplicated().sum()<\/code><\/pre>\n<figure class=\"\"><\/figure>\n<pre><code class=\"python\">data.drop_duplicates(inplace = True) data = data.reset_index(drop = True) data.info()<\/code><\/pre>\n<figure class=\"\"><\/figure>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438.\u00a0<\/p>\n<pre><code class=\"python\">data.hist(figsize=(20, 20))<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"\"><\/figure>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0438 \u0435\u0433\u043e \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e \u0442\u0430\u0440\u0433\u0435\u0442\u0443. \u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 25 \u0434\u043e 35 \u043b\u0435\u0442. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 28 \u043b\u0435\u0442, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['Age'], hue=data['TravelInsurance']) # \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u0430\u044f \u0432 % data['Age'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>84% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438\u043c\u0435\u044e\u0442 \u0432\u044b\u0441\u0448\u0435\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u0430\u043a \u043b\u044e\u0434\u0438 \u0441 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0442\u0430\u043a \u0438 \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e\u0442 \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['GraduateOrNot'],hue=data['TravelInsurance']) data['GraduateOrNot'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0421\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e\u0442 \u043f\u043e\u043a\u0443\u043f\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0441 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0434\u043e\u0445\u043e\u0434\u0430.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['AnnualIncome'],hue=data['TravelInsurance']) plt.xticks(rotation = 90) plt.show() data['AnnualIncome'].value_counts(normalize=True)*100<\/code><\/pre>\n<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"\"><\/figure>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432 \u0441\u0435\u043c\u044c\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442 3 \u0434\u043e 5 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041d\u0435 \u043f\u0440\u043e\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0442\u0430\u0432\u043e\u043c \u0441\u0435\u043c\u044c\u0438 \u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438.\u00a0<\/p>\n<pre><code>sns.countplot(x = data['FamilyMembers'],hue=data['TravelInsurance']) data['FamilyMembers'].value_counts(normalize=True)*100<\/code><\/pre>\n<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0438\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0445\u0440\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0431\u043e\u043b\u0435\u0432\u0430\u043d\u0438\u0439 \u043b\u044e\u0434\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e\u0442 \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['ChronicDiseases'],hue=data['TravelInsurance']) data['ChronicDiseases'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>77% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0443\u0441\u043b\u0443\u0433\u0430\u043c\u0438 \u0430\u0432\u0438\u0430\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043b\u0435\u0442\u0435, \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['FrequentFlyer'],hue=data['TravelInsurance']) data['FrequentFlyer'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>80% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u044e\u0442 \u043f\u043e\u0435\u0437\u0434\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0440\u0430\u043d\u044b. \u041f\u043e\u0434\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0430\u0433\u0440\u0430\u043d\u0438\u0446\u0443, \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['EverTravelledAbroad'],hue=data['TravelInsurance']) data['EverTravelledAbroad'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>73% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u043d\u0435\u0433\u043e\u0441\u0443\u0434\u0430\u0440\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0441\u0435\u043a\u0442\u043e\u0440\u0435. \u041e\u043d\u0438 \u0447\u0430\u0449\u0435 \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443, \u0447\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u044b, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0432 \u0433\u043e\u0441\u043a\u043e\u0440\u043f\u043e\u0440\u0430\u0446\u0438\u044f\u0445.\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['Employment Type'],hue=data['TravelInsurance']) data['Employment Type'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043e\u043a\u0443\u043f\u043a\u0430 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u2013 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a. 64% \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u043d\u0435 \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442.\u00a0\u00a0<\/p>\n<pre><code class=\"python\">sns.countplot(x = data['TravelInsurance'],hue=data['TravelInsurance']) data['TravelInsurance'].value_counts(normalize=True)*100<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e plotly. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u0432\u0430\u0440\u0442\u0438\u043b\u0438, \u043d\u0430\u043b\u0438\u0447\u0438\u0435\/\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432. \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432. \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438\u0437 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432\u044b\u0431\u0440\u043e\u0441\u044b, \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430\u0434 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044f\u043c\u0438.\u00a0<\/p>\n<pre><code class=\"python\">fig = px.histogram(data, x='Age', color='TravelInsurance', marginal = 'box') fig.show() <\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<pre><code class=\"python\">fig = px.histogram(data, x='AnnualIncome', color='TravelInsurance', marginal = 'box') fig.show()<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<pre><code class=\"python\">fig = px.histogram(data, x='FamilyMembers', color='TravelInsurance', marginal = 'box') fig.show()<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<\/p>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e seaborn. \u041e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0430\u0440\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f.\u00a0<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0442\u0443\u0440\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043d\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u0430\u0433\u0440\u0430\u043d\u0438\u0446\u0443, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0435, \u043a\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442 \u0435\u0437\u0434\u0438\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0440\u0430\u043d\u044b, \u043f\u043e\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u0438 \u0434\u043e\u0445\u043e\u0434\u0430. \u041a\u043b\u0438\u0435\u043d\u0442\u044b, \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u0443, \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u044e\u0442 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0443 \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u0438 \u043f\u0440\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0434\u043e\u0445\u043e\u0434\u0430.\u00a0\u00a0<\/p>\n<pre><code class=\"python\">sns.relplot(data=data, x='AnnualIncome', y='Age', hue='TravelInsurance', col='EverTravelledAbroad', palette='bright', height=4)<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0444\u0430\u043a\u0442 \u043f\u043e\u043a\u0443\u043f\u043a\u0438 \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f\/\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0445\u0440\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0431\u043e\u043b\u0435\u0432\u0430\u043d\u0438\u0439, \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430, \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043e\u0445\u043e\u0434\u0430.\u00a0<\/p>\n<pre><code class=\"python\">sns.relplot(data=data, x='AnnualIncome', y='Age', hue='TravelInsurance', col='ChronicDiseases', palette='bright', height=4)<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0414\u0430\u0436\u0435 \u043f\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0432\u044b\u0448\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u043c \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0442 \u043d\u0438\u0437\u043a\u043e\u0439 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0435\u0439. \u041d\u043e \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043f\u043e\u0437\u0436\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.\u00a0<\/p>\n<p>\u0410 \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438. \u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b Yes\/No, \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 1\/0.\u00a0<\/p>\n<p>\u041f\u0440\u0438\u0437\u043d\u0430\u043a Employment Type \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043d\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f: 149 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Government Sector \u0438 420 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Private Sector\/Self Employed. \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f, \u0442\u043e \u0438\u0437-\u0437\u0430 \u043d\u0435\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u0432\u0435\u0440\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u0438\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0432\u0435\u0441. \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u044d\u0442\u043e\u0439 \u043d\u0435\u0432\u0435\u0440\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e One Hot Encoding.\u00a0<\/p>\n<pre><code class=\"python\">data['GraduateOrNot'].unique()<\/code><\/pre>\n<figure class=\"\"><\/figure>\n<pre><code class=\"python\">data['FrequentFlyer'].unique()<\/code><\/pre>\n<figure class=\"\"><\/figure>\n<pre><code>data['EverTravelledAbroad'].unique()<\/code><\/pre>\n<figure class=\"\"><\/figure>\n<pre><code class=\"python\">data['Employment Type'].unique() print(data['Employment Type']. value_counts ()['Government Sector']) print(data['Employment Type']. value_counts ()['Private Sector\/Self Employed'])<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"\"><\/figure>\n<pre><code class=\"python\">data['GraduateOrNot'] = data['GraduateOrNot'].apply(lambda x: 1 if x=='Yes' else 0) data['FrequentFlyer'] = data['FrequentFlyer'].apply(lambda x: 1 if x=='Yes' else 0) data['EverTravelledAbroad'] = data['EverTravelledAbroad'].apply(lambda x: 1 if x=='Yes' else 0)<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c One Hot Encoding \u0434\u043b\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 Employment Type. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043e\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>head()<\/code>.<\/p>\n<pre><code class=\"python\">from category_encoders import OneHotEncoder  enc = OneHotEncoder() enc.fit_transform(data[['Employment Type']]).head()<\/code><\/pre>\n<pre><code class=\"python\">data = data.drop(['Employment Type'], axis = 1).join(enc.fit_transform(data[['Employment Type']], axis = 0)) data.head()<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432.\u00a0 \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c \u0438\u0437 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0439 \u0438 \u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u044b, \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u0443\u044e\u0442 \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u0430\u0431\u043e. \u0415\u0441\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0441 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438.\u00a0<\/p>\n<pre><code class=\"python\">data.describe()<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<pre><code class=\"python\">data.corr()<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<pre><code>plt.subplots(figsize=(10,7)) sns.heatmap(data.corr(), cbar=True, annot=True, square=True, fmt='.2f', annot_kws={'size': 10},\\             cmap=sns.color_palette(\"coolwarm\", 10000), vmin=-1, center=0) plt.show()<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0414\u0430\u0442\u0430\u0441\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0433\u043e\u0442\u043e\u0432 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e.\u00a0 \u0420\u0430\u0437\u043e\u0431\u044c\u0435\u043c \u0435\u0433\u043e \u043d\u0430 X \u0438 \u0443.\u00a0<\/p>\n<pre><code class=\"python\">X = data.copy() X.drop(['TravelInsurance'], axis=1, inplace=True)  y = data['TravelInsurance']<\/code><\/pre>\n<p>\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-349608","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/349608","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=349608"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/349608\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=349608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=349608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=349608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}