{"id":283611,"date":"2017-03-20T19:40:04","date_gmt":"2017-03-20T16:40:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=283611"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=283611","title":{"rendered":"\u041e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u0443\u0440\u0441 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0422\u0435\u043c\u0430 4. \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"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/256\/a5d\/ed0\/256a5ded03274e0f87ccf97164c31c35.png\" align=\"right\" width=\"45%\"\/>  <\/p>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u2013 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445.<br \/>  \u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043d\u0430\u0448\u0435\u0439 \u043f\u043e\u0434\u0430\u0447\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043e\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0433\u043e \u0432 \u043a\u0443\u0440\u0441\u0430\u0445 \u044d\u043a\u043e\u043d\u043e\u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u2013 \u044d\u0442\u043e \u0430\u043a\u0446\u0435\u043d\u0442 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 (\u0445\u043e\u0442\u044f \u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043c\u0430\u043b\u043e). <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0432\u0443\u0445 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u2013 \u044d\u0442\u043e \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f Kaggle Inclass \u043f\u043e <a href=\"https:\/\/inclass.kaggle.com\/c\/howpop-habrahabr-favs-lognorm\">\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438<\/a> \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0438 \u043f\u043e <a href=\"https:\/\/inclass.kaggle.com\/c\/catch-me-if-you-can-intruder-detection-through-webpage-session-tracking\">\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u0437\u043b\u043e\u043c\u0449\u0438\u043a\u0430<\/a> \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043f\u043e \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u0441\u0430\u0439\u0442\u0430\u043c. \u0414\u043e\u043c\u0430\u0448\u043d\u0438\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0435\u043c \u21164 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u044d\u0442\u0438\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445. <\/p>\n<p>  <\/p>\n<p>\u0410 \u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 3 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u2013 \u0434\u043e 23:59 20 \u043c\u0430\u0440\u0442\u0430.<br \/>  \u0412\u0441\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 <a href=\"https:\/\/github.com\/Yorko\/mlcourse_open\">GitHub<\/a>.<\/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>\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. \u041a\u0440\u0438\u0432\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/li>\n<li>\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, \u043f\u043e\u0438\u0441\u043a \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439<\/li>\n<li>\u0418\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u0431\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0430, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0433\u0435\u043e-\u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043b\u0430\u043d \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<br \/> \n<ul>\n<li>\u041c\u0435\u0442\u043e\u0434 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432<\/li>\n<li>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f<\/li>\n<li>\u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0438 \u0440\u0430\u0437\u0431\u0440\u043e\u0441 (Bias-variance decomposition)<\/li>\n<li>\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/li>\n<\/ul>\n<\/li>\n<li>\u041b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<br \/> \n<ul>\n<li>\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440<\/li>\n<li>\u041b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043a\u0430\u043a \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440<\/li>\n<li>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f \u0438 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/li>\n<li>L2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \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<\/li>\n<\/ul>\n<\/li>\n<li>\u041d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 <\/li>\n<li>\u0413\u0434\u0435 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0445\u043e\u0440\u043e\u0448\u0430 \u0438 \u0433\u0434\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c<\/li>\n<li>\u041a\u0440\u0438\u0432\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/li>\n<li>\u041f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/li>\n<li>\u0414\u043e\u043c\u0430\u0448\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u21164. \u0421\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f Kaggle Inclass<\/li>\n<li>\u041e\u0431\u0437\u043e\u0440 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/li>\n<\/ol>\n<p>  <\/p>\n<h1 id=\"1-lineynaya-regressiya\">1. \u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/h1>\n<p>  <\/p>\n<h3 id=\"metod-naimenshih-kvadratov\">\u041c\u0435\u0442\u043e\u0434 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432<\/h3>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043a\u0430\u0437 \u043f\u0440\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438. \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1e6\/829\/a25\/1e6829a256c8a2712f849dc1d2343b62.svg\" alt=\"$y$\" data-tex=\"inline\"\/><\/math> \u043e\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0438\u0445 \u0435\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e44\/304\/8fd\/e443048fd46cfeb75140164bc074428a.svg\" alt=\"$y = w_0 + \\sum_{i=1}^m w_i x_i$\" data-tex=\"inline\"\/><\/math>. \u0415\u0441\u043b\u0438 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f00\/94e\/a28\/f0094ea28e71d2088d2d0f240132da87.svg\" alt=\"$x_0 = 1$\" data-tex=\"inline\"\/><\/math> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f, \u0442\u043e\u0433\u0434\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e, \u0437\u0430\u043f\u0438\u0441\u0430\u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0447\u043b\u0435\u043d <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5ec\/533\/acf\/5ec533acf0f35024d8036be9294167b9.svg\" alt=\"$w_0$\" data-tex=\"inline\"\/><\/math> \u043f\u043e\u0434 \u0441\u0443\u043c\u043c\u0443: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/452\/da5\/bf4\/452da5bf4b8c7683a960685b7384fdc8.svg\" alt=\"$y = \\sum_{i=0}^m w_i x_i = \\vec{w}^T \\vec{x}$\" data-tex=\"inline\"\/><\/math>. \u0415\u0441\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f-\u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u0443\u044e \u043a\u043e\u043b\u043e\u043d\u043a\u0443 \u0441\u043b\u0435\u0432\u0430. \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f86\/cd4\/654\/f86cd4654ac6f030cb6d0b815031844c.svg\" alt=\"$\\large \\vec y = X \\vec w + \\epsilon,$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0433\u0434\u0435<\/p>\n<p>  <\/p>\n<ul>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1cd\/b3a\/1a5\/1cdb3a1a52446f8e049d844b679603ec.svg\" alt=\"$\\vec y \\in \\mathbb{R}^n$\" data-tex=\"inline\"\/><\/math> \u2013 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u043c\u0430\u044f (\u0438\u043b\u0438 \u0446\u0435\u043b\u0435\u0432\u0430\u044f) \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f;  <\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/43c\/d4a\/82f\/43cd4a82fba2d057ebc2d101242d68d5.svg\" alt=\"$w$\" data-tex=\"inline\"\/><\/math> \u2013 \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 (\u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u044d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u0435\u0441\u0430\u043c\u0438);  <\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bf\/a5b\/297\/6bfa5b2972cf556a719dca37a543fd04.svg\" alt=\"$X$\" data-tex=\"inline\"\/><\/math> \u2013 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/17e\/d16\/be1\/17ed16be17023e4cd19584781c333593.svg\" alt=\"$n$\" data-tex=\"inline\"\/><\/math> \u0441\u0442\u0440\u043e\u043a \u043d\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0e1\/09b\/de8\/0e109bde8c0c8e2db72d1f153a7a4658.svg\" alt=\"$m + 1$\" data-tex=\"inline\"\/><\/math> \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u0443\u044e \u043a\u043e\u043b\u043e\u043d\u043a\u0443 \u0441\u043b\u0435\u0432\u0430) \u0441 \u043f\u043e\u043b\u043d\u044b\u043c \u0440\u0430\u043d\u0433\u043e\u043c \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b6a\/fa8\/f0f\/b6afa8f0f98f9044742008a248c0a346.svg\" alt=\"$\\text{rank}\\left(X\\right) = m + 1$\" data-tex=\"inline\"\/><\/math>;  <\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e12\/dff\/45a\/e12dff45a7ed01bc64ba2aeb4d34a2bc.svg\" alt=\"$\\epsilon$\" data-tex=\"inline\"\/><\/math> \u2013 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439, \u043d\u0435\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.  <\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f02\/224\/2f9\/f022242f9d21f156d1f7ae879c4a80ea.svg\" alt=\"$\\large y_i = \\sum_{j=1}^m w_j X_{ij} + \\epsilon_i$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f (\u0438\u043d\u0430\u0447\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a\u0430\u044f \u0442\u043e \u0434\u0440\u0443\u0433\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f, \u043d\u043e \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f):<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043c\u0430\u0442\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5bc\/0a7\/b4a\/5bc0a7b4a91418683cc8f126100f227c.svg\" alt=\"$\\forall i: \\mathbb{E}\\left[\\epsilon_i\\right] = 0$\" data-tex=\"inline\"\/><\/math>;<\/li>\n<li>\u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u0430, \u044d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%93%D0%BE%D0%BC%D0%BE%D1%81%D0%BA%D0%B5%D0%B4%D0%B0%D1%81%D1%82%D0%B8%D1%87%D0%BD%D0%BE%D1%81%D1%82%D1%8C\">\u0433\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e<\/a>: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/758\/024\/7ff\/7580247ff01218325ee2a6759bf65de3.svg\" alt=\"$\\forall i: \\text{Var}\\left(\\epsilon_i\\right) = \\sigma^2 &lt; \\infty$\" data-tex=\"inline\"\/><\/math>;<\/li>\n<li>\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435 \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/90d\/e9d\/bb9\/90de9dbb9d688b9f2922e57f0053ee63.svg\" alt=\"$\\forall i \\neq j: \\text{Cov}\\left(\\epsilon_i, \\epsilon_j\\right) = 0$\" data-tex=\"inline\"\/><\/math>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u0446\u0435\u043d\u043a\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/934\/183\/a0f\/934183a0fa8b9a161ccf1fa6f3b8c7ac.svg\" alt=\"$\\hat{w}_i$\" data-tex=\"inline\"\/><\/math> \u0432\u0435\u0441\u043e\u0432 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2ff\/479\/70a\/2ff47970af6850903a417ec2ba13a917.svg\" alt=\"$w_i$\" data-tex=\"inline\"\/><\/math> \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439, \u0435\u0441\u043b\u0438<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6e2\/272\/041\/6e22720418977cfa5bbf4597e550a9b1.svg\" alt=\"$\\large \\hat{w}_i = \\omega_{1i}y_1 + \\omega_{2i}y_2 + \\cdots + \\omega_{1n}y_n,$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0433\u0434\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7af\/169\/ecb\/7af169ecb43e1aa20f3e93a99771f4e2.svg\" alt=\"$\\forall\\ k\\ \\omega_{ki}$\" data-tex=\"inline\"\/><\/math> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bf\/a5b\/297\/6bfa5b2972cf556a719dca37a543fd04.svg\" alt=\"$X$\" data-tex=\"inline\"\/><\/math> \u0438 \u043f\u043e\u0447\u0442\u0438 \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e. \u0422\u0430\u043a \u043a\u0430\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u0435\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430, \u0442\u043e \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0435\u0439<\/i>. \u0412\u0432\u0435\u0434\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u041e\u0446\u0435\u043d\u043a\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/934\/183\/a0f\/934183a0fa8b9a161ccf1fa6f3b8c7ac.svg\" alt=\"$\\hat{w}_i$\" data-tex=\"inline\"\/><\/math> \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043c\u0435\u0449\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043c\u0430\u0442\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043e\u0446\u0435\u043d\u043a\u0438 \u0440\u0430\u0432\u043d\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c\u0443, \u043d\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4b0\/f0b\/f2d\/4b0f0bf2daaa7f202679897762de3b31.svg\" alt=\"$\\large \\mathbb{E}\\left[\\hat{w}_i\\right] = w_i$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <b>\u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432<\/b> (\u041c\u041d\u041a), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u043c, \u0432\u044b\u0434\u0430\u043d\u043d\u044b\u043c \u043c\u043e\u0434\u0435\u043b\u044c\u044e:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/599\/424\/1d1\/5994241d1b081a49471592ce22f80742.svg\" alt=\"$\\large \\begin{array}{rcl}\\mathcal{L}\\left(X, \\vec{y}, \\vec{w} \\right) &amp;=&amp; \\frac{1}{2n} \\sum_{i=1}^n \\left(y_i - \\vec{w}^T \\vec{x}_i\\right)^2 \\\\ &amp;=&amp; \\frac{1}{2n} \\left\\| \\vec{y} - X \\vec{w} \\right\\|_2^2 \\\\ &amp;=&amp; \\frac{1}{2n} \\left(\\vec{y} - X \\vec{w}\\right)^T \\left(\\vec{y} - X \\vec{w}\\right) \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 \u043f\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u044f\u0442\u044c \u0438\u0445 \u043a \u043d\u0443\u043b\u044e \u0438 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6fc\/106\/45c\/6fc10645cd5bc7d8e98239e33473c0d5.svg\" alt=\"$\\vec w$\" data-tex=\"inline\"\/><\/math> (\u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u0443\u043c\u043c\u044b, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043e\u0442\u0432\u0435\u0442\u0435):<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0428\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430 \u043f\u043e \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u043c<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/184\/ed8\/5cc\/184ed85cc5786d02d58a2cd0375167d1.svg\" alt=\"$\\large \\begin{array}{rcl} \\frac{\\partial}{\\partial x} x^T a &amp;=&amp; a \\\\ \\frac{\\partial}{\\partial x} x^T A x &amp;=&amp; \\left(A + A^T\\right)x \\\\ \\frac{\\partial}{\\partial A} x^T A y &amp;=&amp; x^T y\\\\ \\frac{\\partial}{\\partial x} A^{-1} &amp;=&amp; -A^{-1} \\frac{\\partial A}{\\partial x} A^{-1} \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/62d\/4fd\/199\/62d4fd199a009bce3710f1f07bb3d76c.svg\" alt=\"$\\large \\begin{array}{rcl} \\frac{\\partial \\mathcal{L}}{\\partial \\vec{w}} &amp;=&amp; \\frac{\\partial}{\\partial \\vec{w}} \\frac{1}{2n} \\left( \\vec{y}^T \\vec{y} -2\\vec{y}^T X \\vec{w} + \\vec{w}^T X^T X \\vec{w}\\right) \\\\ &amp;=&amp; \\frac{1}{2n} \\left(-2 X^T \\vec{y} + 2X^T X \\vec{w}\\right) \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f5f\/e97\/e34\/f5fe97e34a81fd01f0d6471092c91b1e.svg\" alt=\"$\\large \\begin{array}{rcl} \\frac{\\partial \\mathcal{L}}{\\partial \\vec{w}} = 0 &amp;\\Leftrightarrow&amp; \\frac{1}{2n} \\left(-2 X^T \\vec{y} + 2X^T X \\vec{w}\\right) = 0 \\\\ &amp;\\Leftrightarrow&amp; -X^T \\vec{y} + X^T X \\vec{w} = 0 \\\\ &amp;\\Leftrightarrow&amp; X^T X \\vec{w} = X^T \\vec{y} \\\\ &amp;\\Leftrightarrow&amp; \\vec{w} = \\left(X^T X\\right)^{-1} X^T \\vec{y} \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0438\u043c\u0435\u044f \u0432 \u0432\u0438\u0434\u0443 \u0432\u0441\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A2%D0%B5%D0%BE%D1%80%D0%B5%D0%BC%D0%B0_%D0%93%D0%B0%D1%83%D1%81%D1%81%D0%B0_%E2%80%94_%D0%9C%D0%B0%D1%80%D0%BA%D0%BE%D0%B2%D0%B0\">\u0442\u0435\u043e\u0440\u0435\u043c\u0443 \u041c\u0430\u0440\u043a\u043e\u0432\u0430-\u0413\u0430\u0443\u0441\u0441\u0430<\/a>, \u0447\u0442\u043e \u043e\u0446\u0435\u043d\u043a\u0430 \u041c\u041d\u041a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u043e\u0446\u0435\u043d\u043a\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438, \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 <i>\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445<\/i> \u0438 <i>\u043d\u0435\u0441\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0445<\/i> \u043e\u0446\u0435\u043d\u043e\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0449\u0435\u0439 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0435\u0439.<\/p>\n<p>  <\/p>\n<h3 id=\"metod-maksimalnogo-pravdopodobiya\">\u041c\u0435\u0442\u043e\u0434 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u0423 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0435\u0437\u043e\u043d\u043d\u043e \u043c\u043e\u0433\u043b\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0447\u0435\u043c\u0443 \u043c\u044b \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443, \u0430 \u043d\u0435 \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435. \u0412\u0435\u0434\u044c \u043c\u043e\u0436\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0432\u044f\u0437\u043a\u0438 \u0438\u043b\u0438 \u0435\u0449\u0435 \u0447\u0442\u043e-\u0442\u043e. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u0439\u0434\u0435\u043c \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u041c\u0430\u0440\u043a\u043e\u0432\u0430-\u0413\u0430\u0443\u0441\u0441\u0430, \u0438 \u043d\u0430\u0448\u0438 \u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u0443\u0447\u0448\u0438\u043c\u0438 \u0441\u0440\u0435\u0434\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0438 \u043d\u0435\u0441\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0445. <\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043b\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. <\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a-\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0448\u043a\u043e\u043b\u044b \u044f \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u043c\u043d\u044f\u0442 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u044d\u0442\u0438\u043b\u043e\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0440\u0442\u0430. \u0422\u043e\u0433\u0434\u0430 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442: \u043f\u043e\u043c\u043d\u044f\u0442 \u043b\u0438 \u043b\u044e\u0434\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u043c\u0435\u0442\u0438\u043b\u043e\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0440\u0442\u0430: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/52d\/7a7\/e3e\/52d7a7e3edf618976e5fdbc23931f5bc.svg\" alt=\"$CH_3OH$\" data-tex=\"inline\"\/><\/math>. \u041c\u044b \u043e\u043f\u0440\u043e\u0441\u0438\u043b\u0438 400 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u043f\u043e\u043c\u043d\u044f\u0442 \u0432\u0441\u0435\u0433\u043e 117 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0420\u0430\u0437\u0443\u043c\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0437\u043d\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u043c\u0435\u0442\u0438\u043b\u043e\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0440\u0442\u0430 \u2013 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/29c\/631\/729\/29c631729ce13559d136a0d24d920360.svg\" alt=\"$\\frac{117}{400} \\approx 29%$\" data-tex=\"inline\"\/><\/math>. \u041f\u043e\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0430, \u0430 \u0435\u0449\u0435 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0446\u0435\u043d\u043a\u043e\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f. <\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u044d\u0442\u0430 \u043e\u0446\u0435\u043d\u043a\u0430, \u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B0%D1%81%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5_%D0%91%D0%B5%D1%80%D0%BD%D1%83%D0%BB%D0%BB%D0%B8\">\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438<\/a>: \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bf\/a5b\/297\/6bfa5b2972cf556a719dca37a543fd04.svg\" alt=\"$X$\" data-tex=\"inline\"\/><\/math> \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (<math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/072\/ceb\/bbc\/072cebbbc068c9c66ce5e423466d257c.svg\" alt=\"$1$\" data-tex=\"inline\"\/><\/math> \u0438 <math>$inline$0$inline$<\/math> \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044f\u043c\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a21\/ed4\/61f\/a21ed461f66aaee7817cacfb1a898860.svg\" alt=\"$\\theta$\" data-tex=\"inline\"\/><\/math> \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/352\/d19\/ecb\/352d19ecb8459f5a80c17d658eec3e51.svg\" alt=\"$1 - \\theta$\" data-tex=\"inline\"\/><\/math> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e) \u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/946\/aca\/6be\/946aca6be05b9b0674d6603c98d3d40e.svg\" alt=\"$\\large p\\left(\\theta, x\\right) = \\theta^x \\left(1 - \\theta\\right)^\\left(1 - x\\right), k \\in \\left\\{0, 1\\right\\}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0445\u043e\u0436\u0435, \u044d\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u2013 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a21\/ed4\/61f\/a21ed461f66aaee7817cacfb1a898860.svg\" alt=\"$\\theta$\" data-tex=\"inline\"\/><\/math> \u0438 \u0435\u0441\u0442\u044c \u0442\u0430 \u043e\u0446\u0435\u043d\u043a\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0437\u043d\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u043c\u0435\u0442\u0438\u043b\u043e\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0440\u0442\u0430. \u041c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/82c\/7e3\/73b\/82c7e373bb9d88b4b2ae07c1c3458425.svg\" alt=\"$400$\" data-tex=\"inline\"\/><\/math> <i>\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445<\/i> \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u0438\u0445 \u0438\u0441\u0445\u043e\u0434\u044b \u043a\u0430\u043a <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e07\/5b4\/944\/e075b49440450bc0599099bf2216bfef.svg\" alt=\"$\\vec{x} = \\left(x_1, x_2, \\ldots, x_{400}\\right)$\" data-tex=\"inline\"\/><\/math>. \u0417\u0430\u043f\u0438\u0448\u0435\u043c <em>\u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u0435<\/em> \u043d\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439), \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c 117 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2d2\/22c\/5ea\/2d222c5eae04916a9ef237f2540ac2a7.svg\" alt=\"$\\theta = 1$\" data-tex=\"inline\"\/><\/math> \u0438 283 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/982\/f2b\/d5b\/982f2bd5b3c48aeea2ded2a3dbb4886b.svg\" alt=\"$\\theta = 0$\" data-tex=\"inline\"\/><\/math>:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2cf\/ac1\/4d7\/2cfac14d70d14f12468fa2bbcdc3dc81.svg\" alt=\"$\\large p(\\vec{x} \\mid \\theta) = \\prod_{i=1}^{400} \\theta^{x_i} \\left(1 - \\theta\\right)^{\\left(1 - x_i\\right)} = \\theta^{117} \\left(1 - \\theta\\right)^{283}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a21\/ed4\/61f\/a21ed461f66aaee7817cacfb1a898860.svg\" alt=\"$\\theta$\" data-tex=\"inline\"\/><\/math>, \u0438 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u043d\u0435 \u0441 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u0435\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/126\/a62\/634\/126a626347be44d77ce8106dda68758b.svg\" alt=\"$p(\\vec{x} \\mid \\theta)$\" data-tex=\"inline\"\/><\/math>, \u0430 \u0441 \u0435\u0433\u043e \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u043e\u043c (\u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f):<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/551\/0a2\/9db\/5510a29db56aa1be16214ed469901763.svg\" alt=\"$\\large \\log p(\\vec{x} \\mid \\theta) = \\log \\prod_{i=1}^{400} \\theta^{x_i} \\left(1 - \\theta\\right)^{\\left(1 - x_i\\right)} = $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2df\/d8b\/4cb\/2dfd8b4cbcb27895af07856fc76f54d5.svg\" alt=\"$ \\large = \\log \\theta^{117} \\left(1 - \\theta\\right)^{283} = 117 \\log \\theta + 283 \\log \\left(1 - \\theta\\right)$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a21\/ed4\/61f\/a21ed461f66aaee7817cacfb1a898860.svg\" alt=\"$\\theta$\" data-tex=\"inline\"\/><\/math>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u0435, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u0443\u044e \u043f\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a21\/ed4\/61f\/a21ed461f66aaee7817cacfb1a898860.svg\" alt=\"$\\theta$\" data-tex=\"inline\"\/><\/math>, \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u044f\u0435\u043c \u043a \u043d\u0443\u043b\u044e \u0438 \u0440\u0435\u0448\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b11\/939\/e70\/b11939e70381006653908dd6b1bd4cf2.svg\" alt=\"$\\large \\frac{\\partial p(\\vec{x} \\mid \\theta)}{\\partial \\theta} = \\frac{\\partial}{\\partial \\theta} \\left(117 \\log \\theta + 283 \\log \\left(1 - \\theta\\right)\\right) = \\frac{117}{\\theta} - \\frac{283}{1 - \\theta};$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/165\/b06\/19e\/165b0619e1f16b2e412dc92b6a590b4a.svg\" alt=\"$\\large \\begin{array}{rcl} \\frac{117}{\\theta} - \\frac{283}{1 - \\theta} = 0 \\Rightarrow \\theta = \\frac{117}{400} \\end{array}.$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u2013 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043e\u0446\u0435\u043d\u043a\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u0435 \u0436\u0435 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u043b\u0435\u0436\u0438\u0442 \u0437\u0430 \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f. \u041c\u043e\u0434\u0435\u043b\u044c, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f86\/cd4\/654\/f86cd4654ac6f030cb6d0b815031844c.svg\" alt=\"$\\large \\vec y = X \\vec w + \\epsilon,$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u043d\u043e \u0431\u0443\u0434\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0437 \u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9D%D0%BE%D1%80%D0%BC%D0%B0%D0%BB%D1%8C%D0%BD%D0%BE%D0%B5_%D1%80%D0%B0%D1%81%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5\">\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f<\/a>:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/be9\/184\/bf8\/be9184bf8af0191bc9ca12fda85969b2.svg\" alt=\"$\\large \\epsilon_i \\sim \\mathcal{N}\\left(0, \\sigma^2\\right)$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u043d\u043e\u0432\u043e\u043c \u0441\u0432\u0435\u0442\u0435:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/928\/a72\/f51\/928a72f51b7a23fc4101351733ff82ca.svg\" alt=\"$\\large \\begin{array}{rcl} p\\left(y_i \\mid X, \\vec{w}\\right) &amp;=&amp; \\sum_{j=1}^m w_j X_{ij} + \\epsilon_i \\\\ &amp;=&amp; \\sum_{j=1}^m w_j X_{ij} + \\mathcal{N}\\left(0, \\sigma^2\\right) \\\\ &amp;=&amp; \\mathcal{N}\\left(\\sum_{j=1}^m w_j X_{ij}, \\sigma^2\\right) \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e (\u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435 \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u2013 \u043e\u0434\u043d\u043e \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u041c\u0430\u0440\u043a\u043e\u0432\u0430-\u0413\u0430\u0443\u0441\u0441\u0430), \u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6fe\/634\/9bb\/6fe6349bb833da529a9af3c523223b5a.svg\" alt=\"$p\\left(y_i\\right)$\" data-tex=\"inline\"\/><\/math>. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043e\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043a \u0441\u0443\u043c\u043c\u0435:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/32a\/284\/ce4\/32a284ce4bae31885eeca1afa0f86c24.svg\" alt=\"$\\large \\begin{array}{rcl} \\log p\\left(\\vec{y}, X \\mid \\vec{w}\\right) &amp;=&amp; \\log \\prod_{i=1}^n \\mathcal{N}\\left(\\sum_{j=1}^m w_j X_{ij}, \\sigma^2\\right) \\\\ &amp;=&amp; \\sum_{i=1}^n \\log \\mathcal{N}\\left(\\sum_{j=1}^m w_j X_{ij}, \\sigma^2\\right) \\\\ &amp;=&amp; -\\frac{n}{2}\\log 2\\pi\\sigma^2 -\\frac{1}{2\\sigma^2} \\sum_{i=1}^n \\left(y_i - \\vec{w}^T \\vec{x}_i\\right)^2 \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0443 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f, \u0442.\u0435. \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8ac\/266\/001\/8ac26600115920d1444ee7e9f7c7b978.svg\" alt=\"$p\\left(\\vec{y} \\mid X, \\vec{w}\\right)$\" data-tex=\"inline\"\/><\/math>, \u0430 \u044d\u0442\u043e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0435\u0433\u043e \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0430. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043a\u0438\u043d\u0443\u0442\u044c \u0432\u0441\u0435 \u0447\u043b\u0435\u043d\u044b, \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0435 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bf2\/aa1\/541\/bf2aa1541eb4511fe9f71bc9b1dd48ec.svg\" alt=\"$\\large \\begin{array}{rcl} \\hat{w} &amp;=&amp; \\arg \\max_{w} p\\left(\\vec{y}, X \\mid \\vec{w}\\right) \\\\ &amp;=&amp; \\arg \\max_{w} -\\frac{n}{2}\\log 2\\pi\\sigma^2 -\\frac{1}{2\\sigma^2} \\sum_{i=1}^n \\left(y_i - \\vec{w}^T \\vec{x}_i\\right)^2 \\\\ &amp;=&amp; \\arg \\max_{w} -\\frac{1}{2\\sigma^2} \\sum_{i=1}^n \\left(y_i - \\vec{w}^T \\vec{x}_i\\right)^2 \\\\ &amp;=&amp; \\arg \\max_{w} \\mathcal{L}\\left(X, \\vec{y}, \\vec{w} \\right) \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u2013 \u044d\u0442\u043e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 (\u043f\u0440\u0438 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e\u0441\u0442\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0439). \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \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 \u043e\u0448\u0438\u0431\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u0430 \u043d\u0435 \u043a\u0430\u043a-\u0442\u043e \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443.<\/p>\n<p>  <\/p>\n<h3 id=\"razlozhenie-oshibki-na-smeschenie-i-razbros-bias-variance-decomposition\">\u0420\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0438 \u0440\u0430\u0437\u0431\u0440\u043e\u0441 (Bias-variance decomposition)<\/h3>\n<p>  <\/p>\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u043e\u0446\u0435\u043d\u043a\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0435\u0439. \u0412 \u0441\u0432\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430 \u043c\u044b \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u0438, \u0447\u0442\u043e:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/125\/85a\/293\/12585a293bf911e9b8925c65b15433c0.svg\" alt=\"$f\\left(\\vec{x}\\right)$\" data-tex=\"inline\"\/><\/math> \u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e12\/dff\/45a\/e12dff45a7ed01bc64ba2aeb4d34a2bc.svg\" alt=\"$\\epsilon$\" data-tex=\"inline\"\/><\/math>: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cdf\/f40\/028\/cdff40028779bc9a11bfa7309b103e00.svg\" alt=\"$y = f\\left(\\vec{x}\\right) + \\epsilon$\" data-tex=\"inline\"\/><\/math>;<\/li>\n<li>\u043e\u0448\u0438\u0431\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0441 \u0446\u0435\u043d\u0442\u0440\u043e\u043c \u0432 \u043d\u0443\u043b\u0435 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u043e\u043c: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/973\/009\/f72\/973009f7297b2a7a420ccd4a9fafadd3.svg\" alt=\"$\\epsilon \\sim \\mathcal{N}\\left(0, \\sigma^2\\right)$\" data-tex=\"inline\"\/><\/math>;<\/li>\n<li>\u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0436\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0e1\/8c6\/9e0\/0e18c69e032b9d3a264d06c95eb383b4.svg\" alt=\"$y \\sim \\mathcal{N}\\left(f\\left(\\vec{x}\\right), \\sigma^2\\right)$\" data-tex=\"inline\"\/><\/math><\/li>\n<li>\u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u044c \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e, \u043d\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/125\/85a\/293\/12585a293bf911e9b8925c65b15433c0.svg\" alt=\"$f\\left(\\vec{x}\\right)$\" data-tex=\"inline\"\/><\/math> \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043e\u0442 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u043e\u0440\u043e\u0432 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d80\/7ae\/7e9\/d807ae7e9f567e3430dddc8e387be558.svg\" alt=\"$\\hat{f}\\left(\\vec{x}\\right)$\" data-tex=\"inline\"\/><\/math>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u0447\u0435\u0447\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e27\/cf9\/8c7\/e27cf98c72717dbc7954c0aeea930c1a.svg\" alt=\"$f$\" data-tex=\"inline\"\/><\/math> \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u0442\u043e\u0447\u043d\u0435\u0435, \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e\u043c \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439), \u0442.\u0435. \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0442\u043e\u0447\u043a\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0dd\/413\/01d\/0dd41301d0657c23744e7189b5ee570c.svg\" alt=\"$\\vec{x}$\" data-tex=\"inline\"\/><\/math> \u0440\u0430\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/646\/424\/a32\/646424a32e631c5ffa176515360db535.svg\" alt=\"$\\large \\begin{array}{rcl} \\text{Err}\\left(\\vec{x}\\right) &amp;=&amp; \\mathbb{E}\\left[\\left(y - \\hat{f}\\left(\\vec{x}\\right)\\right)^2\\right] \\\\ &amp;=&amp; \\mathbb{E}\\left[y^2\\right] + \\mathbb{E}\\left[\\left(\\hat{f}\\left(\\vec{x}\\right)\\right)^2\\right] - 2\\mathbb{E}\\left[y\\hat{f}\\left(\\vec{x}\\right)\\right] \\\\ &amp;=&amp; \\mathbb{E}\\left[y^2\\right] + \\mathbb{E}\\left[\\hat{f}^2\\right] - 2\\mathbb{E}\\left[y\\hat{f}\\right] \\\\ \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0447\u043b\u0435\u043d \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043b\u0435\u0433\u043a\u043e \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c88\/a9d\/fb4\/c88a9dfb4eca41004b91a777ee4ea275.svg\" alt=\"$\\text{Var}\\left(z\\right) = \\mathbb{E}\\left[z^2\\right] - \\mathbb{E}\\left[z\\right]^2$\" data-tex=\"inline\"\/><\/math>:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/efa\/188\/254\/efa188254b56cd8934dcb1ca939134ba.svg\" alt=\"$\\large \\begin{array}{rcl} \\mathbb{E}\\left[y^2\\right] &amp;=&amp; \\text{Var}\\left(y\\right) + \\mathbb{E}\\left[y\\right]^2 = \\sigma^2 + f^2\\\\ \\mathbb{E}\\left[\\hat{f}^2\\right] &amp;=&amp; \\text{Var}\\left(\\hat{f}\\right) + \\mathbb{E}\\left[\\hat{f}\\right]^2 \\\\ \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8e6\/95b\/9d2\/8e695b9d29732ea8e48e16f2fc88f102.svg\" alt=\"$\\large \\begin{array}{rcl} \\text{Var}\\left(y\\right) &amp;=&amp; \\mathbb{E}\\left[\\left(y - \\mathbb{E}\\left[y\\right]\\right)^2\\right] \\\\ &amp;=&amp; \\mathbb{E}\\left[\\left(y - f\\right)^2\\right] \\\\ &amp;=&amp; \\mathbb{E}\\left[\\left(f + \\epsilon - f\\right)^2\\right] \\\\ &amp;=&amp; \\mathbb{E}\\left[\\epsilon^2\\right] = \\sigma^2 \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/07d\/9f7\/5eb\/07d9f75eb45df3e273b30ba6a297902b.svg\" alt=\"$\\large \\mathbb{E}[y] = \\mathbb{E}[f + \\epsilon] = \\mathbb{E}[f] + \\mathbb{E}[\\epsilon] = f$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0447\u043b\u0435\u043d \u0441\u0443\u043c\u043c\u044b. \u041c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0438 \u0446\u0435\u043b\u0435\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6f6\/7b8\/e54\/6f67b8e54a55efa35e8ea8076751b285.svg\" alt=\"$\\large \\begin{array}{rcl} \\mathbb{E}\\left[y\\hat{f}\\right] &amp;=&amp; \\mathbb{E}\\left[\\left(f + \\epsilon\\right)\\hat{f}\\right] \\\\ &amp;=&amp; \\mathbb{E}\\left[f\\hat{f}\\right] + \\mathbb{E}\\left[\\epsilon\\hat{f}\\right] \\\\ &amp;=&amp; f\\mathbb{E}\\left[\\hat{f}\\right] + \\mathbb{E}\\left[\\epsilon\\right] \\mathbb{E}\\left[\\hat{f}\\right] = f\\mathbb{E}\\left[\\hat{f}\\right] \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2aa\/20b\/48b\/2aa20b48b248752cce2e3cfb046d9679.svg\" alt=\"$\\large \\begin{array}{rcl} \\text{Err}\\left(\\vec{x}\\right) &amp;=&amp; \\mathbb{E}\\left[\\left(y - \\hat{f}\\left(\\vec{x}\\right)\\right)^2\\right] \\\\ &amp;=&amp; \\sigma^2 + f^2 + \\text{Var}\\left(\\hat{f}\\right) + \\mathbb{E}\\left[\\hat{f}\\right]^2 - 2f\\mathbb{E}\\left[\\hat{f}\\right] \\\\ &amp;=&amp; \\left(f - \\mathbb{E}\\left[\\hat{f}\\right]\\right)^2 + \\text{Var}\\left(\\hat{f}\\right) + \\sigma^2 \\\\ &amp;=&amp; \\text{Bias}\\left(\\hat{f}\\right)^2 + \\text{Var}\\left(\\hat{f}\\right) + \\sigma^2 \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u0446\u0435\u043b\u0438 \u0432\u0441\u0435\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cdf\/f40\/028\/cdff40028779bc9a11bfa7309b103e00.svg\" alt=\"$y = f\\left(\\vec{x}\\right) + \\epsilon$\" data-tex=\"inline\"\/><\/math> \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/63f\/3a0\/2ca\/63f3a02ca3191a553bfa9aed58719ed3.svg\" alt=\"$\\text{Bias}\\left(\\hat{f}\\right)$\" data-tex=\"inline\"\/><\/math> \u2013 \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u043e \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043d\u0430\u0431\u043e\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445;<\/li>\n<li>\u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2fe\/bee\/47b\/2febee47b92bb220983febdc00068e41.svg\" alt=\"$\\text{Var}\\left(\\hat{f}\\right)$\" data-tex=\"inline\"\/><\/math> \u2013 \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438, \u0442\u043e, \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043e\u0431\u0443\u0447\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445;<\/li>\n<li>\u043d\u0435\u0443\u0441\u0442\u0440\u0430\u043d\u0438\u043c\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/be0\/006\/9bd\/be00069bd90f3669a29f6a12ff0df445.svg\" alt=\"$\\sigma^2$\" data-tex=\"inline\"\/><\/math>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043c\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u043c, \u0442\u043e \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043a\u0430\u043a-\u0442\u043e \u0432\u043b\u0438\u044f\u0442\u044c. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0441\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 \u043d\u0435\u0442 \u043e\u0431\u0430 \u044d\u0442\u0438\u0445 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 (\u043b\u0435\u0432\u044b\u0439 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0440\u0438\u0441\u0443\u043d\u043a\u0430), \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0441\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u043c\u0438 \u0438 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0446\u0435\u043d\u043a\u0430\u043c\u0438 (\u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f).<\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/aa5\/d0f\/149\/aa5d0f149838470fb997ca405c4c55a0.png\"  width=\"70%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432) \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442\u0441\u044f \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f (\u0440\u0430\u0437\u0431\u0440\u043e\u0441) \u043e\u0446\u0435\u043d\u043a\u0438, \u043d\u043e \u043e\u0446\u0435\u043d\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u043d\u043e\u0439. \u0418\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c (\u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435). \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043b\u0430\u0431\u0430\u044f, \u0442\u043e \u043e\u043d\u0430 \u043d\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0432\u044b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u0443\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435, \u0441\u043c\u0435\u0449\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fac\/875\/6ad\/fac8756ad9e64cae85cd2f2b2c289d05.png\"  width=\"70%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043e\u0440\u0435\u043c\u0430 \u041c\u0430\u0440\u043a\u043e\u0432\u0430-\u0413\u0430\u0443\u0441\u0441\u0430 \u043a\u0430\u043a \u0440\u0430\u0437 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u041c\u041d\u041a-\u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0439 \u043b\u0443\u0447\u0448\u0435\u0439 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0435\u0441\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043e\u0446\u0435\u043d\u043e\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0435\u0439. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u043a\u0430\u044f-\u043b\u0438\u0431\u043e \u0434\u0440\u0443\u0433\u0430\u044f \u043d\u0435\u0441\u043c\u0435\u0449\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/67c\/b7d\/36e\/67cb7d36ea7fee82440eab6c322039a9.svg\" alt=\"$g$\" data-tex=\"inline\"\/><\/math> \u0442\u043e\u0436\u0435 \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/618\/701\/c6b\/618701c6b0b19ceae0318487acaa4e18.svg\" alt=\"$Var\\left(\\hat{f}\\right) \\leq Var\\left(g\\right)$\" data-tex=\"inline\"\/><\/math>.<\/p>\n<p>  <\/p>\n<h3 id=\"regulyarizaciya-lineynoy-regressii\">\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/h3>\n<p>  <\/p>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0440\u0430\u0434\u0438 \u0435\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442.\u0435. \u0440\u0430\u0434\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2fe\/bee\/47b\/2febee47b92bb220983febdc00068e41.svg\" alt=\"$\\text{Var}\\left(\\hat{f}\\right)$\" data-tex=\"inline\"\/><\/math>. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u041c\u0430\u0440\u043a\u043e\u0432\u0430-\u0413\u0430\u0443\u0441\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432\u044b\u0439 \u0440\u0430\u043d\u0433 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bf\/a5b\/297\/6bfa5b2972cf556a719dca37a543fd04.svg\" alt=\"$X$\" data-tex=\"inline\"\/><\/math>. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u041c\u041d\u041a <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f0a\/f23\/fea\/f0af23fea7e7117c83e0859dec0c3473.svg\" alt=\"$\\vec{w} = \\left(X^T X\\right)^{-1} X^T \\vec{y}$\" data-tex=\"inline\"\/><\/math> \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0442.\u043a. \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cf7\/f9d\/b75\/cf7f9db75bb6cb12f181819685b50681.svg\" alt=\"$\\left(X^T X\\right)^{-1}.$\" data-tex=\"inline\"\/><\/math> \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043c\u0430\u0442\u0440\u0438\u0446\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/11f\/4ff\/eef\/11f4ffeef72245e53b9776778a05b90d.svg\" alt=\"$X^T X$\" data-tex=\"inline\"\/><\/math> \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u043d\u0433\u0443\u043b\u044f\u0440\u043d\u0430, \u0438\u043b\u0438 \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u0430. \u0422\u0430\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D0%BE%D1%80%D1%80%D0%B5%D0%BA%D1%82%D0%BD%D0%BE_%D0%BF%D0%BE%D1%81%D1%82%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%BD%D0%B0%D1%8F_%D0%B7%D0%B0%D0%B4%D0%B0%D1%87%D0%B0\">\u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439<\/a>. \u0417\u0430\u0434\u0430\u0447\u0443 \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/11f\/4ff\/eef\/11f4ffeef72245e53b9776778a05b90d.svg\" alt=\"$X^TX$\" data-tex=\"inline\"\/><\/math> \u043d\u0435\u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u043e\u0439, \u0438\u043b\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0439 (\u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439). \u0427\u0430\u0449\u0435 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e <i>\u043c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u044c<\/i> \u2014 \u043a\u043e\u0433\u0434\u0430 \u0434\u0432\u0430 \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441\u0438\u043b\u044c\u043d\u043e \u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bf\/a5b\/297\/6bfa5b2972cf556a719dca37a543fd04.svg\" alt=\"$X$\" data-tex=\"inline\"\/><\/math> \u044d\u0442\u043e \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 &quot;\u043f\u043e\u0447\u0442\u0438&quot; \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0446\u0435\u043d\u044b \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u043f\u043e \u0435\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c &quot;\u043f\u043e\u0447\u0442\u0438&quot; \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 &quot;\u043f\u043b\u043e\u0449\u0430\u0434\u044c \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0431\u0430\u043b\u043a\u043e\u043d\u0430&quot; \u0438 &quot;\u043f\u043b\u043e\u0449\u0430\u0434\u044c \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0431\u0430\u043b\u043a\u043e\u043d\u0430&quot;. \u0424\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/11f\/4ff\/eef\/11f4ffeef72245e53b9776778a05b90d.svg\" alt=\"$X^T X$\" data-tex=\"inline\"\/><\/math> \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0430, \u043d\u043e \u0438\u0437-\u0437\u0430 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u0438 \u0443 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/11f\/4ff\/eef\/11f4ffeef72245e53b9776778a05b90d.svg\" alt=\"$X^T X$\" data-tex=\"inline\"\/><\/math> \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0431\u043b\u0438\u0437\u043a\u0438 \u043a \u043d\u0443\u043b\u044e, \u0430 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/64e\/841\/412\/64e841412fb5a99ebcd7fd205851ad0f.svg\" alt=\"$\\left(X^T X\\right)^{-1}$\" data-tex=\"inline\"\/><\/math> \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0442.\u043a. \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u2013 \u044d\u0442\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2b0\/004\/78f\/2b000478f4560e2efaea0b748de7bc70.svg\" alt=\"$\\frac{1}{\\lambda_i}$\" data-tex=\"inline\"\/><\/math>. \u0418\u0442\u043e\u0433\u043e\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u0448\u0430\u0442\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438, \u0442.\u0435. \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0432 \u043d\u0430\u0431\u043e\u0440 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e. \u0418\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0440\u043e\u0441\u0442\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0432 <a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/322076\/\">\u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0448\u043b\u044b\u0445 \u043f\u043e\u0441\u0442\u043e\u0432<\/a>. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9C%D0%B5%D1%82%D0%BE%D0%B4_%D1%80%D0%B5%D0%B3%D1%83%D0%BB%D1%8F%D1%80%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8_%D0%A2%D0%B8%D1%85%D0%BE%D0%BD%D0%BE%D0%B2%D0%B0\">\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0422\u0438\u0445\u043e\u043d\u043e\u0432\u0430<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0447\u043b\u0435\u043d\u0430 \u043a \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0435: <\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/43d\/ed2\/67e\/43ded267e7bafc5a175743c34e8ee959.svg\" alt=\"$\\large \\begin{array}{rcl} \\mathcal{L}\\left(X, \\vec{y}, \\vec{w} \\right) &amp;=&amp; \\frac{1}{2n} \\left\\| \\vec{y} - X \\vec{w} \\right\\|_2^2 + \\left\\|\\Gamma \\vec{w}\\right\\|^2\\\\ \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0427\u0430\u0441\u0442\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0422\u0438\u0445\u043e\u043d\u043e\u0432\u0430 \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a86\/18f\/2dd\/a8618f2dd0e5d9c88c85b5b627accd26.svg\" alt=\"$\\Gamma = \\frac{\\lambda}{2} E$\" data-tex=\"inline\"\/><\/math>. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430\u0434\u0430\u0447\u0430 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5d2\/2a3\/690\/5d22a3690d9add2b7f98ad6e568079c9.svg\" alt=\"$L_2$\" data-tex=\"inline\"\/><\/math> \u043d\u043e\u0440\u043c\u0443. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u044f\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a \u043d\u0443\u043b\u044e \u0438 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6fc\/106\/45c\/6fc10645cd5bc7d8e98239e33473c0d5.svg\" alt=\"$\\vec{w}$\" data-tex=\"inline\"\/><\/math>, \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/43e\/5d6\/1a0\/43e5d61a03851a30c67d144a1aff9020.svg\" alt=\"$\\large \\begin{array}{rcl} \\vec{w} &amp;=&amp; \\left(X^T X + \\lambda E\\right)^{-1} X^T \\vec{y} \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0433\u0440\u0435\u0431\u043d\u0435\u0432\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0435\u0439 (ridge regression). \u0410 \u0433\u0440\u0435\u0431\u043d\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/11f\/4ff\/eef\/11f4ffeef72245e53b9776778a05b90d.svg\" alt=\"$X^T X$\" data-tex=\"inline\"\/><\/math>, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430.<\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c6e\/21e\/c4d\/c6e21ec4d5364b59a727c193760a40e1.png\"  width=\"70%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e, \u043d\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u043c, \u0442.\u043a. \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u0438 \u043d\u043e\u0440\u043c\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0447\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u043d\u0443\u043b\u044f. \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435 \u043d\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0431\u0435\u043b\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u0438\u0440\u043d\u044b\u0445 \u043b\u0438\u043d\u0438\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u041c\u041d\u041a-\u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0413\u043e\u043b\u0443\u0431\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0433\u0440\u0435\u0431\u043d\u0435\u0432\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438. \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d1d\/2ad\/058\/d1d2ad058a6e91cc85fd05d7403b9837.svg\" alt=\"$\\lambda$\" data-tex=\"inline\"\/><\/math> \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u043d\u0443\u043b\u044f.<\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/2f7\/484\/d31\/2f7484d31b98416296ad3bab430854ee.png\"  width=\"70%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0432\u0435\u0442\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432 <a href=\"https:\/\/habrahabr.ru\/company\/ods\/blog\/322076\/\">\u043d\u0430\u0448 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u043f\u043e\u0441\u0442<\/a> \u0437\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0442\u043e\u0433\u043e, \u043a\u0430\u043a <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5d2\/2a3\/690\/5d22a3690d9add2b7f98ad6e568079c9.svg\" alt=\"$L_2$\" data-tex=\"inline\"\/><\/math> \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0442\u043e\u0431\u044b \u043e\u0441\u0432\u0435\u0436\u0438\u0442\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0439 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<h1 id=\"2-logisticheskaya-regressiya\">2. \u041b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/h1>\n<p>  <\/p>\n<h3 id=\"lineynyy-klassifikator\">\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440<\/h3>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043e \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c\u044e \u043d\u0430 \u0434\u0432\u0435 \u043f\u043e\u043b\u0443\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438, \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e \u0438\u0437 \u0434\u0432\u0443\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<br \/>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a, \u0442\u043e \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c\u043e\u0439<\/em>.<\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/77b\/af8\/55c\/77baf855c84a4ba9a851060ec7ae6ec8.png\" \/><\/div>\n<p>  <\/p>\n<p>\u041c\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0435\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043f\u0440\u0438\u0447\u0435\u043c \u043c\u0435\u0442\u043a\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c &quot;+1&quot; (\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b) \u0438 &quot;-1&quot; (\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b).<br \/>  \u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f20\/d92\/7ad\/f20d927ad945c2e5da6a9617ab13b152.svg\" alt=\"$\\large a(\\vec{x}) = sign(\\vec{w}^Tx),$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0433\u0434\u0435<\/p>\n<p>  <\/p>\n<ul>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0dd\/413\/01d\/0dd41301d0657c23744e7189b5ee570c.svg\" alt=\"$\\vec{x}$\" data-tex=\"inline\"\/><\/math> \u2013 \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 (\u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0435\u0434\u0438\u043d\u0438\u0446\u0435\u0439);  <\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6fc\/106\/45c\/6fc10645cd5bc7d8e98239e33473c0d5.svg\" alt=\"$\\vec{w}$\" data-tex=\"inline\"\/><\/math> \u2013 \u0432\u0435\u0441\u0430 \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (\u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5ec\/533\/acf\/5ec533acf0f35024d8036be9294167b9.svg\" alt=\"$w_0$\" data-tex=\"inline\"\/><\/math>);  <\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a34\/f4b\/b29\/a34f4bb29138e068fbfb4295f9ee1bb0.svg\" alt=\"$sign(\\bullet)$\" data-tex=\"inline\"\/><\/math> \u2013 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u00ab\u0441\u0438\u0433\u043d\u0443\u043c\u00bb, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u0437\u043d\u0430\u043a \u0441\u0432\u043e\u0435\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430;  <\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8dd\/770\/9b3\/8dd7709b3fb0c4334b8912b06968f340.svg\" alt=\"$a(\\vec{x})$\" data-tex=\"inline\"\/><\/math> \u2013 \u043e\u0442\u0432\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0dd\/413\/01d\/0dd41301d0657c23744e7189b5ee570c.svg\" alt=\"$\\vec{x}$\" data-tex=\"inline\"\/><\/math>.  <\/li>\n<\/ul>\n<p>  <\/p>\n<h3 id=\"logisticheskaya-regressiya-kak-lineynyy-klassifikator\">\u041b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043a\u0430\u043a \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440<\/h3>\n<p>  <\/p>\n<p>\u041b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043d\u044b\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430, \u043d\u043e \u043e\u043d\u0430 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u043c &quot;\u0443\u043c\u0435\u043d\u0438\u0435\u043c&quot; \u2013 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/659\/018\/cb3\/659018cb32478b879143e0fc28afe25e.svg\" alt=\"$p_+$\" data-tex=\"inline\"\/><\/math> \u043e\u0442\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1bd\/bf9\/2bd\/1bdbf92bd6767c0a8b59148444cd6c3e.svg\" alt=\"$\\vec{x_i}$\" data-tex=\"inline\"\/><\/math> \u043a \u043a\u043b\u0430\u0441\u0441\u0443 &quot;+&quot;:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/670\/5d7\/7dd\/6705d77dd4970e8d5bed8f43f959b881.svg\" alt=\"$\\large p_+ = P\\left(y_i = 1 \\mid \\vec{x_i}, \\vec{w}\\right) $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u0430 (&quot;+1&quot; \u0438\u043b\u0438 &quot;-1&quot;), \u0430 \u0438\u043c\u0435\u043d\u043d\u043e <em>\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438<\/em> \u043e\u0442\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043a \u043a\u043b\u0430\u0441\u0441\u0443 &quot;+1&quot; \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u043e\u0433\u043e \u0441\u043a\u043e\u0440\u0438\u043d\u0433\u0430, \u0433\u0434\u0435 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f, \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u044e\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043a\u0440\u0435\u0434\u0438\u0442\u0430 (<math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/659\/018\/cb3\/659018cb32478b879143e0fc28afe25e.svg\" alt=\"$p_+$\" data-tex=\"inline\"\/><\/math>). \u041a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043e\u0431\u0440\u0430\u0442\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u0437\u0430 \u043a\u0440\u0435\u0434\u0438\u0442\u043e\u043c, \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442 \u043f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 (\u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e), \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043a\u043e\u0440\u043a\u0430\u0440\u0442\u0430 \u2014 \u043f\u043e \u0441\u0443\u0442\u0438, \u0440\u0435\u0439\u0442\u0438\u043d\u0433 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u043e\u0442 \u043f\u043b\u043e\u0445\u0438\u0445 \u043a \u0445\u043e\u0440\u043e\u0448\u0438\u043c. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0438\u0433\u0440\u0443\u0448\u0435\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439 \u0441\u043a\u043e\u0440\u043a\u0430\u0440\u0442\u044b. <\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/54e\/9e3\/e86\/54e9e3e8636743ed88c34b35a44c7c99.png\" width=\"60%\" \/><\/div>\n<p>  <\/p>\n<p>\u0411\u0430\u043d\u043a \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043f\u043e\u0440\u043e\u0433 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5a0\/2bd\/c53\/5a02bdc53f1186e372f20d3f47958b25.svg\" alt=\"$p_*$\" data-tex=\"inline\"\/><\/math> \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043a\u0440\u0435\u0434\u0438\u0442\u0430 (\u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u2013 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e0e\/e61\/52c\/e0ee6152c89c43ba0de725adcabeaf14.svg\" alt=\"$0.15$\" data-tex=\"inline\"\/><\/math>) \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u043d\u0435 \u0432\u044b\u0434\u0430\u0435\u0442 \u043a\u0440\u0435\u0434\u0438\u0442. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0432\u044b\u0434\u0430\u043d\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0430\u0442\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u0435\u0440\u044c \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0447\u0442\u043e \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043c\u0435\u0442\u0440\u0438\u043a\u043e\u0439 (<em>\u0414\u0430\u043b\u0435\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u044b \u043f\u043e \u0441\u043a\u043e\u0440\u0438\u043d\u0433\u0443 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043d\u043e \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0443\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0430\u044f<\/em>).<\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/624\/c6f\/a2f\/624c6fa2f2f9e8ef64089d57b357b588.svg\" alt=\"$p_+ \\in [0,1]$\" data-tex=\"inline\"\/><\/math>, \u0430 \u043f\u043e\u043a\u0430 \u0443\u043c\u0435\u0435\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u041c\u041d\u041a: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5ae\/7b8\/751\/5ae7b8751c894634e5d9b5e07801041c.svg\" alt=\"$b(\\vec{x}) = \\vec{w}^T \\vec{x} \\in \\mathbb{R}$\" data-tex=\"inline\"\/><\/math>. \u041a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u2013 [0, 1]? \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1b2\/b4c\/9fa\/1b2b4c9fa5bd7c14754664a95285bcd2.svg\" alt=\"$f: \\mathbb{R} \\rightarrow [0,1].$\" data-tex=\"inline\"\/><\/math> \u0412 \u043c\u043e\u0434\u0435\u043b\u0438 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/390\/1b4\/fc2\/3901b4fc29764da69c7c686d773b7f92.svg\" alt=\"$\\sigma(z) = \\frac{1}{1 + \\exp^{-z}}$\" data-tex=\"inline\"\/><\/math>. \u0418 \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a\u043e\u0432\u044b \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0438. <\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f7d\/20b\/5e3\/f7d20b5e309b4931bd2cac6c56df8525.png\" width=\"60%\" \/><\/div>\n<p>  <\/p>\n<p>\u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0bb\/702\/eb7\/0bb702eb7f9f4deec6039e3e89f4324c.svg\" alt=\"$P(X)$\" data-tex=\"inline\"\/><\/math> \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bf\/a5b\/297\/6bfa5b2972cf556a719dca37a543fd04.svg\" alt=\"$X$\" data-tex=\"inline\"\/><\/math>. \u0422\u043e\u0433\u0434\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7ec\/168\/0f7\/7ec1680f791db61a7392e9c524cb4a38.svg\" alt=\"$OR(X)$\" data-tex=\"inline\"\/><\/math> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7ef\/5f7\/9e8\/7ef5f79e8e6f72a1e3bfb8a39400de57.svg\" alt=\"$\\frac{P(X)}{1-P(X)}$\" data-tex=\"inline\"\/><\/math>, \u0430 \u044d\u0442\u043e \u2014 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0442\u043e\u0433\u043e, \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043b\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0438\u043b\u0438 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0448\u0430\u043d\u0441\u043e\u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u041d\u043e \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0bb\/702\/eb7\/0bb702eb7f9f4deec6039e3e89f4324c.svg\" alt=\"$P(X)$\" data-tex=\"inline\"\/><\/math> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0442 0 \u0434\u043e 1, <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7ec\/168\/0f7\/7ec1680f791db61a7392e9c524cb4a38.svg\" alt=\"$OR(X)$\" data-tex=\"inline\"\/><\/math> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0442 0 \u0434\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/143\/075\/533\/14307553326a13e2e677ca3e7f3ffdb3.svg\" alt=\"$\\infty$\" data-tex=\"inline\"\/><\/math>.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/7ec\/168\/0f7\/7ec1680f791db61a7392e9c524cb4a38.svg\" alt=\"$OR(X)$\" data-tex=\"inline\"\/><\/math> (\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u0448\u0430\u043d\u0441\u043e\u0432, \u0438\u043b\u0438 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439), \u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/715\/29e\/d01\/71529ed01e23472e045581b0a481b273.svg\" alt=\"$\\log{OR(X)} \\in \\mathbb{R}$\" data-tex=\"inline\"\/><\/math>. \u0415\u0433\u043e \u0442\u043e \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u041c\u041d\u041a.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0b6\/25e\/2a4\/0b625e2a445e9c8fffeaf1ac187c57c1.svg\" alt=\"$p_+ = P\\left(y_i = 1 \\mid \\vec{x_i}, \\vec{w}\\right)$\" data-tex=\"inline\"\/><\/math> (\u043f\u043e\u043a\u0430 \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u0432\u0435\u0441\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6fc\/106\/45c\/6fc10645cd5bc7d8e98239e33473c0d5.svg\" alt=\"$\\vec{w}$\" data-tex=\"inline\"\/><\/math> \u043c\u044b \u043a\u0430\u043a-\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 (\u0442.\u0435. \u043e\u0431\u0443\u0447\u0438\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c), \u0434\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e). <\/p>\n<p>  <\/p>\n<ul>\n<li>\n<p><strong>\u0428\u0430\u0433 1.<\/strong> \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/aad\/707\/954\/aad70795403618858bd5df6cff0c2e8e.svg\" alt=\"$w_{0}+w_{1}x_1 + w_{2}x_2 + ... = \\vec{w}^T\\vec{x}$\" data-tex=\"inline\"\/><\/math>. (\u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ad3\/ba3\/067\/ad3ba306790f147b3f9cd74a46ab9e4a.svg\" alt=\"$\\vec{w}^T\\vec{x} = 0$\" data-tex=\"inline\"\/><\/math> \u0437\u0430\u0434\u0430\u0435\u0442 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0430 2 \u043a\u043b\u0430\u0441\u0441\u0430);<\/p>\n<p>  <\/li>\n<li>\n<p><strong>\u0428\u0430\u0433 2.<\/strong> \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0448\u0430\u043d\u0441\u043e\u0432: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bc\/1dc\/8d6\/6bc1dc8d65629ec2a13f619112bb8f86.svg\" alt=\"$ \\log(OR_{+}) = \\vec{w}^T\\vec{x}$\" data-tex=\"inline\"\/><\/math>.<\/p>\n<p>  <\/li>\n<li><strong>\u0428\u0430\u0433 3.<\/strong> \u0418\u043c\u0435\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0448\u0430\u043d\u0441\u043e\u0432 \u043d\u0430 \u043e\u0442\u043d\u0435\u0441\u0435\u043d\u0438\u0435 \u043a \u043a\u043b\u0430\u0441\u0441\u0443 &quot;+&quot; \u2013 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ef6\/1bb\/644\/ef61bb644e66232243627829e1718cd7.svg\" alt=\"$OR_{+}$\" data-tex=\"inline\"\/><\/math>, \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/659\/018\/cb3\/659018cb32478b879143e0fc28afe25e.svg\" alt=\"$p_{+}$\" data-tex=\"inline\"\/><\/math> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/li>\n<\/ul>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/28c\/022\/a78\/28c022a78a31b0aa9c474bcf9c959b07.svg\" alt=\"$\\large p_{+} = \\frac{OR_{+}}{1 + OR_{+}} = \\frac{\\exp^{\\vec{w}^T\\vec{x}}}{1 + \\exp^{\\vec{w}^T\\vec{x}}} = \\frac{1}{1 + \\exp^{-\\vec{w}^T\\vec{x}}} = \\sigma(\\vec{w}^T\\vec{x})$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a\u0430\u043a \u0440\u0430\u0437 \u0441\u0438\u0433\u043c\u043e\u0438\u0434-\u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u0443\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043a \u043a\u043b\u0430\u0441\u0441\u0443 &quot;+&quot; (\u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0435\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0438 \u0432\u0435\u0441\u0430 \u043c\u043e\u0434\u0435\u043b\u0438) \u043a\u0430\u043a \u0441\u0438\u0433\u043c\u043e\u0438\u0434-\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0432\u0435\u0441\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8e5\/f9e\/6e0\/8e5f9e6e0b22c03aac7e05de236ef038.svg\" alt=\"$\\large p_+(x_i) = P\\left(y_i = 1 \\mid \\vec{x_i}, \\vec{w}\\right) = \\sigma(\\vec{w}^T\\vec{x_i}). $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f? \u0422\u0443\u0442 \u043c\u044b \u043e\u043f\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f.<\/p>\n<p>  <\/p>\n<h3 id=\"princip-maksimalnogo-pravdopodobiya-i-logisticheskaya-regressiya\">\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f \u0438 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0438\u0437 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0435\u0448\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u2013 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f <em>\u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439<\/em> \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c.<br \/>  \u0422\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043a \u043a\u043b\u0430\u0441\u0441\u0443 &quot;+&quot; \u043a\u0430\u043a <\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cb1\/51f\/638\/cb151f63862d73c49aee0e97768ecaf6.svg\" alt=\"$\\large p_+(\\vec{x_i}) = P\\left(y_i = 1 \\mid \\vec{x_i}, \\vec{w}\\right) = \\sigma(\\vec{w}^T\\vec{x_i})$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 &quot;-&quot; \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/372\/ff5\/098\/372ff509802fcb4232fe16e94165f220.svg\" alt=\"$\\large p_-(\\vec{x_i}) = P\\left(y_i = -1 \\mid \\vec{x_i}, \\vec{w}\\right) = 1 - \\sigma(\\vec{w}^T\\vec{x_i}) = \\sigma(-\\vec{w}^T\\vec{x_i}) $\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0430 \u044d\u0442\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043b\u043e\u0432\u043a\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e (\u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043c\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438 \u2013 \u043d\u0435 \u043e\u0431\u043c\u0430\u043d\u044b\u0432\u0430\u044e\u0442 \u043b\u0438 \u0432\u0430\u0441):<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/86f\/496\/2d9\/86f4962d91402441cb88272386646e1e.svg\" alt=\"$\\large P\\left(y = y_i \\mid \\vec{x_i}, \\vec{w}\\right) = \\sigma(y_i\\vec{w}^T\\vec{x_i})$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/11e\/b1d\/8ec\/11eb1d8ec0ad7ac09b05e3b241765620.svg\" alt=\"$M(\\vec{x_i}) = y_i\\vec{w}^T\\vec{x_i}$\" data-tex=\"inline\"\/><\/math> \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u043e\u0442\u0441\u0442\u0443\u043f\u043e\u043c<\/em> (<em>margin<\/em>) \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1bd\/bf9\/2bd\/1bdbf92bd6767c0a8b59148444cd6c3e.svg\" alt=\"$\\vec{x_i}$\" data-tex=\"inline\"\/><\/math> (\u043d\u0435 \u043f\u0443\u0442\u0430\u0442\u044c \u0441 \u0437\u0430\u0437\u043e\u0440\u043e\u043c (\u0442\u043e\u0436\u0435 margin), \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 SVM). \u0415\u0441\u043b\u0438 \u043e\u043d \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u0435\u043d, \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u043e\u0448\u0438\u0431\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1bd\/bf9\/2bd\/1bdbf92bd6767c0a8b59148444cd6c3e.svg\" alt=\"$\\vec{x_i}$\" data-tex=\"inline\"\/><\/math>, \u0435\u0441\u043b\u0438 \u0436\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u0435\u043d \u2013 \u0437\u043d\u0430\u0447\u0438\u0442, \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1bd\/bf9\/2bd\/1bdbf92bd6767c0a8b59148444cd6c3e.svg\" alt=\"$\\vec{x_i}$\" data-tex=\"inline\"\/><\/math> \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e.<br \/>  \u0417\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u043e\u0442\u0441\u0442\u0443\u043f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043a\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ce0\/009\/fc5\/ce0009fc5603a0e2edc997cebe4cc560.svg\" alt=\"$y_i$\" data-tex=\"inline\"\/><\/math>.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b, \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u0445 \u0415\u0432\u0433\u0435\u043d\u0438\u044f \u0421\u043e\u043a\u043e\u043b\u043e\u0432\u0430 \u2013 <a href=\"https:\/\/github.com\/esokolov\/ml-course-msu\/blob\/master\/ML16\/lecture-notes\/Sem09_linear.pdf\">\u0442\u0443\u0442<\/a>. <\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u043e\u0447\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0438\u0437 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u0443\u0440\u0441\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u044b: \u043d\u0430\u0439\u0442\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 \u0442\u043e\u0447\u043a\u0438 \u0441 \u0440\u0430\u0434\u0438\u0443\u0441-\u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/405\/e5f\/756\/405e5f7564c4aa4bfe67592823acd0c2.svg\" alt=\"$\\vec{x_A}$\" data-tex=\"inline\"\/><\/math> \u0434\u043e \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4c8\/674\/49f\/4c867449fa30bcd4b95b01d9fb3137b2.svg\" alt=\"$\\vec{w}^T\\vec{x} = 0.$\" data-tex=\"inline\"\/><\/math><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bcc\/24a\/ae4\/bcc24aae47ef623d534c954da2838892.svg\" alt=\"$\\large \\rho(\\vec{x_A}, \\vec{w}^T\\vec{x} = 0) = \\frac{\\vec{w}^T\\vec{x_A}}{||\\vec{w}||}$\" data-tex=\"display\"\/><\/math><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4b0\/707\/583\/4b07075832dd47a8b7fdd4b3636a4b58.png\" width=\"60%\" \/><\/div>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c (\u0438\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c) \u043e\u0442\u0432\u0435\u0442, \u0442\u043e \u043f\u043e\u0439\u043c\u0435\u043c, \u0447\u0442\u043e \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bd8\/259\/72c\/bd825972c78c865c2040fd5adfa79dc5.svg\" alt=\"$\\vec{w}^T\\vec{x_i}$\" data-tex=\"inline\"\/><\/math>, \u0442\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0442\u043e\u0447\u043a\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1bd\/bf9\/2bd\/1bdbf92bd6767c0a8b59148444cd6c3e.svg\" alt=\"$\\vec{x_i}$\" data-tex=\"inline\"\/><\/math> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0442 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4c8\/674\/49f\/4c867449fa30bcd4b95b01d9fb3137b2.svg\" alt=\"$\\vec{w}^T\\vec{x} = 0.$\" data-tex=\"inline\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0417\u043d\u0430\u0447\u0438\u0442, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/11e\/b1d\/8ec\/11eb1d8ec0ad7ac09b05e3b241765620.svg\" alt=\"$M(\\vec{x_i}) = y_i\\vec{w}^T\\vec{x_i}$\" data-tex=\"inline\"\/><\/math> \u2013 \u044d\u0442\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 &quot;\u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c&quot; \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1bd\/bf9\/2bd\/1bdbf92bd6767c0a8b59148444cd6c3e.svg\" alt=\"$\\vec{x_i}$\" data-tex=\"inline\"\/><\/math>: <\/p>\n<p>  <\/p>\n<ul>\n<li>\u0435\u0441\u043b\u0438 \u043e\u0442\u0441\u0442\u0443\u043f \u0431\u043e\u043b\u044c\u0448\u043e\u0439 (\u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e) \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043c\u0435\u0442\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0430\u043b\u0435\u043a\u043e \u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 (\u0442\u0430\u043a\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e). \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u2013 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/29c\/4c7\/0b2\/29c4c70b2f54eb15825a6023462d3f85.svg\" alt=\"$x_3$\" data-tex=\"inline\"\/><\/math>.<\/li>\n<li>\u0435\u0441\u043b\u0438 \u043e\u0442\u0441\u0442\u0443\u043f \u0431\u043e\u043b\u044c\u0448\u043e\u0439 (\u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e) \u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u0435\u0442\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0430\u043b\u0435\u043a\u043e \u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 (\u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u2013 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0433\u043e \u043c\u0435\u0442\u043a\u0430 \u0432 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e). \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u2013 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/736\/3ed\/315\/7363ed3150ecffdf235171aaa9ea4160.svg\" alt=\"$x_1$\" data-tex=\"inline\"\/><\/math>.<\/li>\n<li>\u0435\u0441\u043b\u0438 \u043e\u0442\u0441\u0442\u0443\u043f \u043c\u0430\u043b\u044b\u0439 (\u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e), \u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438, \u0430 \u0437\u043d\u0430\u043a \u043e\u0442\u0441\u0442\u0443\u043f\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d. \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u2013 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/911\/1e6\/994\/9111e69946e97ffe28324cbae67a9269.svg\" alt=\"$x_2$\" data-tex=\"inline\"\/><\/math> \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8c0\/49a\/709\/8c049a709f656f34e7f7ae00a3f78b95.svg\" alt=\"$x_4$\" data-tex=\"inline\"\/><\/math>.<\/li>\n<\/ul>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/397\/85b\/265\/39785b2651514289b424a1dacdffd2ba.png\" width=\"60%\" \/><\/div>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bc2\/fb7\/c06\/bc2fb7c065192e7ca9785e15d0882475.svg\" alt=\"$\\vec{y}$\" data-tex=\"inline\"\/><\/math> \u0443 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bf\/a5b\/297\/6bfa5b2972cf556a719dca37a543fd04.svg\" alt=\"$X$\" data-tex=\"inline\"\/><\/math>. \u0414\u0435\u043b\u0430\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435: \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e, \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f (<em>i.i.d.<\/em>). \u0422\u043e\u0433\u0434\u0430<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d6b\/1aa\/deb\/d6b1aadebe629c7204d5892b358cd36b.svg\" alt=\"$\\large P\\left(\\vec{y} \\mid X, \\vec{w}\\right) = \\prod_{i=1}^{\\ell} P\\left(y = y_i \\mid \\vec{x_i}, \\vec{w}\\right),$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0433\u0434\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1f4\/690\/9a1\/1f46909a1e747ff58f4935981c50a941.svg\" alt=\"$\\ell$\" data-tex=\"inline\"\/><\/math> \u2013 \u0434\u043b\u0438\u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bf\/a5b\/297\/6bfa5b2972cf556a719dca37a543fd04.svg\" alt=\"$X$\" data-tex=\"inline\"\/><\/math> (\u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a).<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u043e\u0434\u0438\u0442\u0441\u044f, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f (\u0441\u0443\u043c\u043c\u0443 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435):<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/466\/9b1\/301\/4669b130123d8ab72acf5c8afa6a6c66.svg\" alt=\"$\\large \\begin{array}{rcl} \\log P\\left(\\vec{y} \\mid X, \\vec{w}\\right) &amp;=&amp; \\log \\sum_{i=1}^{\\ell} P\\left(y = y_i \\mid \\vec{x_i}, \\vec{w}\\right) \\\\ &amp;=&amp; \\log \\prod_{i=1}^{\\ell} \\sigma(y_i\\vec{w}^T\\vec{x_i}) \\\\ &amp;=&amp; \\sum_{i=1}^{\\ell} \\log \\sigma(y_i\\vec{w}^T\\vec{x_i}) \\\\ &amp;=&amp; \\sum_{i=1}^{\\ell} \\log \\frac{1}{1 + \\exp^{-y_i\\vec{w}^T\\vec{x_i}}} \\\\ &amp;=&amp; - \\sum_{i=1}^{\\ell} \\log (1 + \\exp^{-y_i\\vec{w}^T\\vec{x_i}}) \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u0434\u0430\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f <\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/93c\/83e\/812\/93c83e812cf2590f6cd9f90f287cd558.svg\" alt=\"$\\large \\mathcal{L_{log}} (X, \\vec{y}, \\vec{w}) = \\sum_{i=1}^{\\ell} \\log (1 + \\exp^{-y_i\\vec{w}^T\\vec{x_i}}).$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e <em>\u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f<\/em> \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c, \u043f\u0440\u043e\u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u0446\u0438\u044e \u043a\u0430\u043a \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442 \u043e\u0442\u0441\u0442\u0443\u043f\u0430: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0ae\/fcc\/93f\/0aefcc93fdd7b80c609522acbac0403c.svg\" alt=\"$L(M) = \\log (1 + \\exp^{-M})$\" data-tex=\"inline\"\/><\/math>. \u041d\u0430\u0440\u0438\u0441\u0443\u0435\u043c \u0435\u0435 \u0433\u0440\u0430\u0444\u0438\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0433\u0440\u0430\u0444\u0438\u043a 1\/0 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u0439 \u043f\u043e\u0442\u0435\u0440\u044c (<em>zero-one loss<\/em>), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0448\u0442\u0440\u0430\u0444\u0443\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 1 \u0437\u0430 \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 (\u043e\u0442\u0441\u0442\u0443\u043f \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439): <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/241\/260\/ede\/241260ede206ec501fcc94508d08d32d.svg\" alt=\"$L_{1\/0}(M) = [M &lt; 0]$\" data-tex=\"inline\"\/><\/math>.<\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/676\/83c\/339\/67683c3399f14d82bbaedb722b154f0f.png\" width=\"60%\" \/><\/div>\n<p>  <\/p>\n<p>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u043e\u0431\u0449\u0443\u044e \u0438\u0434\u0435\u044e, \u0447\u0442\u043e \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043d\u0435 \u0443\u043c\u0435\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043e\u0448\u0438\u0431\u043e\u043a (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u044d\u0442\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u2013 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u0430\u044f 1\/0 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u0439 \u043f\u043e\u0442\u0435\u0440\u044c \u0432 \u043d\u0443\u043b\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c), \u043c\u044b \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0435\u0435 \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u043e\u0446\u0435\u043d\u043a\u0443. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \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 (\u0433\u0434\u0435 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e), \u0438 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e <\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5a6\/9ad\/598\/5a69ad59865ad980fed636c81c7b8a68.svg\" alt=\"$\\large \\begin{array}{rcl} \\mathcal{L_{1\/0}} (X, \\vec{y}, \\vec{w}) &amp;=&amp; \\sum_{i=1}^{\\ell} [M(\\vec{x_i}) &lt; 0] \\\\ &amp;\\leq&amp; \\sum_{i=1}^{\\ell} \\log (1 + \\exp^{-y_i\\vec{w}^T\\vec{x_i}}) \\\\ &amp;=&amp; \\mathcal{L_{log}} (X, \\vec{y}, \\vec{w}) \\end{array}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0433\u0434\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c5c\/628\/36a\/c5c62836a6344844db8167d9ad45b1b1.svg\" alt=\"$\\mathcal{L_{1\/0}} (X, \\vec{y}, \\vec{w})$\" data-tex=\"inline\"\/><\/math> \u2013 \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u0447\u0438\u0441\u043b\u043e \u043e\u0448\u0438\u0431\u043e\u043a \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0441 \u0432\u0435\u0441\u0430\u043c\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6fc\/106\/45c\/6fc10645cd5bc7d8e98239e33473c0d5.svg\" alt=\"$\\vec{w}$\" data-tex=\"inline\"\/><\/math> \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e21\/eb2\/5e3\/e21eb25e35669aa1fe619d135fa99999.svg\" alt=\"$(X, \\vec{y})$\" data-tex=\"inline\"\/><\/math>.<\/p>\n<p>  <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u043e\u0446\u0435\u043d\u043a\u0443 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ba0\/d5d\/0c7\/ba0d5d0c7957a6596e4e0c7f8e7a01c9.svg\" alt=\"$\\mathcal{L_{log}}$\" data-tex=\"inline\"\/><\/math> \u043d\u0430 \u0447\u0438\u0441\u043b\u043e \u043e\u0448\u0438\u0431\u043e\u043a \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043c\u044b \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0438 \u0441\u0430\u043c\u043e \u0447\u0438\u0441\u043b\u043e \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<p>  <\/p>\n<h3 id=\"l2-regulyarizaciya-logisticheskih-poter\">L2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u043e\u0442\u0435\u0440\u044c<\/h3>\n<p>  <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/439\/983\/a03\/439983a03bf43eb1fa2a8d763b5417c4.svg\" alt=\"$L2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f$\" data-tex=\"inline\"\/><\/math> \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0433\u0440\u0435\u0431\u043d\u0435\u0432\u043e\u0439 (Ridge \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0435\u0439). \u0412\u043c\u0435\u0441\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d81\/3d1\/124\/d813d112497c29ff1d1f312c48bc8193.svg\" alt=\"$\\mathcal{L_{log}} (X, \\vec{y}, \\vec{w})$\" data-tex=\"inline\"\/><\/math> \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b3c\/387\/91a\/b3c38791a2b5e38c98f6361200d43afa.svg\" alt=\"$\\large J(X, \\vec{y}, \\vec{w}) = \\mathcal{L_{log}} (X, \\vec{y}, \\vec{w}) + \\lambda |\\vec{w}|^2$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d73\/8f1\/324\/d738f13247032bb4f7a2947a9798af62.svg\" alt=\"$C = \\frac{1}{\\lambda}$\" data-tex=\"inline\"\/><\/math>. \u0418 \u0442\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0443\u0434\u0435\u0442  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/842\/a1a\/629\/842a1a629e9e5aa79464f24b48100911.svg\" alt=\"$\\large \\hat{w} = \\arg \\min_{\\vec{w}} J(X, \\vec{y}, \\vec{w}) = \\arg \\min_{\\vec{w}}\\ (C\\sum_{i=1}^{\\ell} \\log (1 + \\exp^{-y_i\\vec{w}^T\\vec{x_i}})+ |\\vec{w}|^2)$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u043c\u044b\u0441\u043b\u043e\u0432 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<br \/>  #3. \u041d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<br \/>  \u0412 1 \u0441\u0442\u0430\u0442\u044c\u0435 \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c \u043c\u043e\u0434\u0435\u043b\u044f\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0435 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u043a\u0430\u0436\u0435\u043c \u044d\u0442\u043e \u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u0445.<br \/>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430 \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u0438\u043a\u0440\u043e\u0447\u0438\u043f\u043e\u0432 \u0438\u0437 \u043a\u0443\u0440\u0441\u0430 Andrew Ng \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e. <br \/>  \u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u0441 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u0438 \u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 C.<br \/>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430, \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0438 \u043d\u0435\u0434\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435.<br \/>  \u041f\u043e\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0431\u043b\u0438\u0437\u043a\u0438\u0439 \u043a \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 (cross-validation) \u0438 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u043f\u043e \u0441\u0435\u0442\u043a\u0435 (GridSearch).   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0434\u043b\u044e\u043a\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from __future__ import division, print_function # \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043c \u0432\u0441\u044f\u043a\u0438\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f Anaconda import warnings warnings.filterwarnings('ignore') %matplotlib inline from matplotlib import pyplot as plt import seaborn as sns  import numpy as np import pandas as pd from sklearn.preprocessing import PolynomialFeatures from sklearn.linear_model import LogisticRegression, LogisticRegressionCV from sklearn.model_selection import cross_val_score, StratifiedKFold from sklearn.model_selection import GridSearchCV<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 read_csv \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pandas. \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f 118 \u043c\u0438\u043a\u0440\u043e\u0447\u0438\u043f\u043e\u0432 (\u043e\u0431\u044a\u0435\u043a\u0442\u044b) \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0434\u0432\u0443\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 (\u0434\u0432\u0430 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430) \u0438 \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043b\u0438 \u043c\u0438\u043a\u0440\u043e\u0447\u0438\u043f \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u043e. \u041f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0443\u0436\u0435 \u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0442\u043e \u0435\u0441\u0442\u044c \u0438\u0437 \u0432\u0441\u0435\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u044b\u0447\u0442\u0435\u043d\u044b \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, &quot;\u0441\u0440\u0435\u0434\u043d\u0435\u043c\u0443&quot; \u043c\u0438\u043a\u0440\u043e\u0447\u0438\u043f\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u043e\u0432. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">data = pd.read_csv('..\/..\/data\/microchip_tests.txt', header=None, names = ('test1','test2','released')) # \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 data.info()<\/code><\/pre>\n<p>  <\/p>\n<p>&lt;class &#8216;pandas.core.frame.DataFrame&#8217;&gt;<br \/>  RangeIndex: 118 entries, 0 to 117<br \/>  Data columns (total 3 columns):<br \/>  test1 118 non-null float64<br \/>  test2 118 non-null float64<br \/>  released 118 non-null int64<br \/>  dtypes: float64(2), int64(1)<br \/>  memory usage: 2.8 KB<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0435 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 5 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/bae\/537\/db0\/bae537db02734bf495332e27183a5af4.png\"  width=\"50%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cdd\/7d0\/02d\/cdd7d002de3442aeb2ce3ec82cc867fe.png\"  width=\"50%\"\/><\/div>\n<p>  <\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0438 \u043c\u0435\u0442\u043a\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445 NumPy. \u041e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435. \u041a\u0440\u0430\u0441\u043d\u044b\u0439 \u0446\u0432\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u0440\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0447\u0438\u043f\u0430\u043c, \u0437\u0435\u043b\u0435\u043d\u044b\u0439 \u2013 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">X = data.ix[:,:2].values y = data.ix[:,2].values<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">plt.scatter(X[y == 1, 0], X[y == 1, 1], c='green', label='\u0412\u044b\u043f\u0443\u0449\u0435\u043d') plt.scatter(X[y == 0, 0], X[y == 0, 1], c='red', label='\u0411\u0440\u0430\u043a\u043e\u0432\u0430\u043d') plt.xlabel(&quot;\u0422\u0435\u0441\u0442 1&quot;) plt.ylabel(&quot;\u0422\u0435\u0441\u0442 2&quot;) plt.title('2 \u0442\u0435\u0441\u0442\u0430 \u043c\u0438\u043a\u0440\u043e\u0447\u0438\u043f\u043e\u0432') plt.legend();<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b99\/2ad\/a2e\/b992ada2e7a34ccd81cf74b22e3a120e.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def plot_boundary(clf, X, y, grid_step=.01, poly_featurizer=None): x_min, x_max = X[:, 0].min() - .1, X[:, 0].max() + .1 y_min, y_max = X[:, 1].min() - .1, X[:, 1].max() + .1 xx, yy = np.meshgrid(np.arange(x_min, x_max, grid_step), np.arange(y_min, y_max, grid_step))  # \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u0432 \u0441\u0435\u0442\u043a\u0435 [x_min, m_max]x[y_min, y_max] # \u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u0432\u043e\u0439 \u0446\u0432\u0435\u0442 Z = clf.predict(poly_featurizer.transform(np.c_[xx.ravel(), yy.ravel()])) Z = Z.reshape(xx.shape) plt.contour(xx, yy, Z, cmap=plt.cm.Paired)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u0434\u043e \u0441\u0442\u0435\u043f\u0435\u043d\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b59\/99c\/bd8\/b5999cbd87881cf38f84f9b0b73a8284.svg\" alt=\"$d$\" data-tex=\"inline\"\/><\/math> \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/736\/3ed\/315\/7363ed3150ecffdf235171aaa9ea4160.svg\" alt=\"$x_1$\" data-tex=\"inline\"\/><\/math> \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/911\/1e6\/994\/9111e69946e97ffe28324cbae67a9269.svg\" alt=\"$x_2$\" data-tex=\"inline\"\/><\/math> \u043c\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a01\/5eb\/507\/a015eb5070ff41039efea8c6457cd8d2.svg\" alt=\"$\\large \\{x_1^d, x_1^{d-1}x_2, \\ldots x_2^d\\} = \\{x_1^ix_2^j\\}_{i+j=d, i,j \\in \\mathbb{N}}$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/84f\/a22\/a69\/84fa22a69dd7cf181898581cabc75db9.svg\" alt=\"$d=3$\" data-tex=\"inline\"\/><\/math> \u044d\u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a18\/66f\/5b5\/a1866f5b5ade0468cee17d929bc9fa05.svg\" alt=\"$\\large 1, x_1, x_2, x_1^2, x_1x_2, x_2^2, x_1^3, x_1^2x_2, x_1x_2^2, x_2^3$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0432 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u041f\u0438\u0444\u0430\u0433\u043e\u0440\u0430, \u0412\u044b \u0441\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0435, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5af\/5d5\/faa\/5af5d5faaca519ac35c48619d8df4f9b.svg\" alt=\"$d=4,5...$\" data-tex=\"inline\"\/><\/math> \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b59\/99c\/bd8\/b5999cbd87881cf38f84f9b0b73a8284.svg\" alt=\"$d$\" data-tex=\"inline\"\/><\/math>.<br \/>  \u041f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u0433\u043e\u0432\u043e\u0440\u044f, \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u0438 \u0441\u0442\u0440\u043e\u0438\u0442\u044c, \u0441\u043a\u0430\u0436\u0435\u043c, \u0434\u043b\u044f 100 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 10 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e (\u0430 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e). <\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442 sklearn, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bf\/a5b\/297\/6bfa5b2972cf556a719dca37a543fd04.svg\" alt=\"$X$\" data-tex=\"inline\"\/><\/math> \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u0441\u0442\u0435\u043f\u0435\u043d\u0438 7 \u0438 \u043e\u0431\u0443\u0447\u0438\u043c \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/868\/86d\/943\/86886d94308fba2650626259f520cac7.svg\" alt=\"$C = 10^{-2}$\" data-tex=\"inline\"\/><\/math>. \u0418\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443.<br \/>  \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0434\u043e\u043b\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435. \u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u0438\u043b\u044c\u043d\u043e\u0439, \u0438 \u043c\u043e\u0434\u0435\u043b\u044c &quot;\u043d\u0435\u0434\u043e\u043e\u0431\u0443\u0447\u0438\u043b\u0430\u0441\u044c&quot;. \u0414\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0440\u0430\u0432\u043d\u043e\u0439 0.627.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">poly = PolynomialFeatures(degree=7) X_poly = poly.fit_transform(X)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">C = 1e-2 logit = LogisticRegression(C=C, n_jobs=-1, random_state=17) logit.fit(X_poly, y)  plot_boundary(logit, X, y, grid_step=.01, poly_featurizer=poly)  plt.scatter(X[y == 1, 0], X[y == 1, 1], c='green', label='\u0412\u044b\u043f\u0443\u0449\u0435\u043d') plt.scatter(X[y == 0, 0], X[y == 0, 1], c='red', label='\u0411\u0440\u0430\u043a\u043e\u0432\u0430\u043d') plt.xlabel(&quot;\u0422\u0435\u0441\u0442 1&quot;) plt.ylabel(&quot;\u0422\u0435\u0441\u0442 2&quot;) plt.title('2 \u0442\u0435\u0441\u0442\u0430 \u043c\u0438\u043a\u0440\u043e\u0447\u0438\u043f\u043e\u0432. \u041b\u043e\u0433\u0438\u0442 \u0441 C=0.01') plt.legend();  print(&quot;\u0414\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435:&quot;,  round(logit.score(X_poly, y), 3))<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/98d\/f5c\/fee\/98df5cfeebad42bebd34a33d2e66b8e3.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math> \u0434\u043e 1. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043c\u044b <em>\u043e\u0441\u043b\u0430\u0431\u043b\u044f\u0435\u043c<\/em> \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044e, \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0435\u0441\u043e\u0432 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 (\u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e), \u0447\u0435\u043c \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u2013 0.831.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">C = 1 logit = LogisticRegression(C=C, n_jobs=-1, random_state=17) logit.fit(X_poly, y)  plot_boundary(logit, X, y, grid_step=.005, poly_featurizer=poly)  plt.scatter(X[y == 1, 0], X[y == 1, 1], c='green', label='\u0412\u044b\u043f\u0443\u0449\u0435\u043d') plt.scatter(X[y == 0, 0], X[y == 0, 1], c='red', label='\u0411\u0440\u0430\u043a\u043e\u0432\u0430\u043d') plt.xlabel(&quot;\u0422\u0435\u0441\u0442 1&quot;) plt.ylabel(&quot;\u0422\u0435\u0441\u0442 2&quot;) plt.title('2 \u0442\u0435\u0441\u0442\u0430 \u043c\u0438\u043a\u0440\u043e\u0447\u0438\u043f\u043e\u0432. \u041b\u043e\u0433\u0438\u0442 \u0441 C=1') plt.legend();  print(&quot;\u0414\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435:&quot;,  round(logit.score(X_poly, y), 3))<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f19\/876\/60a\/f1987660a43441a0bc495d89ee141ae4.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0415\u0449\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math> \u2013 \u0434\u043e 10 \u0442\u044b\u0441\u044f\u0447. \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0432\u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0438 \u043c\u044b \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 (\u043f\u0440\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math>=1 \u0438 &quot;\u0433\u043b\u0430\u0434\u043a\u043e\u0439&quot; \u0433\u0440\u0430\u043d\u0438\u0446\u0435) \u0434\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043d\u0435 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043d\u0438\u0436\u0435, \u0447\u0435\u043c \u0432 3 \u0441\u043b\u0443\u0447\u0430\u0435, \u0437\u0430\u0442\u043e \u043d\u0430 \u043d\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435, \u043c\u043e\u0436\u043d\u043e \u0441\u0435\u0431\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, 2 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435.<br \/>  \u0414\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u2013 0.873.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">C = 1e4 logit = LogisticRegression(C=C, n_jobs=-1, random_state=17) logit.fit(X_poly, y)  plot_boundary(logit, X, y, grid_step=.005, poly_featurizer=poly)  plt.scatter(X[y == 1, 0], X[y == 1, 1], c='green', label='\u0412\u044b\u043f\u0443\u0449\u0435\u043d') plt.scatter(X[y == 0, 0], X[y == 0, 1], c='red', label='\u0411\u0440\u0430\u043a\u043e\u0432\u0430\u043d') plt.xlabel(&quot;\u0422\u0435\u0441\u0442 1&quot;) plt.ylabel(&quot;\u0422\u0435\u0441\u0442 2&quot;) plt.title('2 \u0442\u0435\u0441\u0442\u0430 \u043c\u0438\u043a\u0440\u043e\u0447\u0438\u043f\u043e\u0432. \u041b\u043e\u0433\u0438\u0442 \u0441 C=10k') plt.legend();  print(&quot;\u0414\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435:&quot;,  round(logit.score(X_poly, y), 3))<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e42\/eae\/62e\/e42eae62e6044080b0cd7bf1aad0c5f0.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431 \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b27\/174\/191\/b2717419160fb225d9db0b9867292edd.svg\" alt=\"$\\large J(X,y,w) = \\mathcal{L} + \\frac{1}{C}||w||^2,$\" data-tex=\"display\"\/><\/math><\/p>\n<p>  <\/p>\n<p>\u0433\u0434\u0435<\/p>\n<p>  <\/p>\n<ul>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8ab\/bed\/034\/8abbed034dd8df983d745e3e4b50f6f8.svg\" alt=\"$\\mathcal{L}$\" data-tex=\"inline\"\/><\/math> \u2013 \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, \u043f\u0440\u043e\u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043f\u043e \u0432\u0441\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435  <\/li>\n<li><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math> \u2013 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 (\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math> \u0432 sklearn-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 LogisticRegression)  <\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0432\u044b\u0432\u043e\u0434\u044b<\/strong>:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math>, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c (\u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 &quot;\u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438&quot; \u043c\u043e\u0434\u0435\u043b\u0438 (model capacity))<\/li>\n<li>\u0435\u0441\u043b\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u0438\u043b\u044c\u043d\u0430\u044f (\u043c\u0430\u043b\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math>), \u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \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 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u043e\u0433\u0438\u0435 \u0432\u0435\u0441\u0430 \u0437\u0430\u043d\u0443\u043b\u0438\u043b\u0438\u0441\u044c \u0438\u043b\u0438 \u0441\u0442\u0430\u043b\u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u044b\u043c\u0438. \u0415\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e &quot;\u0448\u0442\u0440\u0430\u0444\u0443\u0435\u0442\u0441\u044f&quot; \u0437\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 (\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0b2\/4e0\/34d\/0b24e034d4f61f3df863802b621207e2.svg\" alt=\"$J$\" data-tex=\"inline\"\/><\/math> &quot;\u043f\u0435\u0440\u0435\u0432\u0435\u0448\u0438\u0432\u0430\u0435\u0442&quot; \u0441\u0443\u043c\u043c\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0432\u0435\u0441\u043e\u0432, \u0430 \u043e\u0448\u0438\u0431\u043a\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8ab\/bed\/034\/8abbed034dd8df983d745e3e4b50f6f8.svg\" alt=\"$\\mathcal{L}$\" data-tex=\"inline\"\/><\/math> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439). \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f <em>\u043d\u0435\u0434\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439<\/em> (1 \u0441\u043b\u0443\u0447\u0430\u0439)<\/li>\n<li>\u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0435\u0441\u043b\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u0430\u0431\u0430\u044f (\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math>), \u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/43c\/d4a\/82f\/43cd4a82fba2d057ebc2d101242d68d5.svg\" alt=\"$w$\" data-tex=\"inline\"\/><\/math> \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0432\u043a\u043b\u0430\u0434 \u0432 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/0b2\/4e0\/34d\/0b24e034d4f61f3df863802b621207e2.svg\" alt=\"$J$\" data-tex=\"inline\"\/><\/math> \u0438\u043c\u0435\u0435\u0442 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8ab\/bed\/034\/8abbed034dd8df983d745e3e4b50f6f8.svg\" alt=\"$\\mathcal{L}$\" data-tex=\"inline\"\/><\/math> \u0438, \u0432\u043e\u043b\u044c\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u044f\u0441\u044c, \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c &quot;\u0431\u043e\u0438\u0442\u0441\u044f&quot; \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f <em>\u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439<\/em> (3 \u0441\u043b\u0443\u0447\u0430\u0439)<\/li>\n<li>\u0442\u043e, \u043a\u0430\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math> \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u0441\u0430\u043c\u0430 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f &quot;\u043d\u0435 \u043f\u043e\u0439\u043c\u0435\u0442&quot; (\u0438\u043b\u0438 \u0435\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f\u0442 &quot;\u043d\u0435 \u0432\u044b\u0443\u0447\u0438\u0442&quot;), \u0442\u043e \u0435\u0441\u0442\u044c \u044d\u0442\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f (\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0432\u0435\u0441\u043e\u0432 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/43c\/d4a\/82f\/43cd4a82fba2d057ebc2d101242d68d5.svg\" alt=\"$w$\" data-tex=\"inline\"\/><\/math>). \u0422\u0430\u043a \u0436\u0435 \u0442\u043e\u0447\u043d\u043e, \u0434\u0435\u0440\u0435\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 &quot;\u0441\u0430\u043c\u043e \u043f\u043e\u043d\u044f\u0442\u044c&quot;, \u043a\u0430\u043a\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0432\u044b\u0431\u0440\u0430\u0442\u044c (\u0437\u0430 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math> \u2013 \u044d\u0442\u043e <em>\u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/em> \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438, \u043a\u0430\u043a \u0438 <em>max_depth<\/em> \u0434\u043b\u044f \u0434\u0435\u0440\u0435\u0432\u0430.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/strong><\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0439\u0434\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math>. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e LogisticRegressionCV \u2013 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u0441\u0435\u0442\u043a\u0435 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439. \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 (\u0434\u043b\u044f \u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432), \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u044b \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 GridSearchCV, RandomizedSearchCV \u0438\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \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, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432 hyperopt.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"> skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=17)  c_values = np.logspace(-2, 3, 500)  logit_searcher = LogisticRegressionCV(Cs=c_values, cv=skf, verbose=1, n_jobs=-1) logit_searcher.fit(X_poly, y)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u043b\u0438 (\u0434\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445) \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0433\u0438\u043f\u0435\u0440\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/daf\/e83\/7b2\/dafe837b2eb473c8c3a2240b85e4ca80.svg\" alt=\"$C$\" data-tex=\"inline\"\/><\/math>. <\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4d7\/288\/42a\/4d728842ae994eee99e4b1d3329ceaf6.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0434\u0435\u043b\u0438\u043c \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u0441 &quot;\u043b\u0443\u0447\u0448\u0438\u043c\u0438&quot; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 C.<\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/af9\/27c\/1cc\/af927c1ccd1348928c7b7dba644f118e.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u0442\u0430\u043a\u0438\u0435 \u043a\u0440\u0438\u0432\u044b\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <em>\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438<\/em>, \u0440\u0430\u043d\u044c\u0448\u0435 \u043c\u044b \u0438\u0445 \u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u043e \u0432 sklearn \u0434\u043b\u044f \u043d\u0438\u0445 \u0438\u0445 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0442\u043e\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<h1 id=\"4-gde-logisticheskaya-regressiya-horosha-i-gde-ne-ochen\">4. \u0413\u0434\u0435 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0445\u043e\u0440\u043e\u0448\u0430 \u0438 \u0433\u0434\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c<\/h1>\n<p>  <\/p>\n<h3 id=\"analiz-otzyvov-imdb-k-filmam\">\u0410\u043d\u0430\u043b\u0438\u0437 \u043e\u0442\u0437\u044b\u0432\u043e\u0432 IMDB \u043a \u0444\u0438\u043b\u044c\u043c\u0430\u043c<\/h3>\n<p>  <\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0442\u0437\u044b\u0432\u043e\u0432 IMDB \u043a \u0444\u0438\u043b\u044c\u043c\u0430\u043c. \u0418\u043c\u0435\u0435\u0442\u0441\u044f \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0441 \u0440\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u0442\u0437\u044b\u0432\u0430\u043c\u0438, \u043f\u043e 12500 \u043e\u0442\u0437\u044b\u0432\u043e\u0432 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043e\u043d\u0438 \u0445\u043e\u0440\u043e\u0448\u0438\u0435, \u0435\u0449\u0435 \u043f\u0440\u043e 12500 \u2013 \u0447\u0442\u043e \u043e\u043d\u0438 \u043f\u043b\u043e\u0445\u0438\u0435. \u0417\u0434\u0435\u0441\u044c \u0443\u0436\u0435 \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6bf\/a5b\/297\/6bfa5b2972cf556a719dca37a543fd04.svg\" alt=\"$X$\" data-tex=\"inline\"\/><\/math> \u043d\u0435\u0442 \u2013 \u0435\u0435 \u043d\u0430\u0434\u043e \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c. \u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2013 \u043c\u0435\u0448\u043e\u043a \u0441\u043b\u043e\u0432 (&quot;Bag of words&quot;). \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u043e\u0442\u0437\u044b\u0432\u0430 \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0432 \u043d\u0435\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0438\u0437 \u0432\u0441\u0435\u0433\u043e \u043a\u043e\u0440\u043f\u0443\u0441\u0430, \u0433\u0434\u0435 \u043a\u043e\u0440\u043f\u0443\u0441 \u2013 \u044d\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0441\u0435\u0445 \u043e\u0442\u0437\u044b\u0432\u043e\u0432. \u0418\u0434\u0435\u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439<\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a0a\/bb1\/2e9\/a0abb12e9ed94624ade0b9090d26ad66.png\" width=\"80%\" \/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u043c\u043f\u043e\u0440\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from __future__ import division, print_function # \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043c \u0432\u0441\u044f\u043a\u0438\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f Anaconda import warnings warnings.filterwarnings('ignore') import numpy as np import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns import numpy as np from sklearn.datasets import load_files from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer, TfidfVectorizer from sklearn.linear_model import LogisticRegression from sklearn.svm import LinearSVC<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 <a href=\"https:\/\/yadi.sk\/d\/Tg1Tflur333iLr\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>. \u0412 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445 \u043f\u043e 12500 \u0442\u044b\u0441\u044f\u0447 \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0438 \u043f\u043b\u043e\u0445\u0438\u0445 \u043e\u0442\u0437\u044b\u0432\u043e\u0432 \u043a \u0444\u0438\u043b\u044c\u043c\u0430\u043c.<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"python\">reviews_train = load_files(&quot;YOUR PATH&quot;) text_train, y_train = reviews_train.data, reviews_train.target<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">print(&quot;Number of documents in training data: %d&quot; % len(text_train)) print(np.bincount(y_train))<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\"># \u043f\u043e\u043c\u0435\u043d\u044f\u0439\u0442\u0435 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 reviews_test = load_files(&quot;YOUR PATH&quot;) text_test, y_test = reviews_test.data, reviews_test.target print(&quot;Number of documents in test data: %d&quot; % len(text_test)) print(np.bincount(y_test))<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043b\u043e\u0445\u043e\u0433\u043e \u043e\u0442\u0437\u044b\u0432\u0430: <\/p>\n<p>  <\/p>\n<blockquote><p>&#8216;Words can\\&#8217;t describe how bad this movie is. I can\\&#8217;t explain it by writing only. You have too see it for yourself to get at grip of how horrible a movie really can be. Not that I recommend you to do that. There are so many clich\\xc3\\xa9s, mistakes (and all other negative things you can imagine) here that will just make you cry. To start with the technical first, there are a LOT of mistakes regarding the airplane. I won\\&#8217;t list them here, but just mention the coloring of the plane. They didn\\&#8217;t even manage to show an airliner in the colors of a fictional airline, but instead used a 747 painted in the original Boeing livery. Very bad. The plot is stupid and has been done many times before, only much, much better. There are so many ridiculous moments here that i lost count of it really early. Also, I was on the bad guys\\&#8217; side all the time in the movie, because the good guys were so stupid. &quot;Executive Decision&quot; should without a doubt be you\\&#8217;re choice over this one, even the &quot;Turbulence&quot;-movies are better. In fact, every other movie in the world is better than this one.&#8217;<\/p><\/blockquote>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u043e\u0442\u0437\u044b\u0432\u0430: <\/p>\n<p>  <\/p>\n<blockquote><p>&#8216;Everyone plays their part pretty well in this &quot;little nice movie&quot;. Belushi gets the chance to live part of his life differently, but ends up realizing that what he had was going to be just as good or maybe even better. The movie shows us that we ought to take advantage of the opportunities we have, not the ones we do not or cannot have. If U can get this movie on video for around $10, it\\xc2\\xb4d be an investment!&#8217;<\/p><\/blockquote>\n<p>  <\/p>\n<h2 id=\"prostoy-podschet-slov\">\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u043b\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u0421\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0432\u0441\u0435\u0445 \u0441\u043b\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e CountVectorizer. \u0412\u0441\u0435\u0433\u043e \u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 74849 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u043e\u0432. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 &quot;\u0441\u043b\u043e\u0432&quot; (\u043b\u0443\u0447\u0448\u0435 \u0438\u0445 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438), \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0430 \u043c\u044b \u0442\u0443\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 (\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u2013 \u044d\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0431\u044b\u0442\u044c \u0442\u0435\u043c\u043e\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439).<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">cv = CountVectorizer() cv.fit(text_train)  print(len(cv.vocabulary_)) #74849<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">print(cv.get_feature_names()[:50]) print(cv.get_feature_names()[50000:50050])<\/code><\/pre>\n<p>  <\/p>\n<p>[&#8217;00&#8217;, &#8216;000&#8217;, &#8216;0000000000001&#8217;, &#8216;00001&#8217;, &#8216;00015&#8217;, &#8216;000s&#8217;, &#8216;001&#8217;, &#8216;003830&#8217;, &#8216;006&#8217;, &#8216;007&#8217;, &#8216;0079&#8217;, &#8216;0080&#8217;, &#8216;0083&#8217;, &#8216;0093638&#8217;, &#8217;00am&#8217;, &#8217;00pm&#8217;, &#8217;00s&#8217;, &#8217;01&#8217;, &#8217;01pm&#8217;, &#8217;02&#8217;, &#8216;020410&#8217;, &#8216;029&#8217;, &#8217;03&#8217;, &#8217;04&#8217;, &#8216;041&#8217;, &#8217;05&#8217;, &#8216;050&#8217;, &#8217;06&#8217;, &#8217;06th&#8217;, &#8217;07&#8217;, &#8217;08&#8217;, &#8216;087&#8217;, &#8216;089&#8217;, &#8217;08th&#8217;, &#8217;09&#8217;, &#8216;0f&#8217;, &#8216;0ne&#8217;, &#8216;0r&#8217;, &#8216;0s&#8217;, &#8217;10&#8217;, &#8216;100&#8217;, &#8216;1000&#8217;, &#8216;1000000&#8217;, &#8216;10000000000000&#8217;, &#8216;1000lb&#8217;, &#8216;1000s&#8217;, &#8216;1001&#8217;, &#8216;100b&#8217;, &#8216;100k&#8217;, &#8216;100m&#8217;]<br \/>  [&#8216;pincher&#8217;, &#8216;pinchers&#8217;, &#8216;pinches&#8217;, &#8216;pinching&#8217;, &#8216;pinchot&#8217;, &#8216;pinciotti&#8217;, &#8216;pine&#8217;, &#8216;pineal&#8217;, &#8216;pineapple&#8217;, &#8216;pineapples&#8217;, &#8216;pines&#8217;, &#8216;pinet&#8217;, &#8216;pinetrees&#8217;, &#8216;pineyro&#8217;, &#8216;pinfall&#8217;, &#8216;pinfold&#8217;, &#8216;ping&#8217;, &#8216;pingo&#8217;, &#8216;pinhead&#8217;, &#8216;pinheads&#8217;, &#8216;pinho&#8217;, &#8216;pining&#8217;, &#8216;pinjar&#8217;, &#8216;pink&#8217;, &#8216;pinkerton&#8217;, &#8216;pinkett&#8217;, &#8216;pinkie&#8217;, &#8216;pinkins&#8217;, &#8216;pinkish&#8217;, &#8216;pinko&#8217;, &#8216;pinks&#8217;, &#8216;pinku&#8217;, &#8216;pinkus&#8217;, &#8216;pinky&#8217;, &#8216;pinnacle&#8217;, &#8216;pinnacles&#8217;, &#8216;pinned&#8217;, &#8216;pinning&#8217;, &#8216;pinnings&#8217;, &#8216;pinnochio&#8217;, &#8216;pinnocioesque&#8217;, &#8216;pino&#8217;, &#8216;pinocchio&#8217;, &#8216;pinochet&#8217;, &#8216;pinochets&#8217;, &#8216;pinoy&#8217;, &#8216;pinpoint&#8217;, &#8216;pinpoints&#8217;, &#8216;pins&#8217;, &#8216;pinsent&#8217;]<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0417\u0430\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043b\u043e\u0432. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0442\u0430\u043a \u0436\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">X_train = cv.transform(text_train) X_test = cv.transform(text_test)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0443\u0447\u0438\u043c \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0434\u043e\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043c\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 86.7% \u043e\u0442\u0437\u044b\u0432\u043e\u0432. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">%%time logit = LogisticRegression(n_jobs=-1, random_state=7) logit.fit(X_train, y_train) print(round(logit.score(X_train, y_train), 3), round(logit.score(X_test, y_test), 3))<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def visualize_coefficients(classifier, feature_names, n_top_features=25): # get coefficients with large absolute values  coef = classifier.coef_.ravel() positive_coefficients = np.argsort(coef)[-n_top_features:] negative_coefficients = np.argsort(coef)[:n_top_features] interesting_coefficients = np.hstack([negative_coefficients, positive_coefficients]) # plot them plt.figure(figsize=(15, 5)) colors = [&quot;red&quot; if c &lt; 0 else &quot;blue&quot; for c in coef[interesting_coefficients]] plt.bar(np.arange(2 * n_top_features), coef[interesting_coefficients], color=colors) feature_names = np.array(feature_names) plt.xticks(np.arange(1, 1 + 2 * n_top_features), feature_names[interesting_coefficients], rotation=60, ha=&quot;right&quot;); <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">def plot_grid_scores(grid, param_name): plt.plot(grid.param_grid[param_name], grid.cv_results_['mean_train_score'], color='green', label='train') plt.plot(grid.param_grid[param_name], grid.cv_results_['mean_test_score'], color='red', label='test') plt.legend(); <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">visualize_coefficients(logit, cv.get_feature_names())<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fd4\/895\/fb3\/fd4895fb32094d2684e65f22e3764ac6.png\"\/>  <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0431\u0435\u0440\u0435\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c sklearn.pipeline, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 CountVectorizer \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0442\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c (\u0447\u0442\u043e\u0431 \u043d\u0435 &quot;\u043f\u043e\u0434\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c&quot; \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0438 \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e \u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0432). \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 pipeline \u0437\u0430\u0434\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439: \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c CountVectorizer, \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e. \u0422\u0430\u043a \u043c\u044b \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c \u0434\u043e\u043b\u044e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0434\u043e 88.5% \u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 87.9% \u2013 \u043d\u0430 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from sklearn.pipeline import make_pipeline  text_pipe_logit = make_pipeline(CountVectorizer(),  LogisticRegression(n_jobs=-1, random_state=7))  text_pipe_logit.fit(text_train, y_train) print(text_pipe_logit.score(text_test, y_test))  from sklearn.model_selection import GridSearchCV  param_grid_logit = {'logisticregression__C': np.logspace(-5, 0, 6)} grid_logit = GridSearchCV(text_pipe_logit, param_grid_logit, cv=3, n_jobs=-1)  grid_logit.fit(text_train, y_train) grid_logit.best_params_, grid_logit.best_score_ plot_grid_scores(grid_logit, 'logisticregression__C') grid_logit.score(text_test, y_test)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/715\/7a4\/1ff\/7157a41fffc344dabd32ebc65c00ce73.png\"\/>  <\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043b\u0435\u0441\u043e\u043c. \u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0435\u0439 \u043c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0434\u043e\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043c\u0435\u043d\u044c\u0448\u0438\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438. \u041b\u0435\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043e\u043b\u044c\u0448\u0435, \u043d\u0430 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 85.5% \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043b\u0435\u0441\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from sklearn.ensemble import RandomForestClassifier forest = RandomForestClassifier(n_estimators=200, n_jobs=-1, random_state=17) forest.fit(X_train, y_train) print(round(forest.score(X_test, y_test), 3))<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3 id=\"xor-problema\">XOR-\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h3>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440, \u0433\u0434\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0445\u0443\u0436\u0435. <\/p>\n<p>  <\/p>\n<p>\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u044f\u0442 \u0432\u0441\u0435 \u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u2013 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c. \u0421\u0430\u043c\u044b\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0438\u0433\u0440\u0443\u0448\u0435\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c\u044e (\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u044f\u043c\u043e\u0439, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e 2D), \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0438\u043c\u044f &quot;the XOR problem&quot;.<\/p>\n<p>  <\/p>\n<p>XOR \u2013 \u044d\u0442\u043e &quot;\u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0435 \u0418\u041b\u0418&quot;, \u0431\u0443\u043b\u0435\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/aa7\/c61\/7c9\/aa7c617c9ce4458d88979b6d44a1e2fa.gif\"  width=\"50%\"\/><\/div>\n<p>  <\/p>\n<p>XOR \u0434\u0430\u043b \u0438\u043c\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432\u044b\u0442\u044f\u043d\u0443\u0442\u044b\u043c\u0438 \u043f\u043e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044f\u043c \u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u043e\u0431\u043b\u0430\u043a\u0430\u043c\u0438 \u0442\u043e\u0447\u0435\u043a. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434, \u0440\u0438\u0441\u0443\u044e\u0449\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 3 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"># \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 rng = np.random.RandomState(0) X = rng.randn(200, 2) y = np.logical_xor(X[:, 0] &gt; 0, X[:, 1] &gt; 0)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">plt.scatter(X[:, 0], X[:, 1], s=30, c=y, cmap=plt.cm.Paired);<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">def plot_boundary(clf, X, y, plot_title): xx, yy = np.meshgrid(np.linspace(-3, 3, 50), np.linspace(-3, 3, 50)) clf.fit(X, y) # plot the decision function for each datapoint on the grid Z = clf.predict_proba(np.vstack((xx.ravel(), yy.ravel())).T)[:, 1] Z = Z.reshape(xx.shape)  image = plt.imshow(Z, interpolation='nearest', extent=(xx.min(), xx.max(), yy.min(), yy.max()), aspect='auto', origin='lower', cmap=plt.cm.PuOr_r) contours = plt.contour(xx, yy, Z, levels=[0], linewidths=2, linetypes='--') plt.scatter(X[:, 0], X[:, 1], s=30, c=y, cmap=plt.cm.Paired) plt.xticks(()) plt.yticks(()) plt.xlabel(r'&lt;!-- math&gt;&lt;img src=&quot;https:\/\/habrastorage.org\/getpro\/habr\/post_images\/736\/3ed\/315\/7363ed3150ecffdf235171aaa9ea4160.svg&quot; alt=&quot;$x_1$&quot; data-tex=&quot;inline&quot; \/&gt;&lt;\/math --&gt;') plt.ylabel(r'&lt;!-- math&gt;&lt;img src=&quot;https:\/\/habrastorage.org\/getpro\/habr\/post_images\/911\/1e6\/994\/9111e69946e97ffe28324cbae67a9269.svg&quot; alt=&quot;$x_2$&quot; data-tex=&quot;inline&quot; \/&gt;&lt;\/math --&gt;') plt.axis([-3, 3, -3, 3]) plt.colorbar(image) plt.title(plot_title, fontsize=12);<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">plot_boundary(LogisticRegression(), X, y, &quot;Logistic Regression, XOR problem&quot;)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">from sklearn.preprocessing import PolynomialFeatures from sklearn.pipeline import Pipeline<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">logit_pipe = Pipeline([('poly', PolynomialFeatures(degree=2)),  ('logit', LogisticRegression())])<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">plot_boundary(logit_pipe, X, y, &quot;Logistic Regression + quadratic features. XOR problem&quot;)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/9af\/085\/a4c\/9af085a4c6ff4f83bcb92b6ea974fa01.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u044f\u043c\u0443\u044e \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043f\u043b\u043e\u0445\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. <\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/dad\/465\/d87\/dad465d87b3d409c95a4fafb995335ef.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0410 \u0432\u043e\u0442 \u0435\u0441\u043b\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e 2 \u0441\u0442\u0435\u043f\u0435\u043d\u0438, \u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f. <\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/db7\/93f\/419\/db793f4197254722aead5e409200990e.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u043b\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c, \u043d\u043e \u0432 6-\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/994\/d68\/bb1\/994d68bb11672175bce45de7c055d6e2.svg\" alt=\"$1, x_1, x_2, x_1^2, x_1x_2$\" data-tex=\"inline\"\/><\/math> \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/256\/691\/305\/256691305a99b89dbaaa754412aaf684.svg\" alt=\"$x_2^2$\" data-tex=\"inline\"\/><\/math>. \u0412 \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0438 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e1a\/6ad\/db4\/e1a6addb481fa42c0a9cefa64794767c.svg\" alt=\"$x_1, x_2$\" data-tex=\"inline\"\/><\/math> \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439. <\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442, \u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u0445 \u044f\u0432\u043d\u043e \u2013 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 SVM \u0441 \u044f\u0434\u0440\u043e\u0432\u044b\u043c \u0442\u0440\u044e\u043a\u043e\u043c. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 (\u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439-\u044f\u0434\u0440\u043e\u043c), \u0430 \u044f\u0432\u043d\u043e \u043f\u043b\u043e\u0434\u0438\u0442\u044c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f. \u041f\u0440\u043e \u044d\u0442\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u043a\u0443\u0440\u0441\u0435 \u0415\u0432\u0433\u0435\u043d\u0438\u044f \u0421\u043e\u043a\u043e\u043b\u043e\u0432\u0430 \u2013 <a href=\"https:\/\/github.com\/esokolov\/ml-course-msu\/blob\/master\/ML16\/lecture-notes\/Sem10_linear.pdf\">\u0442\u0443\u0442<\/a> (\u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0443\u0436\u0435 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u0430\u044f).<\/p>\n<p>  <\/p>\n<h3 id=\"5-krivye-validacii-i-obucheniya\">5. \u041a\u0440\u0438\u0432\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u041c\u044b \u0443\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441:<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u0441 \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0438\u043b\u0438 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c?<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432?<\/li>\n<li>\u0418\u043b\u0438 \u043d\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f?<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u0435\u0436\u0430\u0442 \u043d\u0430 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0438\u043d\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0443\u0445\u0443\u0434\u0448\u0435\u043d\u0438\u044e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439. \u041b\u0438\u0431\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043e\u0449\u0443\u0442\u0438\u043c\u044b\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c. \u0421\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430 \u043e\u0442 \u043f\u043b\u043e\u0445\u043e\u0433\u043e.<\/p>\n<p>  <\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \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. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u043c\u043f\u043e\u0440\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from __future__ import division, print_function # \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043c \u0432\u0441\u044f\u043a\u0438\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f Anaconda import warnings warnings.filterwarnings('ignore') %matplotlib inline from matplotlib import pyplot as plt import seaborn as sns  import numpy as np import pandas as pd from sklearn.preprocessing import PolynomialFeatures from sklearn.pipeline import Pipeline from sklearn.preprocessing import StandardScaler from sklearn.linear_model import LogisticRegression, LogisticRegressionCV, SGDClassifier from sklearn.model_selection import validation_curve  data = pd.read_csv('..\/..\/data\/telecom_churn.csv').drop('State', axis=1) data['International plan'] = data['International plan'].map({'Yes': 1, 'No': 0}) data['Voice mail plan'] = data['Voice mail plan'].map({'Yes': 1, 'No': 0})  y = data['Churn'].astype('int').values X = data.drop('Churn', axis=1).values<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0443\u0447\u0430\u0442\u044c \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u043c \u0441\u043f\u0443\u0441\u043a\u043e\u043c. \u041f\u043e\u043a\u0430 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c \u044d\u0442\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u043e \u0434\u0430\u043b\u0435\u0435 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0443 \u043d\u0430\u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u043e. \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043a\u0440\u0438\u0432\u044b\u0435, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435, \u043a\u0430\u043a \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e (ROC AUC) \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u0447\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">alphas = np.logspace(-2, 0, 20) sgd_logit = SGDClassifier(loss='log', n_jobs=-1, random_state=17) logit_pipe = Pipeline([('scaler', StandardScaler()), ('poly', PolynomialFeatures(degree=2)),  ('sgd_logit', sgd_logit)]) val_train, val_test = validation_curve(logit_pipe, X, y, 'sgd_logit__alpha', alphas, cv=5, scoring='roc_auc')  def plot_with_err(x, data, **kwargs): mu, std = data.mean(1), data.std(1) lines = plt.plot(x, mu, '-', **kwargs) plt.fill_between(x, mu - std, mu + std, edgecolor='none', facecolor=lines[0].get_color(), alpha=0.2)  plot_with_err(alphas, val_train, label='training scores') plot_with_err(alphas, val_test, label='validation scores') plt.xlabel(r'$\\alpha$'); plt.ylabel('ROC AUC') plt.legend();<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c26\/4bb\/f89\/c264bbf897184a0ea70a0f3fb7cdabc3.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043d\u0434\u0435\u043d\u0446\u0438\u044f \u0432\u0438\u0434\u043d\u0430 \u0441\u0440\u0430\u0437\u0443, \u0438 \u043e\u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<ul>\n<li>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u0430\u044f \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u0440\u044f\u0434\u043e\u043c, \u0438 \u043e\u043d\u0438 \u0432\u0435\u043b\u0438\u043a\u0438. \u042d\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c <strong>\u043d\u0435\u0434\u043e\u043e\u0431\u0443\u0447\u0438\u043b\u0430\u0441\u044c<\/strong>: \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043d\u0430 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<p>  <\/li>\n<li>\u0414\u043b\u044f \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u0430\u044f \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c <strong>\u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c<\/strong>: \u043a\u043e\u0433\u0434\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0431\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043e\u0436\u0435\u0442 &quot;\u043e\u0442\u0432\u043b\u0435\u043a\u0430\u0442\u044c\u0441\u044f&quot; \u043d\u0430 \u0448\u0443\u043c \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0443\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0440\u0435\u043d\u0434.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0445?<\/strong><\/p>\n<p>  <\/p>\n<p>\u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c, \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435. \u041d\u043e \u043a\u0430\u043a \u043d\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043b\u0438 \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435? \u0421\u043a\u0430\u0436\u0435\u043c, \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u043b\u0438 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c N\\$ \u043d\u0430 \u0442\u0440\u0443\u0434 \u0430\u0441\u0435\u0441\u0441\u043e\u0440\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0432\u0434\u0432\u043e\u0435?<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0431\u044b\u0442\u044c, \u0440\u0430\u0437\u0443\u043c\u043d\u043e \u043f\u043e\u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u043c\u0435\u044e\u0449\u0435\u0439\u0441\u044f \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043e\u0431\u044a\u0435\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043e\u0431\u0443\u0447\u0430\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c. \u0422\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f <strong>\u043a\u0440\u0438\u0432\u044b\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/strong> (<strong>learning curves<\/strong>).<\/p>\n<p>  <\/p>\n<p>\u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u043c\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">from sklearn.model_selection import learning_curve  def plot_learning_curve(degree=2, alpha=0.01): train_sizes = np.linspace(0.05, 1, 20) logit_pipe = Pipeline([('scaler', StandardScaler()), ('poly', PolynomialFeatures(degree=degree)),  ('sgd_logit', SGDClassifier(n_jobs=-1, random_state=17, alpha=alpha))]) N_train, val_train, val_test = learning_curve(logit_pipe, X, y, train_sizes=train_sizes, cv=5, scoring='roc_auc') plot_with_err(N_train, val_train, label='training scores') plot_with_err(N_train, val_test, label='validation scores') plt.xlabel('Training Set Size'); plt.ylabel('AUC') plt.legend()  plot_learning_curve(degree=2, alpha=10)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ccd\/d66\/8ec\/ccdd668ec5d042ca8cefc0e91681fedb.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0422\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f: \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f, \u0447\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435. \u0414\u043b\u044f \u0442\u043e\u0439 \u0436\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u043e \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u0431\u044a\u0435\u043c\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043a\u0438 &quot;\u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f&quot;, \u0447\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u0434\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0442\u0438, \u043d\u043e \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c\u0441\u044f. <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u043e\u0448\u0438\u0431\u043a\u0438 &quot;\u0441\u043e\u0448\u043b\u0438\u0441\u044c&quot;, \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439 \u2013 \u0441\u0430\u043c\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0434\u043b\u044f \u0431\u0438\u0437\u043d\u0435\u0441\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0432 10 \u0440\u0430\u0437. \u041d\u043e \u0435\u0441\u043b\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u043f\u043e\u043c\u043e\u0447\u044c. \u0422\u043e \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f &quot;\u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u2013 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e 10 \u0440\u0430\u0437&quot; \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. <\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 (\u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0434\u043e 0.05)?<\/p>\n<p>  <\/p>\n<p>\u0412\u0438\u0434\u0438\u043c \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u0442\u0435\u043d\u0434\u0435\u043d\u0446\u0438\u044e \u2013 \u043a\u0440\u0438\u0432\u044b\u0435 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f, \u0438 \u0435\u0441\u043b\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043e (\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0435), \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438. <\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/111\/631\/1aa\/1116311aaf2848db9c5ef4d4c6f993b3.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 (<math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f44\/208\/e13\/f44208e13b486f46b2e257a844a331da.svg\" alt=\"$alpha=10^{-4}$\" data-tex=\"inline\"\/><\/math>)?<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u2013 AUC \u043f\u0430\u0434\u0430\u0435\u0442 \u043a\u0430\u043a \u043d\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438, \u0442\u0430\u043a \u0438 \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p><div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f65\/b03\/f62\/f65b03f62a6f47de9e70b53691798b5c.png\"  width=\"80%\"\/><\/div>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0421\u0442\u0440\u043e\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043a\u0440\u0438\u0432\u044b\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0432 \u043a\u0430\u043a\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f, \u0438 \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <\/p>\n<p><strong>\u0412\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u043a\u0440\u0438\u0432\u044b\u043c \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>  <\/p>\n<ul>\n<li>\u041e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/li>\n<li>\u041a\u0440\u043e\u0441\u0441-\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0434\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0435 (\u0438\u043c\u0435\u044e\u0449\u0438\u0439\u0441\u044f \u0442\u0440\u0435\u043d\u0434 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445), \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/li>\n<li><strong>\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u043a\u0440\u0438\u0432\u0430\u044f<\/strong> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0433\u0440\u0430\u0444\u0438\u043a, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0439 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 <strong>\u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438<\/strong>:<\/li>\n<li>\u0435\u0441\u043b\u0438 \u0434\u0432\u0435 \u043a\u0440\u0438\u0432\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0433\u0430\u044e\u0442\u0441\u044f \u0431\u043b\u0438\u0437\u043a\u043e, \u0438 \u043e\u0431\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u0435\u043b\u0438\u043a\u0438, \u2014 \u044d\u0442\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a <em>\u043d\u0435\u0434\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/em><\/li>\n<li>\u0435\u0441\u043b\u0438 \u0434\u0432\u0435 \u043a\u0440\u0438\u0432\u044b\u0435 \u0434\u0430\u043b\u0435\u043a\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430, \u2014 \u044d\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c <em>\u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/em><\/li>\n<li><strong>\u041a\u0440\u0438\u0432\u0430\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/strong> \u2014 \u044d\u0442\u043e \u0433\u0440\u0430\u0444\u0438\u043a, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0439 \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439:<\/li>\n<li>\u0435\u0441\u043b\u0438 \u043a\u0440\u0438\u0432\u044b\u0435 \u0441\u043e\u0448\u043b\u0438\u0441\u044c \u0434\u0440\u0443\u0433 \u043a \u0434\u0440\u0443\u0433\u0443, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u2013 \u043d\u0430\u0434\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 <\/li>\n<li>\u0435\u0441\u043b\u0438 \u043a\u0440\u0438\u0432\u044b\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0441\u043e\u0448\u043b\u0438\u0441\u044c, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/li>\n<\/ul>\n<p>  <\/p>\n<h1 id=\"6-plyusy-i-minusy-lineynyh-modeley-v-zadachah-mashinnogo-obucheniya\">6. \u041f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \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<\/h1>\n<p>  <\/p>\n<p>\u041f\u043b\u044e\u0441\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0425\u043e\u0440\u043e\u0448\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u044b<\/li>\n<li>\u041e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0435, \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445<\/li>\n<li>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043d\u0435 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e (\u043e\u0442 \u0441\u043e\u0442\u0435\u043d \u0442\u044b\u0441\u044f\u0447 \u0438 \u0431\u043e\u043b\u0435\u0435), \u0438 \u043e\u043d\u0438 \u0440\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u044b\u0435 (\u0445\u043e\u0442\u044f \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b)<\/li>\n<li>\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f (\u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0447\u0442\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u044b) \u2013 \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043d\u044b\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u0432 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u2013 \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432<\/li>\n<li>\u041b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0432\u044b\u0434\u0430\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043a \u0440\u0430\u0437\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c (\u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0446\u0435\u043d\u0438\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u043e\u043c \u0441\u043a\u043e\u0440\u0438\u043d\u0433\u0435)<\/li>\n<li>\u041c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443, \u0435\u0441\u043b\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041c\u0438\u043d\u0443\u0441\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043b\u043e\u0445\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043e\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441\u043b\u043e\u0436\u043d\u0430\u044f, \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f<\/li>\n<li>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u041c\u0430\u0440\u043a\u043e\u0432\u0430-\u0413\u0430\u0443\u0441\u0441\u0430 \u043f\u043e\u0447\u0442\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0430\u0449\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0445\u0443\u0436\u0435, \u0447\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, SVM \u0438 \u0430\u043d\u0441\u0430\u043c\u0431\u043b\u0438 (\u043f\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\/\u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438)<\/li>\n<\/ul>\n<p>  <\/p>\n<h1 id=\"7-domashnee-zadanie--4\">7. \u0414\u043e\u043c\u0430\u0448\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u2116 4<\/h1>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435, \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u2013 <a href=\"https:\/\/github.com\/Yorko\/mlcourse_open\/tree\/master\/jupyter_notebooks\/topic4_linear_models\/hw4_part1_websites_logistic_regression.ipynb\">\u0427\u0430\u0441\u0442\u044c 1<\/a> \u0438 <a href=\"https:\/\/github.com\/Yorko\/mlcourse_open\/tree\/master\/jupyter_notebooks\/topic4_linear_models\/hw4_part2_habr_popularity_ridge.ipynb\">\u0427\u0430\u0441\u0442\u044c 2<\/a>. \u041d\u0430\u0434\u043e \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u0434\u0432\u0443\u0445 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f\u0445 Kaggle Inclass.<\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430\u0434\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432 <a href=\"https:\/\/goo.gl\/forms\/xA3xkNkgMp1aNdgn2\">\u0432\u0435\u0431-\u0444\u043e\u0440\u043c\u0435<\/a>. \u041c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0437\u0430 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u2013 18 \u0431\u0430\u043b\u043b\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><strong>\u0421\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f Kaggle Inclass \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u0443\u0440\u0441\u0435<\/strong><\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c 2 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u0443\u0440\u0441\u0430: <\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/inclass.kaggle.com\/c\/howpop-habrahabr-favs-lognorm\">\u041f\u0435\u0440\u0432\u043e\u0435<\/a> &quot;\u041f\u0440\u043e\u0433\u043d\u043e\u0437 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435&quot;<\/li>\n<li><a href=\"https:\/\/inclass.kaggle.com\/c\/catch-me-if-you-can-intruder-detection-through-webpage-session-tracking\">\u0412\u0442\u043e\u0440\u043e\u0435<\/a> &quot;\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0432\u0437\u043b\u043e\u043c\u0449\u0438\u043a\u0430 \u043f\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u0441\u0430\u0439\u0442\u0430\u043c&quot;. <\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u0439.<br \/>  \u0417\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e 40 \u0431\u0430\u043b\u043b\u043e\u0432. \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0447\u0438\u0441\u043b\u0430 \u0431\u0430\u043b\u043b\u043e\u0432: <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5b1\/d40\/d84\/5b1d40d8401ba0b117bde2ad5d184a4d.svg\" alt=\"$40 (1 - (p-1)\/ N)$\" data-tex=\"inline\"\/><\/math>, \u0433\u0434\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/112\/bb3\/965\/112bb396570b07f26f792e48c3447496.svg\" alt=\"$p$\" data-tex=\"inline\"\/><\/math> \u2013 \u043c\u0435\u0441\u0442\u043e \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430 \u0432 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u043c \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0435, <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/644\/86c\/eab\/64486ceabd5fd2c0d8f3df3093ef55bc.svg\" alt=\"$N$\" data-tex=\"inline\"\/><\/math> \u2013 \u0447\u0438\u0441\u043b\u043e \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432, \u043f\u043e\u0431\u0438\u0432\u0448\u0438\u0445 \u0432\u0441\u0435 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438 \u0432 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u043c \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0435 (\u0435\u0449\u0435 \u043c\u043e\u0433\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438).<\/p>\n<p>  <\/p>\n<h1 id=\"8-obzor-poleznyh-resursov\">8. \u041e\u0431\u0437\u043e\u0440 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/h1>\n<p>  <\/p>\n<ul>\n<li>\u041e\u0441\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0437\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0438 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441\u0434\u0435\u043b\u0430\u043d \u0432 <a href=\"https:\/\/www.deeplearningbook.org\/\">\u043a\u043d\u0438\u0433\u0435<\/a> &quot;Deep Learning&quot; (I. Goodfellow, Y. Bengio, A. Courville, 2016);<\/li>\n<li>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043d\u043e\u0433\u0438\u0445 \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 \u0441 \u043d\u0443\u043b\u044f \u2013 <a href=\"https:\/\/github.com\/rushter\/MLAlgorithms\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a> <a href=\"https:\/\/habrahabr.ru\/users\/rushter\/\" class=\"user_link\">rushter<\/a>. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438;<\/li>\n<li><a href=\"https:\/\/github.com\/esokolov\/ml-course-msu\">\u041a\u0443\u0440\u0441<\/a> \u0415\u0432\u0433\u0435\u043d\u0438\u044f \u0421\u043e\u043a\u043e\u043b\u043e\u0432\u0430 \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e (\u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u043d\u0430 GitHub). \u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0442\u0435\u043e\u0440\u0438\u044f, \u043d\u0443\u0436\u043d\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u0430\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430;<\/li>\n<li><a href=\"https:\/\/github.com\/diefimov\">\u041a\u0443\u0440\u0441<\/a> \u0414\u043c\u0438\u0442\u0440\u0438\u044f \u0415\u0444\u0438\u043c\u043e\u0432\u0430 \u043d\u0430 GitHub (\u0430\u043d\u0433\u043b.). \u0422\u043e\u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>\u0421\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0441\u043e\u0430\u0432\u0442\u043e\u0440\u0441\u0442\u0432\u0435 \u0441 <a href=\"https:\/\/habrahabr.ru\/users\/mephistopheies\/\" class=\"user_link\">mephistopheies<\/a>. \u0410\u0432\u0442\u043e\u0440\u044b \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u2013 \u041e\u043b\u044c\u0433\u0430 \u0414\u0430\u0439\u0445\u043e\u0432\u0441\u043a\u0430\u044f \u0438 \u042e\u0440\u0438\u0439 \u0418\u0441\u0430\u043a\u043e\u0432. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e <a href=\"https:\/\/habrahabr.ru\/users\/bauchgefuehl\/\" class=\"user_link\">bauchgefuehl<\/a> \u0437\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/em><\/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\/323890\/\"> https:\/\/habrahabr.ru\/post\/323890\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/256\/a5d\/ed0\/256a5ded03274e0f87ccf97164c31c35.png\" align=\"right\" width=\"45%\"\/>  <\/p>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u2013 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445.<br \/>  \u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043d\u0430\u0448\u0435\u0439 \u043f\u043e\u0434\u0430\u0447\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043e\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0433\u043e \u0432 \u043a\u0443\u0440\u0441\u0430\u0445 \u044d\u043a\u043e\u043d\u043e\u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u2013 \u044d\u0442\u043e \u0430\u043a\u0446\u0435\u043d\u0442 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 (\u0445\u043e\u0442\u044f \u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043c\u0430\u043b\u043e). <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0432\u0443\u0445 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u2013 \u044d\u0442\u043e \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f Kaggle Inclass \u043f\u043e <a href=\"https:\/\/inclass.kaggle.com\/c\/howpop-habrahabr-favs-lognorm\">\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438<\/a> \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0438 \u043f\u043e <a href=\"https:\/\/inclass.kaggle.com\/c\/catch-me-if-you-can-intruder-detection-through-webpage-session-tracking\">\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u0437\u043b\u043e\u043c\u0449\u0438\u043a\u0430<\/a> \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043f\u043e \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u0441\u0430\u0439\u0442\u0430\u043c. \u0414\u043e\u043c\u0430\u0448\u043d\u0438\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0435\u043c \u21164 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u044d\u0442\u0438\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445. <\/p>\n<p>  <\/p>\n<p>\u0410 \u043f\u043e\u043a\u0430 \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 3 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u2013 \u0434\u043e 23:59 20 \u043c\u0430\u0440\u0442\u0430.<br \/>  \u0412\u0441\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 <a href=\"https:\/\/github.com\/Yorko\/mlcourse_open\">GitHub<\/a>.<\/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-283611","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283611","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=283611"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283611\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}