{"id":202090,"date":"2013-11-14T10:00:02","date_gmt":"2013-11-14T06:00:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=202090"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=202090","title":{"rendered":"<span class=\"post_title\">\u041e\u0441\u043d\u043e\u0432\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas+sklearn<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438. \u0412 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0435\u0439 \u043f\u043e\u0441\u0442\u0435 \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0441\u0432\u043e\u0439 \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 python c \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0443\u043b\u044f <a href=\"http:\/\/pandas.pydata.org\/\">Pandas<\/a> \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u0434\u043b\u044f \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f <a href=\"http:\/\/scikit-learn.org\/stable\/\">scikit-learn<\/a>. \u0420\u0430\u0431\u043e\u0442\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <a href=\"https:\/\/www.kaggle.com\/c\/titanic-gettingStarted\/data\">\u0437\u0430\u0434\u0430\u0447\u0438<\/a> \u043f\u0440\u043e \u0441\u043f\u0430\u0441\u0435\u043d\u043d\u044b\u0445 \u0441 &quot;\u0422\u0438\u0442\u0430\u043d\u0438\u043a\u0430&#038;quot. \u0414\u0430\u043d\u043d\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0435\u0434\u0438 \u043b\u044e\u0434\u0435\u0439, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%9C%D0%B0%D1%88%D0%B8%D0%BD%D0%BD%D0%BE%D0%B5_%D0%BE%D0%B1%D1%83%D1%87%D0%B5%D0%BD%D0%B8%D0%B5\">\u043c\u0430\u0448\u0438\u043d\u043d\u044b\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c<\/a>.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<h4>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h4>\n<p>  \u0418\u0442\u0430\u043a \u0441\u0443\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0431\u044b \u0441\u043f\u0430\u0441\u0435\u0442\u0441\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438\u043b\u0438 \u043d\u0435\u0442. \u041a \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f 2 \u0444\u0430\u0439\u043b\u0430:  <\/p>\n<ul>\n<li><i>train.csv<\/i> \u2014 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c (<i>\u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430<\/i>)  <\/li>\n<li><i>test.csv<\/i> \u2014 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438  <\/li>\n<\/ul>\n<p>  \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0438 Pandas \u0438 scikit-learn. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b>Pandas<\/b> \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 <b>sklearn<\/b> \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438:<br \/>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u043e\u043b\u044f\u043c:  <\/p>\n<ul>\n<li><b>PassengerId<\/b> \u2014 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430  <\/li>\n<li><b>Survival<\/b> \u2014 \u043f\u043e\u043b\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0441\u043f\u0430\u0441\u0441\u044f \u0447\u0435\u043b\u043e\u043a\u0435(1) \u0438\u043b\u0438 \u043d\u0435\u0442 (0)  <\/li>\n<li><b>Pclass<\/b> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u043e-\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0442\u0430\u0442\u0443\u0441:<br \/> \n<ol>\n<li>\u0432\u044b\u0441\u043e\u043a\u0438\u0439<\/li>\n<li>\u0441\u0440\u0435\u0434\u043d\u0438\u0439<\/li>\n<li>\u043d\u0438\u0437\u043a\u0438\u0439<\/li>\n<\/ol>\n<\/li>\n<li><b>Name<\/b> \u2014 \u0438\u043c\u044f \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430  <\/li>\n<li><b>Sex<\/b> \u2014 \u043f\u043e\u043b \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430  <\/li>\n<li><b>Age<\/b> \u2014 \u0432\u043e\u0437\u0440\u0430\u0441\u0442  <\/li>\n<li><b>SibSp<\/b> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u0432 2-\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 (\u043c\u0443\u0436, \u0436\u0435\u043d\u0430, \u0431\u0440\u0430\u0442\u044c\u044f, \u0441\u0435\u0442\u0440\u044b)  <\/li>\n<li><b>Parch<\/b> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u0432 \u043d\u0430 \u0431\u043e\u0440\u0442\u0443 1-\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 (\u043c\u0430\u0442\u044c, \u043e\u0442\u0435\u0446, \u0434\u0435\u0442\u0438)  <\/li>\n<li><b>Ticket<\/b> \u2014 \u043d\u043e\u043c\u0435\u0440 \u0431\u0438\u043b\u0435\u0442\u0430  <\/li>\n<li><b>Fare<\/b> \u2014 \u0446\u0435\u043d\u0430 \u0431\u0438\u043b\u0435\u0442\u0430  <\/li>\n<li><b>Cabin<\/b> \u2014 \u043a\u0430\u044e\u0442\u0430  <\/li>\n<li><b>Embarked<\/b> \u2014 \u043f\u043e\u0440\u0442 \u043f\u043e\u0441\u0430\u0434\u043a\u0438<br \/> \n<ul>\n<li>C \u2014 Cherbourg<\/li>\n<li>Q \u2014 Queenstown<\/li>\n<li>S \u2014 Southampton  <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>\u0410\u043d\u0430\u043b\u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  &gt;\u0418\u0442\u0430\u043a, \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044e.<br \/>  \u0414\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043e\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442::<\/p>\n<pre><code class=\"python\">from pandas import read_csv, DataFrame, Series data = read_csv('Kaggle_Titanic\/Data\/train.csv')<\/code><\/pre>\n<p>  <\/p>\n<table border=\"1\">\n<tr>\n<th>PassengerId<\/th>\n<th>Survived<\/th>\n<th>Pclass<\/th>\n<th>Name<\/th>\n<th>Sex<\/th>\n<th>Age<\/th>\n<th>SibSp<\/th>\n<th>Parch<\/th>\n<th>Ticket<\/th>\n<th>Fare<\/th>\n<th>Cabin<\/th>\n<th>Embarked<\/th>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>0<\/td>\n<td>3<\/td>\n<td>Braund, Mr. Owen Harris<\/td>\n<td>male<\/td>\n<td>22<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>A\/5 21171<\/td>\n<td>7.2500<\/td>\n<td>NaN<\/td>\n<td>S<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>Cumings, Mrs. John Bradley (Florence Briggs Th&#8230;<\/td>\n<td>female<\/td>\n<td>38<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>PC 17599<\/td>\n<td>71.2833<\/td>\n<td>C85<\/td>\n<td>C<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>1<\/td>\n<td>3<\/td>\n<td>Heikkinen, Miss. Laina<\/td>\n<td>female<\/td>\n<td>26<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>STON\/O2. 3101282<\/td>\n<td>7.9250<\/td>\n<td>NaN<\/td>\n<td>S<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>Futrelle, Mrs. Jacques Heath (Lily May Peel)<\/td>\n<td>female<\/td>\n<td>35<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>113803<\/td>\n<td>53.1000<\/td>\n<td>C123<\/td>\n<td>S<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>0<\/td>\n<td>3<\/td>\n<td>Allen, Mr. William Henry<\/td>\n<td>male<\/td>\n<td>35<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>373450<\/td>\n<td>8.0500<\/td>\n<td>NaN<\/td>\n<td>S<\/td>\n<\/tr>\n<\/table>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0447\u0435\u043c \u0432\u044b\u0448\u0435 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u043f\u0430\u0441\u0435\u043d\u0438\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u0430\u0441\u0448\u0438\u0445\u0441\u044f \u0438 \u0443\u0442\u043e\u043d\u0443\u0432\u0448\u0438\u0445 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0440\u0430\u0437\u0440\u0435\u0437\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0432\u043e\u0434\u043d\u0443\u044e:<\/p>\n<pre><code class=\"python\">data.pivot_table('PassengerId', 'Pclass', 'Survived', 'count').plot(kind='bar', stacked=True)<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/c64\/b62\/cbc\/c64b62cbc06141e072d550b6b2f3ca7c.png\" alt=\"image\"\/><br \/>  \u041d\u0430\u0448\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e \u0447\u0435\u043c \u0432\u044b\u0448\u0435 \u0443 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432 \u0438\u0445 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0442\u0435\u043c \u0432\u044b\u0448\u0435 \u0438\u0445 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u043f\u0430\u0441\u0435\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c, \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u0432 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0444\u0430\u043a\u0442 \u0441\u043f\u0430\u0441\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">fig, axes = plt.subplots(ncols=2) data.pivot_table('PassengerId', ['SibSp'], 'Survived', 'count').plot(ax=axes[0], title='SibSp') data.pivot_table('PassengerId', ['Parch'], 'Survived', 'count').plot(ax=axes[1], title='Parch') <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/b86\/14a\/1c7\/b8614a1c73db29d7173856f3e05f3c4c.png\" alt=\"image\"\/><br \/>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u043d\u0430\u0448\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u043e\u0441\u044c, \u0438 \u0438\u0437 \u043b\u044e\u0434\u0435\u0439 \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 1 \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u0432 \u0441\u043f\u0430\u0441\u043b\u0438\u0441\u044c \u043d\u0435 \u043c\u043d\u043e\u0433\u0438\u0435.<br \/>  \u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0435\u043c \u043d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u043a\u0430\u044e\u0442. \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043a\u0430\u044e\u0442\u0430\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0431\u044b\u0442\u044c, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u043f\u043e\u043b\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043e:<\/p>\n<pre><code class=\"python\">data.PassengerId[data.Cabin.notnull()].count()<\/code><\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0432\u0441\u0435\u0433\u043e 204 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 890, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u043f\u0440\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c.<br \/>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u043e\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435 \u0441 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u043e\u043c (<i>Age<\/i>). \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043e:<\/p>\n<pre><code class=\"python\">data.PassengerId[data.Age.notnull()].count()<\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043e (714 \u043d\u0435\u043f\u0443\u0441\u0442\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439), \u043d\u043e \u0435\u0441\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u043e\u0435 \u043c\u0435\u0434\u0438\u0430\u043d\u0435 \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0443 \u0438\u0437 \u0432\u0441\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438. \u0414\u0430\u043d\u043d\u044b\u0439 \u0448\u0430\u0433 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\">data.Age = data.Age.median()<\/code><\/pre>\n<p>  \u0423 \u043d\u0430\u0441 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 <i>Ticket<\/i>, <i>Embarked<\/i>, <i>Fare<\/i>, <i>Name<\/i>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u043e\u043b\u0435 Embarked, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0440\u0442 \u043f\u043e\u0441\u0430\u0434\u043a\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u044b \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0440\u0442 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d:<\/p>\n<pre><code class=\"python\">data[data.Embarked.isnull()]<\/code><\/pre>\n<p>  <\/p>\n<table border=\"1\">\n<tr>\n<th>PassengerId<\/th>\n<th>Survived<\/th>\n<th>Pclass<\/th>\n<th>Name<\/th>\n<th>Sex<\/th>\n<th>Age<\/th>\n<th>SibSp<\/th>\n<th>Parch<\/th>\n<th>Ticket<\/th>\n<th>Fare<\/th>\n<th>Cabin<\/th>\n<th>Embarked<\/th>\n<\/tr>\n<tr>\n<td>62<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>Icard, Miss. Amelie<\/td>\n<td>female<\/td>\n<td>28<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>113572<\/td>\n<td>80<\/td>\n<td>B28<\/td>\n<td>NaN<\/td>\n<\/tr>\n<tr>\n<td>830<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>Stone, Mrs. George Nelson (Martha Evelyn)<\/td>\n<td>female<\/td>\n<td>28<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>113572<\/td>\n<td>80<\/td>\n<td>B28<\/td>\n<td>NaN<\/td>\n<\/tr>\n<\/table>\n<p>  \u0418\u0442\u0430\u043a \u0443 \u043d\u0430\u0441 \u043d\u0430\u0448\u043b\u043e\u0441\u044c 2 \u0442\u0430\u043a\u0438\u0445 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u044d\u0442\u0438 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430\u043c \u043f\u043e\u0440\u0442 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0435\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043b\u044e\u0434\u0435\u0439:<\/p>\n<pre><code class=\"python\">MaxPassEmbarked = data.groupby('Embarked').count()['PassengerId'] data.Embarked[data.Embarked.isnull()] = MaxPassEmbarked[MaxPassEmbarked == MaxPassEmbarked.max()].index[0] <\/code><\/pre>\n<p>  \u041d\u0443 \u0447\u0442\u043e \u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0435\u0449\u0435 \u0441 \u043e\u0434\u043d\u0438\u043c \u043f\u043e\u043b\u0435\u043c \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u043b\u044f \u0441 \u0438\u043c\u044f \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430, \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0431\u0438\u043b\u0435\u0442\u0430 \u0438 \u0446\u0435\u043d\u043e\u0439 \u0431\u0438\u043b\u0435\u0442\u0430.<br \/>  \u041f\u043e \u0441\u0443\u0442\u0438 \u043d\u0430\u043c \u0438\u0437 \u044d\u0442\u0438\u0445 \u0442\u0440\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0435\u043d\u0430(<i>Fare<\/i>), \u0442.\u043a. \u043e\u043d\u0430 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u0435\u0440\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043f\u043e\u043b\u044f <i>Pclass<\/i>. \u0422. \u0435. \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043b\u044e\u0434\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0430 \u0442\u0435\u0445, \u043a\u0442\u043e \u0431\u043b\u0438\u0436\u0435 \u043a \u043f\u0435\u0440\u0432\u043e\u043c\u0443(\u0432\u044b\u0441\u0448\u0435\u043c\u0443) \u043a\u043b\u0430\u0441\u0441\u0443, \u0430 \u043a\u0442\u043e \u043a \u0442\u0440\u0435\u0442\u044c\u0435\u043c\u0443(\u043d\u0438\u0437\u0448\u0438\u0439). \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e \u043f\u043e\u043b\u0435 \u043d\u0430 \u043f\u0443\u0441\u0442\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u044b\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0446\u0435\u043d\u0443 \u043c\u0435\u0434\u0438\u0430\u043d\u043e\u0439 \u043f\u043e \u0446\u0435\u043d\u0435 \u0438\u0437 \u0432\u0441\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438:<\/p>\n<pre><code class=\"python\">data.PassengerId[data.Fare.isnull()]<\/code><\/pre>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0443\u0441\u0442\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0435\u0442.<br \/>  \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u043e\u043c\u0435\u0440 \u0431\u0438\u043b\u0435\u0442\u0430 \u0438 \u0438\u043c\u044f \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430 \u043d\u0430\u043c \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442, \u0442. \u043a. \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u2014 \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u0442\u043e \u0438\u0437 \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u043e\u0432 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0430\u043c\u0438, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u043b\u044e\u0434\u0438 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0440\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0441\u043f\u0430\u0441\u043b\u0438\u0441\u044c (\u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435) \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0447\u044c \u044d\u0442\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439, \u043d\u0430\u0448 \u043d\u0430\u0431\u043e\u0440 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">data = data.drop(['PassengerId','Name','Ticket','Cabin'],axis=1)<\/code><\/pre>\n<p>  <\/p>\n<table border=\"1\">\n<tr>\n<th>Survived<\/th>\n<th>Pclass<\/th>\n<th>Sex<\/th>\n<th>Age<\/th>\n<th>SibSp<\/th>\n<th>Parch<\/th>\n<th>Fare<\/th>\n<th>Embarked<\/th>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>3<\/td>\n<td>male<\/td>\n<td>28<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>7.2500<\/td>\n<td>S<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>1<\/td>\n<td>female<\/td>\n<td>28<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>71.2833<\/td>\n<td>C<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>3<\/td>\n<td>female<\/td>\n<td>28<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>7.9250<\/td>\n<td>S<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>1<\/td>\n<td>female<\/td>\n<td>28<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>53.1000<\/td>\n<td>S<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>3<\/td>\n<td>male<\/td>\n<td>28<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>8.0500<\/td>\n<td>S<\/td>\n<\/tr>\n<\/table>\n<h4>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d, \u0438 \u043f\u043e \u0435\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043a\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0439 \u0438 \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438, \u0435\u0441\u043b\u0438 \u0431\u044b \u043d\u0435 \u043e\u0434\u043d\u043e \u00ab\u043d\u043e\u00bb: \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435, \u043d\u043e \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<br \/>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0435 \u0442\u0435\u043c, \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<br \/>  \u041c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0440\u0443\u0447\u043d\u0443\u044e, \u0430 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0443\u043b\u044f <a href=\"http:\/\/scikit-learn.org\/stable\/modules\/preprocessing.html#preprocessing\">sklearn.preprocessing<\/a>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u0442\u043e\u0440\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c.<br \/>  \u0417\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <a href=\"http:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.preprocessing.LabelEncoder.html#sklearn.preprocessing.LabelEncoder\">LabelEncoder()<\/a>. \u0421\u0443\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u0435\u0439 \u043f\u043e\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0434\u043e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u0434\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"python\">from sklearn.preprocessing import LabelEncoder label = LabelEncoder() dicts = {}  label.fit(data.Sex.drop_duplicates()) #\u0437\u0430\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f dicts['Sex'] = list(label.classes_) data.Sex = label.transform(data.Sex) #\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u043e\u0434\u0430\u043c\u0438 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432   label.fit(data.Embarked.drop_duplicates()) dicts['Embarked'] = list(label.classes_) data.Embarked = label.transform(data.Embarked)<\/code><\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430\u0448\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<table border=\"1\">\n<tr>\n<th>Survived<\/th>\n<th>Pclass<\/th>\n<th>Sex<\/th>\n<th>Age<\/th>\n<th>SibSp<\/th>\n<th>Parch<\/th>\n<th>Fare<\/th>\n<th>Embarked<\/th>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>3<\/td>\n<td>1<\/td>\n<td>28<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>7.2500<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>28<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>71.2833<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>3<\/td>\n<td>0<\/td>\n<td>28<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>7.9250<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>28<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>53.1000<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>3<\/td>\n<td>1<\/td>\n<td>28<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>8.0500<\/td>\n<td>2<\/td>\n<\/tr>\n<\/table>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u0447\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c \u0432\u0438\u0434. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0432\u044b\u0448\u0435(\u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430):<\/p>\n<pre><code class=\"python\">test = read_csv('Kaggle_Titanic\/Data\/test.csv') test.Age[test.Age.isnull()] = test.Age.mean() test.Fare[test.Fare.isnull()] = test.Fare.median() #\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0443\u0441\u0442\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0446\u0435\u043d\u043e\u0439 \u0431\u0438\u043b\u0435\u0442\u0430 MaxPassEmbarked = test.groupby('Embarked').count()['PassengerId'] test.Embarked[test.Embarked.isnull()] = MaxPassEmbarked[MaxPassEmbarked == MaxPassEmbarked.max()].index[0] result = DataFrame(test.PassengerId) test = test.drop(['Name','Ticket','Cabin','PassengerId'],axis=1)  label.fit(dicts['Sex']) test.Sex = label.transform(test.Sex)  label.fit(dicts['Embarked']) test.Embarked = label.transform(test.Embarked) <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0435 \u0436\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b\u0438 \u0441 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u043e\u0439. \u041e\u0442\u043b\u0438\u0447\u0438\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u043b\u044f <i>Fare<\/i>, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0432\u0434\u0440\u0443\u0433 \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043e.  <\/p>\n<table border=\"1\">\n<tr>\n<th>Pclass<\/th>\n<th>Sex<\/th>\n<th>Age<\/th>\n<th>SibSp<\/th>\n<th>Parch<\/th>\n<th>Fare<\/th>\n<th>Embarked<\/th>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>1<\/td>\n<td>34.5<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>7.8292<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>0<\/td>\n<td>47.0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>7.0000<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>1<\/td>\n<td>62.0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>9.6875<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>1<\/td>\n<td>27.0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>8.6625<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>0<\/td>\n<td>22.0<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>12.2875<\/td>\n<td>2<\/td>\n<\/tr>\n<\/table>\n<h4>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0438\u0445 \u0430\u043d\u0430\u043b\u0438\u0437<\/h4>\n<p>  \u041d\u0443 \u0447\u0442\u043e \u0436\u0435, \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b \u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/www.machinelearning.ru\/wiki\/index.php?title=%D0%A1%D0%BA%D0%BE%D0%BB%D1%8C%D0%B7%D1%8F%D1%89%D0%B8%D0%B9_%D0%BA%D0%BE%D0%BD%D1%82%D1%80%D0%BE%D0%BB%D1%8C\">\u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c<\/a> \u0438 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/ROC-%D0%BA%D1%80%D0%B8%D0%B2%D0%B0%D1%8F\">ROC-\u043a\u0440\u0438\u0432\u044b\u0435<\/a>. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0435\u0435 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e.<br \/>  \u0418\u0442\u0430\u043a \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f:  <\/p>\n<ul>\n<li><a href=\"http:\/\/ru.wikipedia.org\/wiki\/%CC%E5%F2%EE%E4_%EE%EF%EE%F0%ED%FB%F5_%E2%E5%EA%F2%EE%F0%EE%E2\">\u041c\u0435\u0442\u043e\u0434 \u043e\u043f\u043e\u0440\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432<\/a>  <\/li>\n<li><a href=\"http:\/\/ru.wikipedia.org\/wiki\/%CC%E5%F2%EE%E4_k_%E1%EB%E8%E6%E0%E9%F8%E8%F5_%F1%EE%F1%E5%E4%E5%E9\">\u041c\u0435\u0442\u043e\u0434 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439<\/a>  <\/li>\n<li><a href=\"http:\/\/ru.wikipedia.org\/wiki\/Random_forest\">Random forest<\/a>  <\/li>\n<li><a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%9B%D0%BE%D0%B3%D0%B8%D1%81%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F_%D1%80%D0%B5%D0%B3%D1%80%D0%B5%D1%81%D1%81%D0%B8%D1%8F\">\u041b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/a>  <\/li>\n<\/ul>\n<p>  \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">from sklearn import cross_validation, svm from sklearn.neighbors import KNeighborsClassifier from sklearn.ensemble import RandomForestClassifier from sklearn.linear_model import LogisticRegression from sklearn.metrics import roc_curve, auc import pylab as pl <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u043e\u0431\u0443\u0447\u0430\u044e\u0448\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043d\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c, \u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0435:<\/p>\n<pre><code class=\"python\">target = data.Survived train = data.drop(['Survived'], axis=1) #\u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0431\u0438\u0440\u0430\u0435\u043c Id \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0430 \u0438 \u0444\u043b\u0430\u0433 \u0441\u043f\u0430\u0441\u0441\u044f \u043e\u043d \u0438\u043b\u0438 \u043d\u0435\u0442 kfold = 5 #\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043e\u043a \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 itog_val = {} #\u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043a\u0440\u043e\u0441\u0441 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<table border=\"1\">\n<tr>\n<th>Pclass<\/th>\n<th>Sex<\/th>\n<th>Age<\/th>\n<th>SibSp<\/th>\n<th>Parch<\/th>\n<th>Fare<\/th>\n<th>Embarked<\/th>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>1<\/td>\n<td>28<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>7.2500<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>0<\/td>\n<td>28<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>71.2833<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>0<\/td>\n<td>28<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>7.9250<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>0<\/td>\n<td>28<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>53.1000<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>1<\/td>\n<td>28<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td> 8.0500<\/td>\n<td>2<\/td>\n<\/tr>\n<\/table>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u043e\u0431\u044c\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u043d\u0430 2 \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043a\u0438(\u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0443\u044e \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e) \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442 ROC \u043a\u0440\u0438\u0432\u044b\u0445 (\u0434\u043b\u044f \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e, \u0442.\u043a. \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0430\u043c\u0430. \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"http:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.cross_validation.train_test_split.html#sklearn.cross_validation.train_test_split\">train_test_split<\/a> \u043c\u043e\u0434\u0443\u043b\u044f <a href=\"http:\/\/scikit-learn.org\/stable\/modules\/cross_validation.html#cross-validation\">cross_validation<\/a>:<\/p>\n<pre><code class=\"python\">ROCtrainTRN, ROCtestTRN, ROCtrainTRG, ROCtestTRG = cross_validation.train_test_split(train, target, test_size=0.25)  <\/code><\/pre>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f:  <\/p>\n<ul>\n<li>\u041c\u0430\u0441\u0441\u0438\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432  <\/li>\n<li>\u041c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439  <\/li>\n<li>\u0421\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0442\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0430 1\/4 \u0447\u0430\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438)  <\/li>\n<\/ul>\n<p>  \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0434\u0430\u0435\u0442 4 \u043c\u0430\u0441\u0441\u0438\u0432\u0430:  <\/p>\n<ol>\n<li>\u041d\u043e\u0432\u044b\u0439 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432  <\/li>\n<li>\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432  <\/li>\n<li>\u041d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439  <\/li>\n<li>\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439  <\/li>\n<\/ol>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0441 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043e\u043f\u044b\u0442\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u043c:  <\/p>\n<pre><code class=\"python\">model_rfc = RandomForestClassifier(n_estimators = 70) #\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 model_knc = KNeighborsClassifier(n_neighbors = 18) #\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0441\u043e\u0441\u0435\u0434\u0435\u0439 model_lr = LogisticRegression(penalty='l1', tol=0.01)  model_svc = svm.SVC() #\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e kernek='rbf' <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043ec\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <a href=\"http:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.cross_validation.cross_val_score.html#sklearn.cross_validation.cross_val_score\">cross_val_score<\/a>  <\/p>\n<pre><code class=\"python\">scores = cross_validation.cross_val_score(model_rfc, train, target, cv = kfold) itog_val['RandomForestClassifier'] = scores.mean() scores = cross_validation.cross_val_score(model_knc, train, target, cv = kfold) itog_val['KNeighborsClassifier'] = scores.mean() scores = cross_validation.cross_val_score(model_lr, train, target, cv = kfold) itog_val['LogisticRegression'] = scores.mean() scores = cross_validation.cross_val_score(model_svc, train, target, cv = kfold) itog_val['SVC'] = scores.mean() <\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u043a\u0440\u0435\u0441\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\">DataFrame.from_dict(data = itog_val, orient='index').plot(kind='bar', legend=False) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/0c4\/800\/17d\/0c480017dfbcc82215a8e568d3db0ecb.png\" alt=\"image\"\/><\/p>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438\u0437 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u0435\u0431\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c RandomForest. \u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 ROC-\u043a\u0440\u0438\u0432\u044b\u0445, \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430. \u0413\u0440\u0430\u0444\u0438\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"http:\/\/matplotlib.org\/\">matplotlib<\/a>:<\/p>\n<pre><code class=\"python\">pl.clf() plt.figure(figsize=(8,6)) #SVC model_svc.probability = True probas = model_svc.fit(ROCtrainTRN, ROCtrainTRG).predict_proba(ROCtestTRN) fpr, tpr, thresholds = roc_curve(ROCtestTRG, probas[:, 1]) roc_auc  = auc(fpr, tpr) pl.plot(fpr, tpr, label='%s ROC (area = %0.2f)' % ('SVC', roc_auc)) #RandomForestClassifier probas = model_rfc.fit(ROCtrainTRN, ROCtrainTRG).predict_proba(ROCtestTRN) fpr, tpr, thresholds = roc_curve(ROCtestTRG, probas[:, 1]) roc_auc  = auc(fpr, tpr) pl.plot(fpr, tpr, label='%s ROC (area = %0.2f)' % ('RandonForest',roc_auc)) #KNeighborsClassifier probas = model_knc.fit(ROCtrainTRN, ROCtrainTRG).predict_proba(ROCtestTRN) fpr, tpr, thresholds = roc_curve(ROCtestTRG, probas[:, 1]) roc_auc  = auc(fpr, tpr) pl.plot(fpr, tpr, label='%s ROC (area = %0.2f)' % ('KNeighborsClassifier',roc_auc)) #LogisticRegression probas = model_lr.fit(ROCtrainTRN, ROCtrainTRG).predict_proba(ROCtestTRN) fpr, tpr, thresholds = roc_curve(ROCtestTRG, probas[:, 1]) roc_auc  = auc(fpr, tpr) pl.plot(fpr, tpr, label='%s ROC (area = %0.2f)' % ('LogisticRegression',roc_auc)) pl.plot([0, 1], [0, 1], 'k--') pl.xlim([0.0, 1.0]) pl.ylim([0.0, 1.0]) pl.xlabel('False Positive Rate') pl.ylabel('True Positive Rate') pl.legend(loc=0, fontsize='small') pl.show() <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/2c5\/ef2\/a8c\/2c5ef2a8ce2d782b09a08a5036cdfa68.png\" alt=\"image\"\/><br \/>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u043f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c ROC-\u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u044f\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043b RandomForest. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u043a \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435:<\/p>\n<pre><code class=\"python\">model_rfc.fit(train, target) result.insert(1,'Survived', model_rfc.predict(test)) result.to_csv('Kaggle_Titanic\/Result\/test.csv', index=False) <\/code><\/pre>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442 <b>pandas<\/b> \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 \u043f\u0430\u043a\u0435\u0442\u043e\u043c \u0434\u043b\u044f \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f <b>sklearn<\/b>. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0438 \u0441\u0430\u0431\u043c\u0438\u0442\u0435 \u043d\u0430 Kaggle \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c 0.77033. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c \u0438 \u0445\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u043d\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 <a href=\"http:\/\/habrahabr.ru\/post\/165001\/\">\u044d\u0442\u043e\u0439<\/a> \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439.    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/202090\/\"> http:\/\/habrahabr.ru\/post\/202090\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438. \u0412 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0435\u0439 \u043f\u043e\u0441\u0442\u0435 \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0441\u0432\u043e\u0439 \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 python c \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0443\u043b\u044f <a href=\"http:\/\/pandas.pydata.org\/\">Pandas<\/a> \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u0434\u043b\u044f \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f <a href=\"http:\/\/scikit-learn.org\/stable\/\">scikit-learn<\/a>. \u0420\u0430\u0431\u043e\u0442\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <a href=\"https:\/\/www.kaggle.com\/c\/titanic-gettingStarted\/data\">\u0437\u0430\u0434\u0430\u0447\u0438<\/a> \u043f\u0440\u043e \u0441\u043f\u0430\u0441\u0435\u043d\u043d\u044b\u0445 \u0441 &quot;\u0422\u0438\u0442\u0430\u043d\u0438\u043a\u0430&#038;quot. \u0414\u0430\u043d\u043d\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0435\u0434\u0438 \u043b\u044e\u0434\u0435\u0439, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%9C%D0%B0%D1%88%D0%B8%D0%BD%D0%BD%D0%BE%D0%B5_%D0%BE%D0%B1%D1%83%D1%87%D0%B5%D0%BD%D0%B8%D0%B5\">\u043c\u0430\u0448\u0438\u043d\u043d\u044b\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c<\/a>.  <\/p>\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-202090","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/202090","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=202090"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/202090\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=202090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=202090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=202090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}