{"id":286236,"date":"2017-05-12T15:05:05","date_gmt":"2017-05-12T11:05:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=286236"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=286236","title":{"rendered":"\u041c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f"},"content":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/b33\/683\/d49\/b33683d495964ebb9ca8d413e60c4085.jpg\" align=\"right\"\/>   <\/p>\n<p>\u0412 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0430 \u0438\u0445 \u0432\u044b\u0431\u043e\u0440 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437 \u2014 \u043d\u0435\u043f\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0430\u0442\u0430\u0441\u0430\u0442\u0430\u043d\u0438\u0441\u0442\u0430. <\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043e\u0431\u0441\u0443\u0434\u0438\u043c, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u044b\u043c \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438 \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0439\u0442\u0438 \u043d\u0435 \u0442\u0430\u043a. <\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0430\u0442\u0435\u0439 \u0441\u0435\u0440\u0438\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<ol>\n<li><a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/322626\/\">\u041f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 Pandas<\/a><\/li>\n<li><a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/323210\/\">\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 c Python<\/a><\/li>\n<li><a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/322534\/\">\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u043c\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=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/323890\/\">\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/a><\/li>\n<li><a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/324402\/\">\u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438: \u0431\u044d\u0433\u0433\u0438\u043d\u0433, \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043b\u0435\u0441<\/a><\/li>\n<li><a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/325422\/\">\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u0431\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432<\/a><\/li>\n<li><a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/325654\/\">\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0431\u0435\u0437 \u0443\u0447\u0438\u0442\u0435\u043b\u044f: PCA, \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/a><\/li>\n<li><a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/326418\/\">\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u0445 c Vowpal Wabbit<\/a><\/li>\n<li><a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/327242\/\">\u0410\u043d\u0430\u043b\u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python<\/a><\/li>\n<li>\u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0431\u0443\u0441\u0442\u0438\u043d\u0433<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h1 id=\"metriki-v-zadachah-klassifikacii\">\u041c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/h1>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <em>sklearn<\/em> \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 <a href=\"https:\/\/bigml.com\/user\/francisco\/gallery\/dataset\/5163ad540c0b5e5b22000383\">\u0434\u0430\u0442\u0430\u0441\u0435\u0442<\/a> \u043f\u043e \u043e\u0442\u0442\u043e\u043a\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0442\u0435\u043b\u0435\u043a\u043e\u043c-\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 <a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/322626\/\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043a\u0443\u0440\u0441\u0430.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>import pandas as pd import matplotlib.pyplot as plt from matplotlib.pylab import rc, plot import seaborn as sns from sklearn.preprocessing import LabelEncoder, OneHotEncoder from sklearn.model_selection import cross_val_score from sklearn.linear_model import LogisticRegression from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier from sklearn.metrics import precision_recall_curve, classification_report from sklearn.model_selection import train_test_split  df = pd.read_csv('..\/..\/data\/telecom_churn.csv') <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code>df.head(5)<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/cc3\/55e\/98b\/cc355e98bdac4b8a9e0a12261b5f849b.png\"\/>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code># \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a  # \u0438 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c dummy-\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0448\u0442\u0430\u0442 (\u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b, \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a \u0434\u043b\u044f \u0434\u0435\u0440\u0435\u0432\u044f\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439)  d = {'Yes' : 1, 'No' : 0}  df['International plan'] = df['International plan'].map(d) df['Voice mail plan'] = df['Voice mail plan'].map(d) df['Churn'] = df['Churn'].astype('int64')  le = LabelEncoder() df['State'] = le.fit_transform(df['State'])  ohe = OneHotEncoder(sparse=False)  encoded_state = ohe.fit_transform(df['State'].values.reshape(-1, 1)) tmp = pd.DataFrame(encoded_state,                      columns=['state ' + str(i) for i in range(encoded_state.shape[1])]) df = pd.concat([df, tmp], axis=1)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2 id=\"accuracy-precision-i-recall\">Accuracy, precision \u0438 recall<\/h2>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u043c \u043a \u0441\u0430\u043c\u0438\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u0432\u0430\u0436\u043d\u0443\u044e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u2014 <em>confusion matrix<\/em> (\u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043e\u0448\u0438\u0431\u043e\u043a).<br \/>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0442\u043e\u0433\u0434\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/447\/bea\/1c7\/447bea1c7af9dca25d20da8fede95184.svg\" alt=\"$y = 1$\" data-tex=\"inline\"\/><\/math><\/th>\n<th><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/12a\/4a8\/632\/12a4a86327cbde9aa9fec271ce37a205.svg\" alt=\"$y = 0$\" data-tex=\"inline\"\/><\/math><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/818\/8c3\/192\/8188c3192189c41564bd2ae4a03a9d91.svg\" alt=\"$\\hat y = 1$\" data-tex=\"inline\"\/><\/math><\/td>\n<td>True Positive (TP)<\/td>\n<td>False Positive (FP)<\/td>\n<\/tr>\n<tr>\n<td><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/74d\/5cb\/ba3\/74d5cbba34162f133a65cbbe32164dd7.svg\" alt=\"$\\hat y = 0$\" data-tex=\"inline\"\/><\/math><\/td>\n<td>False Negative (FN)<\/td>\n<td>True Negative (TN)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8b1\/e99\/65f\/8b1e9965f298b958fcd6ae9f77c60704.svg\" alt=\"$\\hat y$\" data-tex=\"inline\"\/><\/math> \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0435, \u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1e6\/829\/a25\/1e6829a256c8a2712f849dc1d2343b62.svg\" alt=\"$y$\" data-tex=\"inline\"\/><\/math> \u2014 \u0438\u0441\u0442\u0438\u043d\u043d\u0430\u044f \u043c\u0435\u0442\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430 \u044d\u0442\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435.<br \/>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0431\u044b\u0432\u0430\u044e\u0442 \u0434\u0432\u0443\u0445 \u0432\u0438\u0434\u043e\u0432: False Negative (FN) \u0438 False Positive (FP).<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043e\u0448\u0438\u0431\u043e\u043a<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>X = df.drop('Churn', axis=1) y = df['Churn']  # \u0414\u0435\u043b\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043d\u0430 train \u0438 test, \u0432\u0441\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435  X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y,  test_size=0.33, random_state=42)  # \u041e\u0431\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u0432\u0448\u0443\u044e \u0440\u043e\u0434\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e  lr = LogisticRegression(random_state=42) lr.fit(X_train, y_train)  # \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043e\u0448\u0438\u0431\u043e\u043a \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 sklearn  def plot_confusion_matrix(cm, classes,                           normalize=False,                           title='Confusion matrix',                           cmap=plt.cm.Blues):     &quot;&quot;&quot;     This function prints and plots the confusion matrix.     Normalization can be applied by setting `normalize=True`.     &quot;&quot;&quot;     plt.imshow(cm, interpolation='nearest', cmap=cmap)     plt.title(title)     plt.colorbar()     tick_marks = np.arange(len(classes))     plt.xticks(tick_marks, classes, rotation=45)     plt.yticks(tick_marks, classes)      if normalize:         cm = cm.astype('float') \/ cm.sum(axis=1)[:, np.newaxis]         print(&quot;Normalized confusion matrix&quot;)     else:         print('Confusion matrix, without normalization')      print(cm)      thresh = cm.max() \/ 2.     for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):         plt.text(j, i, cm[i, j],                  horizontalalignment=&quot;center&quot;,                  color=&quot;white&quot; if cm[i, j] &gt; thresh else &quot;black&quot;)      plt.tight_layout()     plt.ylabel('True label')     plt.xlabel('Predicted label')  font = {'size' : 15}  plt.rc('font', **font)  cnf_matrix = confusion_matrix(y_test, lr.predict(X_test)) plt.figure(figsize=(10, 8)) plot_confusion_matrix(cnf_matrix, classes=['Non-churned', 'Churned'],                       title='Confusion matrix') plt.savefig(&quot;conf_matrix.png&quot;) plt.show() <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/37d\/d24\/a92\/37dd24a92c8e4fe1aaebe31618930473.png\" width=\"80%\" height=\"80%\" \/><\/div>\n<p>  <\/p>\n<h4 id=\"accuracy\">Accuracy<\/h4>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0439 \u0438 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f accuracy \u2014 \u0434\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/3a6\/cb8\/2da\/3a6cb82da231408bd4c38a70e59fb1d8.svg\" alt=\"$\\large accuracy = \\frac{TP + TN}{TP + TN + FP + FN}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u0441 \u043d\u0435\u0440\u0430\u0432\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0438 \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u043f\u0430\u043c-\u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u043f\u043e\u0447\u0442\u044b. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 100 \u043d\u0435-\u0441\u043f\u0430\u043c \u043f\u0438\u0441\u0435\u043c, 90 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b \u0432\u0435\u0440\u043d\u043e (True Negative = 90, False Positive = 10) \u0438 10 \u0441\u043f\u0430\u043c-\u043f\u0438\u0441\u0435\u043c, 5 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b \u0432\u0435\u0440\u043d\u043e (True Positive = 5, False Negative = 5).<br \/>  \u0422\u043e\u0433\u0434\u0430 accuracy:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/35f\/ff7\/01d\/35fff701dae36207f6bf3d536f366fc1.svg\" alt=\"$\\ accuracy = \\frac{5 + 90}{5 + 90 + 10 + 5} = 86,4% $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u0438\u0441\u044c\u043c\u0430 \u043a\u0430\u043a \u043d\u0435-\u0441\u043f\u0430\u043c, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0443\u044e accuracy:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6fc\/81d\/a6e\/6fc81da6e0a9354fca9491b22b3981f4.svg\" alt=\"$\\ accuracy = \\frac{0 + 100}{0 + 100 + 0 + 10} = 90,9% $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0438\u043b\u043e\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0438\u0441\u044c\u043c\u0430 \u0441\u043e \u0441\u043f\u0430\u043c\u043e\u043c. \u041f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0442\u044c \u044d\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u043e\u0431\u0449\u0435\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<p>  <\/p>\n<h4 id=\"precision-recall-i-f-mera\">Precision, recall \u0438 F-\u043c\u0435\u0440\u0430<\/h4>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0432\u0432\u0435\u0434\u0435\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 precision (\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c) \u0438 recall (\u043f\u043e\u043b\u043d\u043e\u0442\u0430).<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/164\/93b\/c89\/16493bc899f7275f3b5ff8d45a3ed2e2.svg\" alt=\"$\\large precision = \\frac{TP}{TP + FP}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/258\/4e7\/8f3\/2584e78f32225eade5cb8b1b4a665193.svg\" alt=\"$\\large recall = \\frac{TP}{TP + FN}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>Precision \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0434\u043e\u043b\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043d\u0430\u0437\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u0430 recall \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a\u0443\u044e \u0434\u043e\u043b\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0437 \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430\u0448\u0435\u043b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/38e\/9d4\/892\/38e9d4892d9241ea95e1f56e3ef9124c.png\" \/><\/div>\n<p>  <\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 precision \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u043e\u0441\u0442 \u0443\u0440\u043e\u0432\u043d\u044f False Positive. Recall \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432\u043e\u043e\u0431\u0449\u0435, \u0430 precision \u2014 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. <\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u044b \u043e\u0442\u043c\u0435\u0447\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435, \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0431\u044b\u0432\u0430\u044e\u0442 \u0434\u0432\u0443\u0445 \u0432\u0438\u0434\u043e\u0432: False Positive \u0438 False Negative. \u0412 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0438\u0434 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 I-\u0433\u043e \u0440\u043e\u0434\u0430, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 II-\u0433\u043e \u0440\u043e\u0434\u0430. \u0412 \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u043e\u0442\u0442\u043e\u043a\u0430 \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u0435 \u043b\u043e\u044f\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u0430 \u0437\u0430 \u0443\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448\u0430 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Type_I_and_type_II_errors\">\u043d\u0443\u043b\u0435\u0432\u0430\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430<\/a> \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u0438\u0437 \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u043e\u0442\u0442\u0435\u043a\u0430\u0435\u0442, \u0430 \u043c\u044b \u044d\u0442\u0443 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0443 \u043e\u0442\u0432\u0435\u0440\u0433\u0430\u0435\u043c. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f &quot;\u043f\u0440\u043e\u043f\u0443\u0441\u043a&quot; \u0443\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u0430 \u0438 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b.<\/p>\n<p>  <\/p>\n<p>Precision \u0438 recall \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 accuracy, \u043e\u0442 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043f\u043e\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043d\u0435\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0431\u043e\u0440\u043e\u043a.<br \/>  \u0427\u0430\u0441\u0442\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430\u0439\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 (\u0434\u043b\u044f \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430) \u0431\u0430\u043b\u0430\u043d\u0441 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c\u0438. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0442\u043e\u043a\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432.<br \/>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c <strong>\u0432\u0441\u0435\u0445<\/strong> \u0443\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u043e\u0442\u0442\u043e\u043a \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 <strong>\u0442\u043e\u043b\u044c\u043a\u043e<\/strong> \u0438\u0445. \u041d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u0438 \u0440\u0435\u0441\u0443\u0440\u0441 \u0434\u043b\u044f \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u043e\u0440\u043e\u0433\u0438 \u043f\u043e precision \u0438 recall. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0441\u043e\u043a\u043e\u0434\u043e\u0445\u043e\u0434\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0442\u0435\u0445, \u043a\u0442\u043e \u043e\u0442\u0442\u0435\u0447\u0451\u0442 \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u043a\u043e\u043b\u043b-\u0446\u0435\u043d\u0442\u0440\u0430.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u043f\u043e \u0441\u0435\u0442\u043a\u0435 <a href=\"http:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.model_selection.GridSearchCV.html\"><em>GridSearchCV<\/em><\/a> ) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430, \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435.<br \/>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c precision \u0438 recall \u0432 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430. F-\u043c\u0435\u0440\u0430 (\u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7c3\/bf7\/0f2\/7c3bf70f29a2fa3bc5f72bd3dcf3a579.svg\" alt=\"$\\ F_\\beta$\" data-tex=\"inline\"\/><\/math>) \u2014 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0433\u0430\u0440\u043c\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0435 precision \u0438 recall :<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4f1\/f5c\/0ab\/4f1f5c0ab5dcf8379ff4bcbbd02f0623.svg\" alt=\"$\\large \\ F_\\beta = (1 + \\beta^2) \\cdot \\frac{precision \\cdot recall}{(\\beta^2 \\cdot precision) + recall}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f39\/05b\/5cf\/f3905b5cfab08d98b2d380d5ea75c66c.svg\" alt=\"$\\beta$\" data-tex=\"inline\"\/><\/math> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0435\u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0432 \u043c\u0435\u0442\u0440\u0438\u043a\u0435 \u0438 \u043f\u0440\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a66\/57a\/5ad\/a6657a5ad779fd051b6a6b0fe3464c51.svg\" alt=\"$\\beta = 1$\" data-tex=\"inline\"\/><\/math> \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0433\u0430\u0440\u043c\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0435 (\u0441 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0435\u043c 2, \u0447\u0442\u043e\u0431\u044b \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 precision = 1 \u0438 recall = 1 \u0438\u043c\u0435\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8eb\/d7a\/a05\/8ebd7aa050e5cab1d1d63f1eb7f1e366.svg\" alt=\"$\\ F_1 = 1$\" data-tex=\"inline\"\/><\/math>)<br \/>  F-\u043c\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430 \u043f\u0440\u0438 \u043f\u043e\u043b\u043d\u043e\u0442\u0435 \u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u0440\u0430\u0432\u043d\u044b\u043c\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0438 \u0431\u043b\u0438\u0437\u043a\u0430 \u043a \u043d\u0443\u043b\u044e, \u0435\u0441\u043b\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0431\u043b\u0438\u0437\u043e\u043a \u043a \u043d\u0443\u043b\u044e.<br \/>  \u0412 sklearn \u0435\u0441\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f _metrics.classification<em>report<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f recall, precision \u0438 F-\u043c\u0435\u0440\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<pre><code>report = classification_report(y_test, lr.predict(X_test), target_names=['Non-churned', 'Churned']) print(report) <\/code><\/pre>\n<p>  <\/p>\n<table>\n<thead>\n<tr>\n<th>class<\/th>\n<th>precision<\/th>\n<th>recall<\/th>\n<th>f1-score<\/th>\n<th>support<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Non-churned<\/td>\n<td>0.88<\/td>\n<td>0.97<\/td>\n<td>0.93<\/td>\n<td>941<\/td>\n<\/tr>\n<tr>\n<td>Churned<\/td>\n<td>0.60<\/td>\n<td>0.25<\/td>\n<td>0.35<\/td>\n<td>159<\/td>\n<\/tr>\n<tr>\n<td>avg \/ total<\/td>\n<td>0.84<\/td>\n<td>0.87<\/td>\n<td>0.84<\/td>\n<td>1100<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430\u0434\u0430\u0447 \u0441 \u043d\u0435\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0432\u0430\u043b\u0438\u0440\u0443\u044e\u0442 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u0442\u044c \u043a \u0442\u0435\u0445\u043d\u0438\u043a\u0430\u043c \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0418\u0445 \u043c\u043d\u043e\u0433\u043e \u0438 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0445 \u043a\u0430\u0441\u0430\u0442\u044c\u0441\u044f, <a href=\"http:\/\/contrib.scikit-learn.org\/imbalanced-learn\/\">\u0437\u0434\u0435\u0441\u044c<\/a> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  <\/p>\n<h4 id=\"auc-roc-i-auc-pr\">AUC-ROC \u0438 AUC-PR<\/h4>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 (\u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043a \u043a\u043b\u0430\u0441\u0441\u0443, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u043c. <a href=\"http:\/\/scikit-learn.org\/stable\/modules\/svm.html#scores-probabilities\">SVM<\/a>) \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u0443\u044e \u043c\u0435\u0442\u043a\u0443, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043f\u043e\u0440\u043e\u0433, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c 0 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f 1. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438 \u0431\u043b\u0438\u0437\u043a\u0438\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043e\u0440\u043e\u0433, \u0440\u0430\u0432\u043d\u044b\u0439 0.5, \u043d\u043e \u043e\u043d \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0431\u0430\u043b\u0430\u043d\u0441\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u0446\u0435\u043b\u043e\u043c, \u043d\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u044f\u0441\u044c \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u043f\u043e\u0440\u043e\u0433\u0443, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f AUC-ROC (\u0438\u043b\u0438 ROC AUC) \u2014 \u043f\u043b\u043e\u0449\u0430\u0434\u044c (<em>A<\/em>rea <em>U<\/em>nder <em>C<\/em>urve) \u043f\u043e\u0434 \u043a\u0440\u0438\u0432\u043e\u0439 \u043e\u0448\u0438\u0431\u043e\u043a (<em>R<\/em>eceiver <em>O<\/em>perating <em>C<\/em>haracteristic curve ). \u0414\u0430\u043d\u043d\u0430\u044f \u043a\u0440\u0438\u0432\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u043b\u0438\u043d\u0438\u044e \u043e\u0442 (0,0) \u0434\u043e (1,1) \u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u0445 True Positive Rate (TPR) \u0438 False Positive Rate (FPR):<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/71e\/20f\/f85\/71e20ff859277c93efc4a1cb20fd4f7a.svg\" alt=\"$\\large TPR = \\frac{TP}{TP + FN}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f75\/d27\/d27\/f75d27d279b274eedc5004a691ccb18a.svg\" alt=\"$\\large FPR = \\frac{FP}{FP + TN}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>TPR \u043d\u0430\u043c \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430, \u044d\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0442\u0430, \u0430 FPR \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a\u0443\u044e \u0434\u043e\u043b\u044e \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 negative \u043a\u043b\u0430\u0441\u0441\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043b \u043d\u0435\u0432\u0435\u0440\u043d\u043e. \u0412 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043e\u043a (FPR = 0, TPR = 1) \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u043b\u043e\u0449\u0430\u0434\u044c \u043f\u043e\u0434 \u043a\u0440\u0438\u0432\u043e\u0439, \u0440\u0430\u0432\u043d\u0443\u044e \u0435\u0434\u0438\u043d\u0438\u0446\u0435, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0434\u0430\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, AUC-ROC \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u044c\u0441\u044f \u043a 0.5, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e TP \u0438 FP.<br \/>  \u041a\u0430\u0436\u0434\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u044b\u0431\u043e\u0440\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u0430. \u041f\u043b\u043e\u0449\u0430\u0434\u044c \u043f\u043e\u0434 \u043a\u0440\u0438\u0432\u043e\u0439 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 (\u0431\u043e\u043b\u044c\u0448\u0435 \u2014 \u043b\u0443\u0447\u0448\u0435), \u043a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0432\u0430\u0436\u043d\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u0443\u0442\u0438\u0437\u043d\u0430 \u0441\u0430\u043c\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 \u2014 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c TPR, \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f FPR, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u043d\u0430\u0448\u0430 \u043a\u0440\u0438\u0432\u0430\u044f \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u044c\u0441\u044f \u043a \u0442\u043e\u0447\u043a\u0435 (0,1).<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 ROC-\u043a\u0440\u0438\u0432\u043e\u0439<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>sns.set(font_scale=1.5) sns.set_color_codes(&quot;muted&quot;)  plt.figure(figsize=(10, 8)) fpr, tpr, thresholds = roc_curve(y_test, lr.predict_proba(X_test)[:,1], pos_label=1) lw = 2 plt.plot(fpr, tpr, lw=lw, label='ROC curve ') plt.plot([0, 1], [0, 1]) plt.xlim([0.0, 1.0]) plt.ylim([0.0, 1.05]) plt.xlabel('False Positive Rate') plt.ylabel('True Positive Rate') plt.title('ROC curve') plt.savefig(&quot;ROC.png&quot;) plt.show() <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/299\/157\/fad\/299157fad56a4ecca8f6b96b425bd38c.png\" width=\"80%\" height=\"80%\" \/><\/div>\n<p>  <\/p>\n<p>\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0439 AUC-ROC \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432 \u043a \u043d\u0435\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c (\u0441\u043f\u043e\u0439\u043b\u0435\u0440: \u0443\u0432\u044b, \u043d\u043e \u043d\u0435 \u0432\u0441\u0451 \u0442\u0430\u043a \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e) \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 positive \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u0448\u0435 (\u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u0442\u044c positive), \u0447\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 negative \u043e\u0431\u044a\u0435\u043a\u0442. <\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443: \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c 100 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b\u0445 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 1 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041c\u044b \u043d\u0430\u043c\u0430\u0448\u0438\u043d\u043b\u0435\u0440\u043d\u0438\u043b\u0438 \u0434\u0432\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li><strong> \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c 1 <\/strong> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 100 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, 90 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, <\/li>\n<\/ul>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/025\/614\/701\/025614701b5a3780f0284941f27807af.svg\" alt=\"$ TPR = \\frac{TP}{TP + FN} = \\frac{90}{90 + 10} = 0.9$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/069\/ba6\/64f\/069ba664fd6cf79f32077d8d97e82822.svg\" alt=\"$ FPR = \\frac{FP}{FP + TN} = \\frac{10}{10 + 999890} = 0.00001$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<ul>\n<li><strong> \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c 2 <\/strong> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 2000 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, 90 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, <\/li>\n<\/ul>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/025\/614\/701\/025614701b5a3780f0284941f27807af.svg\" alt=\"$ TPR = \\frac{TP}{TP + FN} = \\frac{90}{90 + 10} = 0.9$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8b9\/2d6\/8c6\/8b92d68c64dd425e82a61736a193bad3.svg\" alt=\"$ FPR = \\frac{FP}{FP + TN} = \\frac{1910}{1910 + 997990} = 0.00191$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043c\u044b \u0431\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0434\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e False Positive \u043d\u0430 \u0444\u043e\u043d\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u0430. \u041d\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 False Positive Rate \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 <em>\u043a\u0440\u0430\u0439\u043d\u0435<\/em> \u043c\u0430\u043b\u0430 \u2014 \u0432\u0441\u0435\u0433\u043e 0.0019. \u042d\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e AUC-ROC \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442 \u0434\u043e\u043b\u044e False Positive \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e True Negative \u0438 \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445, \u0433\u0434\u0435 \u043d\u0430\u043c \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u0435\u043d \u0432\u0442\u043e\u0440\u043e\u0439 (\u0431\u043e\u043b\u044c\u0448\u0438\u0439) \u043a\u043b\u0430\u0441\u0441, \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043f\u043e\u043b\u043d\u043e\u0442\u0435 \u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 :<\/p>\n<p>  <\/p>\n<ul>\n<li><strong> \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c 1 <\/strong> <\/li>\n<\/ul>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f0f\/ee9\/2db\/f0fee92db0bbd42834e684013d6c7adb.svg\" alt=\"$\\ precision = \\frac{TP}{TP + FP} = 90\/(90 + 10) = 0.9 $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/525\/b48\/226\/525b482263b78da07ec0413edd70d16b.svg\" alt=\"$\\ recall = \\frac{TP}{TP + FN} = 90\/(90 + 10) = 0.9 $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<ul>\n<li><strong> \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c 2 <\/strong> <\/li>\n<\/ul>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d91\/2da\/f29\/d912daf29a8d59b4641930add0b284d3.svg\" alt=\"$\\ precision = \\frac{TP}{TP + FP} = \\frac{90}{90 + 1910} = 0.045 $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/169\/a14\/cf3\/169a14cf303ee39cfc422a779e37b55d.svg\" alt=\"$\\ recall = \\frac{TP}{TP + FN} = \\frac{90}{90 + 10} = 0.9 $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0443\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u2014 0.855 \u0432 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438!<\/p>\n<p>  <\/p>\n<p>Precision \u0438 recall \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0432\u043e\u0439 \u0438, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e AUC-ROC, \u043d\u0430\u0445\u043e\u0434\u044f\u0442 \u043f\u043b\u043e\u0449\u0430\u0434\u044c \u043f\u043e\u0434 \u043d\u0435\u0439. <\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/887\/356\/914\/8873569147c24b49a2b7fa9ae883f20f.png\" width=\"80%\" height=\"80%\" \/><\/div>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 \u043f\u043b\u043e\u0449\u0430\u0434\u044c \u043f\u043e\u0434 PR-\u043a\u0440\u0438\u0432\u043e\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0435\u0440\u0435\u0441\u0447\u0443\u0440 \u043e\u043f\u0442\u0438\u043c\u0438\u0441\u0442\u0438\u0447\u043d\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u0442\u0440\u0430\u043f\u0435\u0446\u0438\u0439, \u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0432 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u0417\u0430 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043e \u0432\u0437\u0430\u0438\u043c\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u0445 AUC-ROC \u0438 AUC-PR \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f <a href=\"http:\/\/pages.cs.wisc.edu\/~jdavis\/davisgoadrichcamera2.pdf\">\u0441\u044e\u0434\u0430<\/a>.<\/p>\n<p>  <\/p>\n<h4 id=\"logistic-loss\">Logistic Loss<\/h4>\n<p>  <\/p>\n<p>\u041e\u0441\u043e\u0431\u043d\u044f\u043a\u043e\u043c \u0441\u0442\u043e\u0438\u0442 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u043a\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c54\/acb\/f01\/c54acbf01a8ad65e36a632819be32a2b.svg\" alt=\"$\\large logloss = - \\frac{1}{l} \\cdot \\sum_{i=1}^l (y_i \\cdot log(\\hat y_i) + (1 - y_i) \\cdot log(1 - \\hat y_i))$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0437\u0434\u0435\u0441\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8b1\/e99\/65f\/8b1e9965f298b958fcd6ae9f77c60704.svg\" alt=\"$\\hat y$\" data-tex=\"inline\"\/><\/math> \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/721\/95b\/0db\/72195b0dbc8d5e1fbd3b06fd91ae2dba.svg\" alt=\"$i$\" data-tex=\"inline\"\/><\/math>-\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435, <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1e6\/829\/a25\/1e6829a256c8a2712f849dc1d2343b62.svg\" alt=\"$y$\" data-tex=\"inline\"\/><\/math> \u0438\u0441\u0442\u0438\u043d\u043d\u0430\u044f \u043c\u0435\u0442\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/721\/95b\/0db\/72195b0dbc8d5e1fbd3b06fd91ae2dba.svg\" alt=\"$i$\" data-tex=\"inline\"\/><\/math>-\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435, \u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ce3\/8a8\/387\/ce38a83878bf16954ea60627fc7c66eb.svg\" alt=\"$l$\" data-tex=\"inline\"\/><\/math> \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044e \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 <a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/323890\/#princip-maksimalnogo-pravdopodobiya-i-logisticheskaya-regressiya\">\u043f\u043e\u0441\u0442\u0430<\/a> \u043f\u0440\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.<br \/>  \u0414\u0430\u043d\u043d\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043d\u0435\u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u0445, \u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043d\u0430 <a href=\"http:\/\/kaggle.com\">kaggle<\/a>.<br \/>  \u0418\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e logloss \u043a\u0430\u043a \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 accuracy \u043f\u0443\u0442\u0435\u043c \u0448\u0442\u0440\u0430\u0444\u0430 \u0437\u0430 \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e logloss \u043a\u0440\u0430\u0439\u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0448\u0442\u0440\u0430\u0444\u0443\u0435\u0442 \u0437\u0430 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0432 \u043d\u0435\u0432\u0435\u0440\u043d\u043e\u043c \u043e\u0442\u0432\u0435\u0442\u0435.<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code>def logloss_crutch(y_true, y_pred, eps=1e-15):      return - (y_true * np.log(y_pred) + (1 - y_true) * np.log(1 - y_pred))  print('Logloss \u043f\u0440\u0438 \u043d\u0435\u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 %f' % logloss_crutch(1, 0.5)) &gt;&gt; Logloss \u043f\u0440\u0438 \u043d\u0435\u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 0.693147  print('Logloss \u043f\u0440\u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0432\u0435\u0440\u043d\u043e\u043c \u043e\u0442\u0432\u0435\u0442\u0435 %f' % logloss_crutch(1, 0.9)) &gt;&gt; Logloss \u043f\u0440\u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0432\u0435\u0440\u043d\u043e\u043c \u043e\u0442\u0432\u0435\u0442\u0435 0.105361  print('Logloss \u043f\u0440\u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u041d\u0415\u0432\u0435\u0440\u043d\u043e\u043c \u043e\u0442\u0432\u0435\u0442\u0435 %f' % logloss_crutch(1, 0.1)) &gt;&gt; Logloss \u043f\u0440\u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u041d\u0415\u0432\u0435\u0440\u043d\u043e\u043c \u043e\u0442\u0432\u0435\u0442\u0435 2.302585<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u043c\u0435\u0442\u0438\u043c \u043a\u0430\u043a \u0434\u0440\u0430\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0440\u043e\u0441\u043b\u0430 logloss \u043f\u0440\u0438 \u043d\u0435\u0432\u0435\u0440\u043d\u043e\u043c \u043e\u0442\u0432\u0435\u0442\u0435 \u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438!<br \/>  \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0443\u0445\u0443\u0434\u0448\u0435\u043d\u0438\u0435 \u043e\u0431\u0449\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0435. \u0422\u0430\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u044e\u0442 \u0432\u044b\u0431\u0440\u043e\u0441\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<br \/>  \u0412\u0441\u0451 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0432\u043e\u0438 \u043c\u0435\u0441\u0442\u0430, \u0435\u0441\u043b\u0438 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a logloss:<\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/0fb\/e4e\/da3\/0fbe4eda3cb3469c8d02c837b53e564e.png\" width=\"80%\" height=\"80%\" \/><\/div>\n<p>  <\/p>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e, \u0447\u0435\u043c \u0431\u043b\u0438\u0436\u0435 \u043a \u043d\u0443\u043b\u044e \u043e\u0442\u0432\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u0440\u0438 ground truth = 1, \u0442\u0435\u043c \u0432\u044b\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u043a\u0440\u0443\u0447\u0435 \u0440\u0430\u0441\u0442\u0451\u0442 \u043a\u0440\u0438\u0432\u0430\u044f.<\/p>\n<p>  <\/p>\n<h2 id=\"podytozhivaya\">\u041f\u043e\u0434\u044b\u0442\u043e\u0436\u0438\u0432\u0430\u044f:<\/h2>\n<p>  <\/p>\n<ul>\n<li>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043d\u043e\u0433\u043e\u043a\u043b\u0430\u0441\u0441\u043e\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f <strong>\u0437\u0430\u0434\u0430\u0447\u0438<\/strong>, \u0430 \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438<\/li>\n<li>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0440\u0430\u0432\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043e\u0442\u0440\u0430\u0436\u0430\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/li>\n<li>\u0412\u044b\u0431\u043e\u0440 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0444\u043e\u043a\u0443\u0441\u043e\u043c \u043d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044f (\u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u0431\u043e\u0433\u0430\u0442\u044b\u0445 \u0438 \u0431\u0435\u0434\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432)<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"poleznye-ssylki\">\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  <\/p>\n<ol>\n<li>\u041a\u0443\u0440\u0441 \u0415\u0432\u0433\u0435\u043d\u0438\u044f \u0421\u043e\u043a\u043e\u043b\u043e\u0432\u0430: <a href=\"https:\/\/github.com\/esokolov\/ml-course-msu\/blob\/master\/ML15\/lecture-notes\/Sem05_metrics.pdf\">\u0421\u0435\u043c\u0438\u043d\u0430\u0440 \u043f\u043e \u0432\u044b\u0431\u043e\u0440\u0443 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/a> (\u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c \u0437\u0430\u0434\u0430\u0447 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438)<\/li>\n<li><a href=\"https:\/\/alexanderdyakonov.wordpress.com\/2015\/10\/09\/%D0%B7%D0%B0%D0%B4%D0%B0%D1%87%D0%BA%D0%B8-%D0%BF%D1%80%D0%BE-auc-roc\/\">\u0417\u0430\u0434\u0430\u0447\u043a\u0438<\/a> \u043d\u0430 AUC-ROC \u043e\u0442 \u0410.\u0413. \u0414\u044c\u044f\u043a\u043e\u043d\u043e\u0432\u0430 <\/li>\n<li>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 <a href=\"https:\/\/www.kaggle.com\/wiki\/Metrics\">kaggle<\/a>. \u041a \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f, \u0433\u0434\u0435 \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c<\/li>\n<li><a href=\"https:\/\/ld86.github.io\/ml-slides\/unbalanced.html#\/\">\u041f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/a> \u0411\u043e\u0433\u0434\u0430\u043d\u0430 \u041c\u0435\u043b\u044c\u043d\u0438\u043a\u0430 aka <a href=\"https:\/\/habrahabr.ru\/users\/ld86\/\" class=\"user_link\">ld86<\/a> \u043f\u0440\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u0435\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445<\/li>\n<\/ol>\n<p>  <\/p>\n<h2 id=\"blagodarnosti\">\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u0438<\/h2>\n<p>  <\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e <a href=\"https:\/\/habrahabr.ru\/users\/mephistopheies\/\" class=\"user_link\">mephistopheies<\/a> \u0438 <a href=\"https:\/\/habrahabr.ru\/users\/madrugado\/\" class=\"user_link\">madrugado<\/a> \u0437\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u0432 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/328372\/\"> https:\/\/habrahabr.ru\/post\/328372\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/b33\/683\/d49\/b33683d495964ebb9ca8d413e60c4085.jpg\" align=\"right\"\/>   <\/p>\n<p>\u0412 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0430 \u0438\u0445 \u0432\u044b\u0431\u043e\u0440 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437 \u2014 \u043d\u0435\u043f\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0430\u0442\u0430\u0441\u0430\u0442\u0430\u043d\u0438\u0441\u0442\u0430. <\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043e\u0431\u0441\u0443\u0434\u0438\u043c, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u044b\u043c \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438 \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0439\u0442\u0438 \u043d\u0435 \u0442\u0430\u043a. <\/p>\n<p>  <\/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-286236","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286236","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=286236"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286236\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}