{"id":371537,"date":"2024-05-21T04:51:12","date_gmt":"2024-05-21T04:51:12","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=371537"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T04:51:12","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=371537","title":{"rendered":"<span>\u041c\u0435\u0442\u043e\u0434 \u043e\u043f\u043e\u0440\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 (SVM). \u041f\u043e\u0434\u0445\u043e\u0434\u044b, \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 Python<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1b2\/092\/0f8\/1b20920f81633a746466cfa05ce43136.png\" width=\"771\" height=\"443\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1b2\/092\/0f8\/1b20920f81633a746466cfa05ce43136.png\"\/><\/figure>\n<p>\u041c\u0435\u0442\u043e\u0434 \u043e\u043f\u043e\u0440\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 (Support Vector Machines \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e SVM) \u2014 \u043c\u043e\u0449\u043d\u044b\u0439 \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043b\u044e\u0431\u043e\u0439 \u0444\u043e\u0440\u043c\u044b, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u043d\u043e \u0438 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e SVM, \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043d\u0443\u043b\u044f \u0435\u0433\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0435\u0439.  <\/p>\n<blockquote>\n<p><em>\u041d\u043e\u0443\u0442\u0431\u0443\u043a \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0430\u00a0<\/em><a href=\"https:\/\/www.kaggle.com\/code\/egazakharenko\/support-vector-machines-svm-from-scratch\" rel=\"noopener noreferrer nofollow\"><strong><em>Kaggle<\/em><\/strong><\/a><em>\u00a0(eng) \u0438\u00a0<\/em><a href=\"https:\/\/github.com\/egaoharu-kensei\/ML-algorithms-from-scratch.-Course-for-beginners\/blob\/main\/Notebooks%20%5Brus%5D\/ML-%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC%D1%8B%20%D1%81%20%D0%BD%D1%83%D0%BB%D1%8F\/05%29%20%D0%9C%D0%B5%D1%82%D0%BE%D0%B4%20%D0%BE%D0%BF%D0%BE%D1%80%D0%BD%D1%8B%D1%85%20%D0%B2%D0%B5%D0%BA%D1%82%D0%BE%D1%80%D0%BE%D0%B2%20%28SVM%29.ipynb\" rel=\"noopener noreferrer nofollow\"><strong><em>GitHub<\/em><\/strong><\/a><em>\u00a0(rus).<\/em>  <\/p>\n<\/blockquote>\n<h4>\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 SVM<\/h4>\n<p><strong>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/strong>\u00a0\u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f SVM \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043b\u0438\u043d\u0438\u0438, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0431\u043b\u0438\u0436\u0435 \u0432\u0441\u0435\u0433\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 \u043e\u0431\u0440\u0430\u0437\u0446\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f\u00a0<em>\u043e\u043f\u043e\u0440\u043d\u044b\u043c\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438<\/em>. \u041b\u0443\u0447\u0448\u0438\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u043f\u043e\u0440\u043d\u044b\u043c\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c\u044e. \u042d\u0442\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00a0<em>\u0437\u0430\u0437\u043e\u0440\u043e\u043c<\/em>. \u0417\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430:<\/p>\n<ul>\n<li>\n<p>1)\u00a0<strong>\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0441 \u0436\u0451\u0441\u0442\u043a\u0438\u043c \u0437\u0430\u0437\u043e\u0440\u043e\u043c (hard margin)<\/strong>, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0446\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u043f\u043e\u043b\u043e\u0441\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043a \u0432\u044b\u0431\u0440\u043e\u0441\u0430\u043c.<\/p>\n<\/li>\n<li>\n<p>2)\u00a0<strong>\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0441 \u043c\u044f\u0433\u043a\u0438\u043c \u0437\u0430\u0437\u043e\u0440\u043e\u043c (soft margin)<\/strong>, \u043a\u043e\u0433\u0434\u0430 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0446\u044b \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u0432 \u043f\u043e\u043b\u043e\u0441\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0448\u0442\u0440\u0430\u0444 \u0437\u0430 \u0442\u0430\u043a\u0438\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 C (\u0447\u0435\u043c \u043d\u0438\u0436\u0435 \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u0435\u043c \u0448\u0438\u0440\u0435 \u043f\u043e\u043b\u043e\u0441\u0430 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0439 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0437\u0430\u0437\u043e\u0440). \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043e\u0431\u0449\u0430\u044e\u0449\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0440\u0438\u0441\u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u0432\u0435\u0441\u043e\u0432 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 OVR (One-Versus-Rest) \u0438\u043b\u0438 OVA (One-Versus-All), \u0430 \u0434\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c hinge.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"min \\rightarrow C \\sum \\limits_{i=1}^{n} max(0, 1 - y_i (w^TX + b))\" alt=\"min \\rightarrow C \\sum \\limits_{i=1}^{n} max(0, 1 - y_i (w^TX + b))\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cdb\/252\/12f\/cdb25212f1b06b5fb51c2ce74b47b4c9.svg\" width=\"323\" height=\"57\"\/><\/p>\n<blockquote>\n<p><em>\u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 scikit-learn \u043a \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0435\u0449\u0451 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f l1 \u0438\u043b\u0438 l2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0432\u044b\u0431\u043e\u0440, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 loss=&#8217;squared_hinge&#8217;.<\/em><\/p>\n<\/blockquote>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0436\u0451\u0441\u0442\u043a\u0438\u043c \u0438 \u043c\u044f\u0433\u043a\u0438\u043c \u0437\u0430\u0437\u043e\u0440\u043e\u043c \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0432\u044b\u043f\u0443\u043a\u043b\u043e\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0437\u0430\u0434\u0430\u0447\u0430\u043c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Liblinear, \u043d\u043e \u0432 \u0440\u0443\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0438\u0436\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0441\u043f\u0443\u0441\u043a \u0441 \u043e\u0434\u043d\u0438\u043c \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435\u043c: \u0432\u0435\u0441\u0430 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0432\u0441\u0435\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0442\u0441\u0442\u0443\u043f\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 1, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0448\u0435. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u0443\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c hinge loss \u0431\u0435\u0437 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 squared hinge loss \u0441 l2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0432 scikit-learn, \u0430 \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0442\u043e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0432 \u0446\u0435\u043b\u043e\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u043d\u0435\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a2a\/807\/835\/a2a80783546c428560ae67c264908707.png\" alt=\"\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e SVM \u0441 \u0436\u0451\u0441\u0442\u043a\u0438\u043c \u0438 \u043c\u044f\u0433\u043a\u0438\u043c \u0437\u0430\u0437\u043e\u0440\u043e\u043c\" title=\"\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e SVM \u0441 \u0436\u0451\u0441\u0442\u043a\u0438\u043c \u0438 \u043c\u044f\u0433\u043a\u0438\u043c \u0437\u0430\u0437\u043e\u0440\u043e\u043c\" width=\"814\" height=\"543\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a2a\/807\/835\/a2a80783546c428560ae67c264908707.png\"\/><\/p>\n<div><figcaption><strong>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e SVM \u0441 \u0436\u0451\u0441\u0442\u043a\u0438\u043c \u0438 \u043c\u044f\u0433\u043a\u0438\u043c \u0437\u0430\u0437\u043e\u0440\u043e\u043c<\/strong><\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/strong>\u00a0SVM \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0437\u043e\u0440\u043e\u043c \u0438 \u043e\u0431\u0440\u0430\u0437\u0446\u0430\u043c\u0438, \u0447\u0442\u043e \u043b\u0435\u0436\u0430\u0442 \u0437\u0430 \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438, \u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u044c \u0437\u0430\u0437\u043e\u0440\u0430 \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043b\u0438\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u0437\u043e\u0440, \u0448\u0438\u0440\u0438\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c epsilon, \u0430 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f epsilon-insensitive.  <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\min \\rightarrow C \\sum\\limits_{i=1}^{n} \\max(0, |y_i - (w^T \\phi(x_i) + b)| - \\varepsilon)\" alt=\"\\min \\rightarrow C \\sum\\limits_{i=1}^{n} \\max(0, |y_i - (w^T \\phi(x_i) + b)| - \\varepsilon)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/232\/8dd\/a67\/2328dda676dab5033baa7694508925a8.svg\" width=\"379\" height=\"57\"\/><\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/036\/38b\/238\/03638b238fdcd9e69c7a4a0d0059b80f.png\" alt=\"\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e SVM \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438\" title=\"\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e SVM \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438\" width=\"496\" height=\"388\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/036\/38b\/238\/03638b238fdcd9e69c7a4a0d0059b80f.png\"\/><\/p>\n<div><figcaption><strong>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e SVM \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/strong><\/figcaption><\/div>\n<\/figure>\n<blockquote>\n<p><em>\u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439, \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 scikit-learn \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 SVM \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f l1 \u0438\u043b\u0438 l2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0432\u044b\u0431\u043e\u0440, \u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439.<\/em><\/p>\n<\/blockquote>\n<h4>\u041d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 SVM<\/h4>\n<p><strong>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/strong>\u00a0\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438, \u0433\u0434\u0435 \u043e\u043d\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c\u044b\u043c\u0438. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u00a0<em>\u044f\u0434\u0435\u0440\u043d\u043e\u0433\u043e \u0442\u0440\u044e\u043a\u0430<\/em>\u00a0\u2014 \u044d\u0442\u043e \u043f\u0440\u0438\u0451\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 n-\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 n, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0431\u0435\u0437 \u0438\u0445 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\phi(a)^T \\cdot \\phi(b) = (a^T \\cdot b)^n\" alt=\"\\phi(a)^T \\cdot \\phi(b) = (a^T \\cdot b)^n\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7c0\/cf9\/21e\/7c0cf921e1dc22be1d1e69ce512ef7a9.svg\" width=\"192\" height=\"25\"\/><\/p>\n<p>\u0433\u0434\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\phi\" alt=\"\\phi\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f9c\/203\/34a\/f9c20334a92998e5c09d0dfa2585b842.svg\" width=\"11\" height=\"20\"\/> \u2014 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u0438 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"n\" alt=\"n\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c00\/484\/a7d\/c00484a7d0b9011300db40d98327cb18.svg\" width=\"12\" height=\"12\"\/>.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u044f\u0434\u0435\u0440\u043d\u043e\u0433\u043e \u0442\u0440\u044e\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043er\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"\\phi(a)^T \\cdot \\phi(b) = \\left( \\begin{array}{c} a_1^2 \\\\ \\sqrt{2} a_1 a_2  \\\\ a_2^2 \\end{array} \\right)^T \\cdot \\left( \\begin{array}{c} b_1^2 \\\\ \\sqrt{2} b_1 b_2  \\\\ b_2^2 \\end{array} \\right) = a_1^2 b_1^2 + 2a_1 b_1 a_2 b_2 + a_2^2 b_2^2 = \\\\ = (a_1 b_1 + a_2 b_2)^2 = \\left( \\begin{array}{c} \\left( \\begin{array}{c} a_1 \\\\ a_2 \\end{array} \\right)^T \\cdot \\left( \\begin{array}{c} b_1 \\\\ b_2 \\end{array} \\right) \\end{array} \\right)^2 = (a^T \\cdot b)^2\" alt=\"\\phi(a)^T \\cdot \\phi(b) = \\left( \\begin{array}{c} a_1^2 \\\\ \\sqrt{2} a_1 a_2  \\\\ a_2^2 \\end{array} \\right)^T \\cdot \\left( \\begin{array}{c} b_1^2 \\\\ \\sqrt{2} b_1 b_2  \\\\ b_2^2 \\end{array} \\right) = a_1^2 b_1^2 + 2a_1 b_1 a_2 b_2 + a_2^2 b_2^2 = \\\\ = (a_1 b_1 + a_2 b_2)^2 = \\left( \\begin{array}{c} \\left( \\begin{array}{c} a_1 \\\\ a_2 \\end{array} \\right)^T \\cdot \\left( \\begin{array}{c} b_1 \\\\ b_2 \\end{array} \\right) \\end{array} \\right)^2 = (a^T \\cdot b)^2\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3c7\/5e1\/5b9\/3c75e15b92e8a00da2d48f33c64946ad.svg\" width=\"697\" height=\"149\"\/><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3c8\/bca\/a27\/3c8bcaa271d69167c796eb68e4e0001f.png\" width=\"936\" height=\"374\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3c8\/bca\/a27\/3c8bcaa271d69167c796eb68e4e0001f.png\"\/><\/figure>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u0442\u0440\u044e\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u043e \u043c\u0435\u0436\u0434\u0443 \u043f\u0430\u0440\u0430\u043c\u0438 \u0442\u043e\u0447\u0435\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u044f\u0434\u0440\u043e\u043c. \u0412 scikit-learn \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u044f\u0434\u0440\u0430: <\/p>\n<ul>\n<li>\n<p>\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u0447\u0442\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443:<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"a^T \\cdot b\" alt=\"a^T \\cdot b\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/70f\/753\/a73\/70f753a7324f682867bf553f9f73cca6.svg\" width=\"44\" height=\"21\"\/><\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u2014 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e \u0443\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c \u0432 \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0442\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432  :<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"(\\gamma a^T \\cdot b + r)^d\" alt=\"(\\gamma a^T \\cdot b + r)^d\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/754\/ac0\/9e3\/754ac09e376e3fe929b8d5855532e23d.svg\" width=\"111\" height=\"25\"\/><\/p>\n<ul>\n<li>\n<p>\u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u043e\u0435 RBF (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Radial_basis_function\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0434\u0438\u0430\u043b\u044c\u043d\u043e-\u0431\u0430\u0437\u0438\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/a>) \u2014 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u0438 \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043d\u043e \u0438 \u0438\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"exp(-\\gamma||a - b||^2)\" alt=\"exp(-\\gamma||a - b||^2)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/85e\/8f6\/9d1\/85e8f69d1642102ce1175cd7d572fd5f.svg\" width=\"142\" height=\"26\"\/><\/p>\n<ul>\n<li>\n<p>\u0441\u0438\u0433\u043c\u043e\u0438\u0434\u0430\u043b\u044c\u043d\u043e\u0435 \u2014 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0433\u0438\u043f\u0435\u0440\u0431\u043e\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0430\u043d\u0433\u0435\u043d\u0441 \u043a \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0432\u0443\u0445\u0441\u043b\u043e\u0439\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0441 \u0441\u0438\u0433\u043c\u043e\u0438\u0434\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438 \u0441\u043b\u0443\u0447\u0430\u044f\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0448\u0443\u043c\u0430 \u0438 \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432:<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"tanh(\\gamma a^t \\cdot b + r)\" alt=\"tanh(\\gamma a^t \\cdot b + r)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c85\/f01\/712\/c85f017128e594e2ec5db67382ffdc9c.svg\" width=\"137\" height=\"24\"\/><\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"\\gamma\" alt=\"\\gamma\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/57a\/d8c\/3f9\/57ad8c3f95b4eec8c1fcab4e1d517e48.svg\" width=\"10\" height=\"16\"\/> \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u043c\u0438 \u043e\u0431\u0440\u0430\u0437\u0446\u0430\u043c\u0438: \u0447\u0435\u043c \u043d\u0438\u0436\u0435 \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0434\u0438\u0443\u0441 \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u043d\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0451 \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0430\u0434\u043a\u043e\u0439. \u041c\u0435\u0436\u0434\u0443 \u0442\u0435\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0441\u0434\u0432\u0438\u0433\u0430 <img loading=\"lazy\" decoding=\"async\" class=\"formula inline\" source=\"r\" alt=\"r\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/264\/f28\/b47\/264f28b472d0dfc906ab9634416d3beb.svg\" width=\"9\" height=\"12\"\/> (coef0 \u0432 scikit-learn) \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u044f\u0434\u0440\u0430, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u0442\u0440\u044e\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 SVM, \u043d\u043e \u0438 \u043a \u0434\u0440\u0443\u0433\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u0442\u0440\u044e\u043a \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0441 SVM.  <\/p>\n<p><strong>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/strong>\u00a0SVM \u0442\u0430\u043a\u0436\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c\u044b\u043c\u0438 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0437\u043e\u0440\u043e\u043c \u0438 \u043e\u0431\u0440\u0430\u0437\u0446\u0430\u043c\u0438 \u043a\u0430\u043a \u0438 \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<blockquote>\n<p><em>\u0412 scikit-learn \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438 \u0441\u043b\u0443\u0447\u0430\u044f\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u044b SVR \u0438 SVC \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Libsvm, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u044f\u0434\u0435\u0440\u043d\u043e\u0433\u043e \u0442\u0440\u044e\u043a\u0430 \u0438 l2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c C.<\/em><\/p>\n<\/blockquote>\n<h4>\u0418\u043c\u043f\u043e\u0440\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/h4>\n<pre><code class=\"python\">import numpy as np import pandas as pd import matplotlib.pyplot as plt from mlxtend.plotting import plot_decision_regions from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score, r2_score from sklearn.utils import check_random_state, check_array from sklearn.svm import LinearSVC, LinearSVR, SVC, SVR, _libsvm from sklearn.datasets import load_iris, load_diabetes, load_wine, load_breast_cancer<\/code><\/pre>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u043d\u0443\u043b\u044f<\/h4>\n<p><strong>Linear SVM<\/strong>  <\/p>\n<pre><code class=\"python\">class LinearSVM:     def __init__(self, regression=False, C=1.0, eps=0, learning_rate=0.001, max_iter=1000,                  random_state=0):         self.regression = regression         self.C = C         self.eps = eps         self.learning_rate = learning_rate         self.max_iter = max_iter         self.random_state = random_state      def fit(self, X, y):         if self.regression:             self.bias, self.weights = self._find_weights(X, y)         else:             classes = np.unique(y)             n_classes = len(classes)             _, n_features = X.shape              self.bias = np.zeros(n_classes)             self.weights = np.zeros((n_classes, n_features))             np.random.seed(self.random_state)              for i, cls in enumerate(classes):                 y_binary = np.where(y == cls, 1, -1)                 self.bias[i], self.weights[i] = self._find_weights(X, y_binary)      def _find_weights(self, X, y):         n_samples, n_features = X.shape         bias = 0         weights = np.zeros(n_features) if self.regression else np.random.randn(n_features)          for _ in range(self.max_iter):             for i in range(n_samples):                 y_pred = X[i] @ weights + bias                 margin = y[i] - y_pred if self.regression else y[i] * y_pred                 condition = np.abs(margin) > self.eps if self.regression else margin &lt; 1                  if condition:                     if self.regression:                         db = -self.C * (margin - self.eps)                         dw = -self.C * (margin - self.eps) * X[i]                     else:                         db = -self.C * y[i]                         dw = -self.C * y[i] * X[i]                      bias -= self.learning_rate * db                     weights -= self.learning_rate * dw          return bias, weights      def predict(self, X):         scores = X @ self.weights.T + self.bias          return scores if self.regression else np.argmax(scores, axis=1)<\/code><\/pre>\n<p><strong>Kernel SVM \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Libsvm<\/strong><\/p>\n<pre><code class=\"python\">class SVM:     def __init__(self, regression=False, C=1.0, kernel='rbf', degree=3, solver='auto',                  gamma='scale', epsilon=0.1, coef0=0.0, shrinking=True, probability=False,                  tol=0.001, cache_size=200, max_iter=-1, random_state=None):         self.regression = regression         self.C = C         self.kernel = kernel         self.degree = degree         self.solver = solver         self.gamma = gamma         self.epsilon = epsilon         self.coef0 = coef0         self.shrinking = shrinking         self.probability = probability         self.tol = tol         self.cache_size = cache_size         self.max_iter = max_iter         self.random_state = random_state      def fit(self, X, y):         X = X.astype(np.float64)         y = y.astype(np.float64)          rnd = check_random_state(self.random_state)         seed = rnd.randint(np.iinfo('i').max)          if self.gamma == 'scale':             self.gamma = 1.0 \/ (X.shape[1] * X.var()) if X.var() != 0 else 1.0         elif self.gamma == 'auto':                 self.gamma = 1.0 \/ X.shape[1]         else:             self.gamma = self.gamma          if self.solver == 'auto':             self.solver = 'epsilon_svr' if self.regression else 'c_svc'          libsvm_impl = ['c_svc', 'nu_svc', 'one_class', 'epsilon_svr', 'nu_svr']         self.solver = libsvm_impl.index(self.solver)          (self.support_, self.support_vectors_, self._n_support, self.dual_coef_, self.intercept_,          self._probA, self._probB, self.fit_status_, self._num_iter          ) = _libsvm.fit(X, y, C=self.C, svm_type=self.solver, kernel=self.kernel, gamma=self.gamma,                         degree=self.degree, epsilon=self.epsilon, coef0=self.coef0, tol=self.tol,                         shrinking=self.shrinking, probability=self.probability,                         cache_size=self.cache_size, max_iter=self.max_iter, random_seed=seed                         )      def predict(self, X_test):         X_test = X_test.astype(np.float64)         prediction = _libsvm.predict(X_test, self.support_, self.support_vectors_, self._n_support,                                      self.dual_coef_, self.intercept_, self._probA, self._probB,                                      svm_type=self.solver, kernel=self.kernel, degree=self.degree,                                      coef0=self.coef0, gamma=self.gamma, cache_size=self.cache_size                                      )          return prediction if self.regression else prediction.astype(int)<\/code><\/pre>\n<h4>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/h4>\n<pre><code class=\"python\">def decision_boundary_plot(X, y, X_train, y_train, clf, feature_indexes, title=None):     feature1_name, feature2_name = X.columns[feature_indexes]     X_feature_columns = X.values[:, feature_indexes]     X_train_feature_columns = X_train[:, feature_indexes]     clf.fit(X_train_feature_columns, y_train)      plot_decision_regions(X=X_feature_columns, y=y.values, clf=clf)     plt.xlabel(feature1_name)     plt.ylabel(feature2_name)     plt.title(title)<\/code><\/pre>\n<h4>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432<\/h4>\n<pre><code class=\"python\">X1, y1 = load_iris(return_X_y=True, as_frame=True) X1_train, X1_test, y1_train, y1_test = train_test_split(X1.values, y1.values, random_state=0) print(X1, y1, sep='\\n')        sepal length (cm)  sepal width (cm)  petal length (cm)  petal width (cm) 0                  5.1               3.5                1.4               0.2 1                  4.9               3.0                1.4               0.2 2                  4.7               3.2                1.3               0.2 3                  4.6               3.1                1.5               0.2 4                  5.0               3.6                1.4               0.2 ..                 ...               ...                ...               ... 145                6.7               3.0                5.2               2.3 146                6.3               2.5                5.0               1.9 147                6.5               3.0                5.2               2.0 148                6.2               3.4                5.4               2.3 149                5.9               3.0                5.1               1.8  [150 rows x 4 columns] 0      0 1      0 2      0 3      0 4      0       .. 145    2 146    2 147    2 148    2 149    2 Name: target, Length: 150, dtype: int64<\/code><\/pre>\n<pre><code class=\"python\">X2, y2 = load_diabetes(return_X_y=True, as_frame=True) X2_train, X2_test, y2_train, y2_test = train_test_split(X2.values, y2.values, random_state=0) print(X2, y2, sep='\\n')             age       sex       bmi        bp        s1        s2        s3  \\ 0    0.038076  0.050680  0.061696  0.021872 -0.044223 -0.034821 -0.043401    1   -0.001882 -0.044642 -0.051474 -0.026328 -0.008449 -0.019163  0.074412    2    0.085299  0.050680  0.044451 -0.005670 -0.045599 -0.034194 -0.032356    3   -0.089063 -0.044642 -0.011595 -0.036656  0.012191  0.024991 -0.036038    4    0.005383 -0.044642 -0.036385  0.021872  0.003935  0.015596  0.008142    ..        ...       ...       ...       ...       ...       ...       ...    437  0.041708  0.050680  0.019662  0.059744 -0.005697 -0.002566 -0.028674    438 -0.005515  0.050680 -0.015906 -0.067642  0.049341  0.079165 -0.028674    439  0.041708  0.050680 -0.015906  0.017293 -0.037344 -0.013840 -0.024993    440 -0.045472 -0.044642  0.039062  0.001215  0.016318  0.015283 -0.028674    441 -0.045472 -0.044642 -0.073030 -0.081413  0.083740  0.027809  0.173816                s4        s5        s6   0   -0.002592  0.019907 -0.017646   1   -0.039493 -0.068332 -0.092204   2   -0.002592  0.002861 -0.025930   3    0.034309  0.022688 -0.009362   4   -0.002592 -0.031988 -0.046641   ..        ...       ...       ...   437 -0.002592  0.031193  0.007207   438  0.034309 -0.018114  0.044485   439 -0.011080 -0.046883  0.015491   440  0.026560  0.044529 -0.025930   441 -0.039493 -0.004222  0.003064    [442 rows x 10 columns] 0      151.0 1       75.0 2      141.0 3      206.0 4      135.0        ...   437    178.0 438    104.0 439    132.0 440    220.0 441     57.0 Name: target, Length: 442, dtype: float64<\/code><\/pre>\n<h4>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432<\/h4>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 SVC \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u043b\u0443\u0447\u0448\u0435 LinearSVC, \u0441\u0434\u0435\u043b\u0430\u0432 \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b SVC \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0433\u0438\u0431\u043a\u0438\u043c\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0432 \u043c\u043d\u043e\u0433\u043e\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 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435.  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0443\u0447\u0448\u0435, \u0447\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438: \u0447\u0430\u0441\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u044f\u0434\u0440\u043e \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<p><strong>LinearSVC<\/strong>  <\/p>\n<pre><code class=\"python\">linear_svc = LinearSVM(random_state=0) linear_svc.fit(X1_train, y1_train) linear_svc_pred_res = linear_svc.predict(X1_test) linear_svc_accuracy = accuracy_score(y1_test, linear_svc_pred_res)  print(f'LinearSVC accuracy: {linear_svc_accuracy:}') print(linear_svc_pred_res)   LinearSVC accuracy: 0.9210526315789473 [2 1 0 2 0 2 0 1 1 1 2 1 1 1 1 0 1 1 0 0 2 2 0 0 2 0 0 1 1 0 2 2 0 2 2 1 0  2]<\/code><\/pre>\n<p><strong>LinearSVC (scikit-learn)<\/strong>  <\/p>\n<pre><code class=\"python\">sk_linear_svc = LinearSVC(loss='squared_hinge', max_iter=10000, random_state=0) sk_linear_svc.fit(X1_train, y1_train) sk_linear_svc_pred_res = sk_linear_svc.predict(X1_test) sk_linear_svc_accuracy = accuracy_score(y1_test, sk_linear_svc_pred_res)  print(f'sk LinearSVC accuracy: {sk_linear_svc_accuracy:}') print(sk_linear_svc_pred_res)  feature_indexes = [2, 3] title1 = 'LinearSVC surface' decision_boundary_plot(X1, y1, X1_train, y1_train, sk_linear_svc, feature_indexes, title1)   sk LinearSVC accuracy: 0.9210526315789473 [2 1 0 2 0 2 0 1 1 1 2 1 1 1 1 0 1 1 0 0 2 2 0 0 2 0 0 1 1 0 2 2 0 2 2 1 0  2]<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/24c\/6ab\/7f1\/24c6ab7f1d5871d065c539d8a016ff40.png\" width=\"578\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/24c\/6ab\/7f1\/24c6ab7f1d5871d065c539d8a016ff40.png\"\/><\/figure>\n<p><strong>SVC<\/strong> <\/p>\n<pre><code class=\"python\">svc = SVM(random_state=0, gamma='auto') svc.fit(X1_train, y1_train) svc_pred_res = svc.predict(X1_test) svc_accuracy = accuracy_score(y1_test, svc_pred_res)  print(f'SVC accuracy: {svc_accuracy:}') print(svc_pred_res)   SVC accuracy: 0.9736842105263158 [2 1 0 2 0 2 0 1 1 1 2 1 1 1 1 0 1 1 0 0 2 1 0 0 2 0 0 1 1 0 2 1 0 2 2 1 0  2]<\/code><\/pre>\n<p><strong>SVC (scikit-learn)<\/strong>  <\/p>\n<pre><code class=\"python\">sk_svc = SVC(random_state=0, gamma='auto') sk_svc.fit(X1_train, y1_train) sk_svc_pred_res = sk_svc.predict(X1_test) sk_svc_accuracy = accuracy_score(y1_test, sk_svc_pred_res)  print(f'sk SVC accuracy: {sk_svc_accuracy:}') print(sk_svc_pred_res)  feature_indexes = [2, 3] title2 = 'SVC surface' decision_boundary_plot(X1, y1, X1_train, y1_train, sk_svc, feature_indexes, title2)   sk SVC accuracy: 0.9736842105263158 [2 1 0 2 0 2 0 1 1 1 2 1 1 1 1 0 1 1 0 0 2 1 0 0 2 0 0 1 1 0 2 1 0 2 2 1 0  2]<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/80c\/896\/815\/80c89681581f86c234dac86797c43b3e.png\" width=\"578\" height=\"455\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/80c\/896\/815\/80c89681581f86c234dac86797c43b3e.png\"\/><\/figure>\n<p><strong>LinearSVR<\/strong>  <\/p>\n<pre><code class=\"python\">linear_svr = LinearSVM(regression=True) linear_svr.fit(X2_train, y2_train) linear_svr_pred_res = linear_svr.predict(X2_test) linear_svr_r2 = r2_score(y2_test, linear_svr_pred_res)  print(f'LinearSVR r2 score: {linear_svr_r2:}') print(linear_svr_pred_res)   LinearSVR r2 score: 0.3792357370266678 [216.15968628 220.4481875  165.81989913 123.24660088 162.79339624  219.32628582 114.40328867 187.29239041 135.60608051 192.94216428  142.8356438  186.26887666 115.93676843  92.65131502 237.37770913  105.70347983 140.17045763  78.03390184  93.19336622 213.55077346  172.96582698 141.23351563 160.93321605 136.06861865 189.99746346  162.00412166 119.88834206  95.16558303 169.4791898  167.9510029  178.92773537  94.54901318 131.32930116 143.22717983 158.62314035  179.63207827 161.26232493 184.99305841 137.0911429  190.80874425   97.79122811 174.20746847 149.93081547 163.6511185  186.25250505   89.10531469 134.71035596 137.85610675 143.47793077 213.7920584  154.13931085  96.48578013 152.68919476 164.92850238 204.49516212  184.36868908 186.98158124 104.04646649 155.49588864 175.27621381  180.18811448 150.78618876 162.95426399 136.68414224 221.99330585  141.62183394  91.8349318  225.76370605 194.54965172  69.11345544   92.30405285 151.11667643 118.33817248 133.31474617 136.09121693  187.03275101 135.91418347 203.47303573 220.93494444 180.79064789  153.63359556 202.03121138  85.14842597 208.72273567  91.56979646  107.38020014 130.37078711 184.64399992 135.46766588 160.00350266   90.34899353 133.82900713  91.48257892 159.99266924 128.72744725  113.3641814  212.27373852 201.97525592 141.00148555 165.9290978  178.10808713  91.31945385 201.40199857 116.11341335 205.99603552  149.74428959 212.73484188 241.66640456 118.74948785 128.32248729  186.72222586]<\/code><\/pre>\n<p><strong>LinearSVR (scikit-learn)<\/strong>  <\/p>\n<pre><code class=\"python\">sk_linear_svr = LinearSVR(loss='squared_epsilon_insensitive') sk_linear_svr.fit(X2_train, y2_train) sk_linear_svr_pred_res = sk_linear_svr.predict(X2_test) sk_linear_svr_r2 = r2_score(y2_test, sk_linear_svr_pred_res)  print(f'sk LinearSVR R2 score: {sk_linear_svr_r2:}') print(sk_linear_svr_pred_res)   sk LinearSVR R2 score: 0.37814542044497423 [215.54802943 220.69479521 163.72321514 125.35050039 168.23663006  222.87285934 117.76887939 183.439543   143.23792374 199.25861483  149.2464745  180.13546176 117.73284104  98.8129158  229.40677283  107.70075384 144.10708869  83.42833432 101.75722386 207.55264272  177.38566123 146.60127268 159.10274119 144.47851976 188.12741871  161.72800999 122.19555137  98.38934168 172.04469244 163.88747259  174.31869231  98.56101933 137.43514957 143.99818253 152.57005935  180.16575707 160.23942338 181.13802512 137.10299603 190.01855923   99.30200726 168.53506831 147.88091211 166.46196854 180.1601789   91.81189072 137.23909085 140.51020744 137.65220301 212.07954464  154.84803714  97.88215713 154.47755522 160.16521948 206.99600783  176.91673261 183.28777653 113.64466494 148.4110365  170.98296686  185.33374519 155.94941503 161.03649538 131.05262642 225.54785872  145.68037375  95.41892062 217.82197857 191.37652659  70.60017863   96.29414312 144.83768093 117.20983217 138.05827775 137.59789698  182.48375573 127.73687759 196.85281425 212.96526525 179.20675501  151.86717758 197.64279852  84.30187965 201.50000094  92.92382878  108.05315903 137.05696185 182.37076863 136.21049311 155.56310123   98.99174929 132.35640936  95.05326284 155.95524466 129.92134192  115.17532067 211.30425492 202.94673641 139.72699584 163.73270376  178.32978006 102.9526864  198.70259669 111.69518298 202.22368578  140.46518594 208.80233486 238.65552407 122.58886831 126.21856224  184.20163827]<\/code><\/pre>\n<p><strong>SVR<\/strong>  <\/p>\n<pre><code class=\"python\">svr = SVM(regression=True) svr.fit(X2_train, y2_train) svr_pred_res = svr.predict(X2_test) svc_r2 = r2_score(y2_test, svr_pred_res)  print(f'SVR r2 score: {svc_r2:}') print(svr_pred_res)   SVR r2 score: 0.13842687260455933 [156.05494339 160.2561796  141.5352585  126.32530705 138.56287083  157.79461531 118.30051225 153.1126463  133.32684359 151.34517091  138.31021981 150.93156042 127.62035887 125.65861919 159.80948036  119.27243753 132.8868118  115.3503535  130.26443966 154.69113982  140.44764244 131.1864082  140.91091129 132.34658014 147.43835547  141.71095095 135.93497953 120.372006   141.90918325 145.01581208  147.05308508 115.34872572 128.98260578 139.39763958 141.37219221  149.93533907 144.21593809 147.00705167 128.79733929 154.94745068  122.27967665 145.73099063 138.72486465 142.87524309 149.4272714  119.3023132  129.77336124 128.95425751 135.62538778 154.4679459  137.44976849 114.591969   136.28102471 144.85720422 155.6502593  145.13807371 149.33504099 124.03772077 141.352508   147.84699051  148.25434815 133.39538615 143.03923607 131.48119845 154.73175072  132.94449565 118.51262122 149.10562494 147.22897373 130.57831287  116.89776562 139.90942034 125.511231   129.63878496 128.60606786  148.44879908 136.55938776 152.91463602 158.19071606 143.85231346  138.42641367 157.68211977 114.52184616 158.09339445 124.94398434  119.09508611 129.13111767 147.82792349 130.8519467  140.09356889  128.19793708 128.37423877 120.27278606 141.48530479 126.975866  118.21921492 156.0928224  150.71999387 132.67319998 142.29171129  149.6172972  127.40342245 152.28664393 129.07127394 158.18758274  139.54904295 151.99820233 154.43678117 124.87211774 126.92101192  152.02873799]<\/code><\/pre>\n<p><strong>SVR (scikit-learn)<\/strong>  <\/p>\n<pre><code class=\"python\">sk_svr = SVR() sk_svr.fit(X2_train, y2_train) sk_svr_pred_res = sk_svr.predict(X2_test) sk_svr_r2 = r2_score(y2_test, sk_svr_pred_res)  print(f'sk SVR r2 score: {sk_svr_r2:}') print(sk_svr_pred_res)   sk SVR r2 score: 0.13842687260455933 [156.05494339 160.2561796  141.5352585  126.32530705 138.56287083  157.79461531 118.30051225 153.1126463  133.32684359 151.34517091  138.31021981 150.93156042 127.62035887 125.65861919 159.80948036  119.27243753 132.8868118  115.3503535  130.26443966 154.69113982  140.44764244 131.1864082  140.91091129 132.34658014 147.43835547  141.71095095 135.93497953 120.372006   141.90918325 145.01581208  147.05308508 115.34872572 128.98260578 139.39763958 141.37219221  149.93533907 144.21593809 147.00705167 128.79733929 154.94745068  122.27967665 145.73099063 138.72486465 142.87524309 149.4272714  119.3023132  129.77336124 128.95425751 135.62538778 154.4679459  137.44976849 114.591969   136.28102471 144.85720422 155.6502593  145.13807371 149.33504099 124.03772077 141.352508   147.84699051  148.25434815 133.39538615 143.03923607 131.48119845 154.73175072  132.94449565 118.51262122 149.10562494 147.22897373 130.57831287  116.89776562 139.90942034 125.511231   129.63878496 128.60606786  148.44879908 136.55938776 152.91463602 158.19071606 143.85231346  138.42641367 157.68211977 114.52184616 158.09339445 124.94398434  119.09508611 129.13111767 147.82792349 130.8519467  140.09356889  128.19793708 128.37423877 120.27278606 141.48530479 126.975866  118.21921492 156.0928224  150.71999387 132.67319998 142.29171129  149.6172972  127.40342245 152.28664393 129.07127394 158.18758274  139.54904295 151.99820233 154.43678117 124.87211774 126.92101192  152.02873799]<\/code><\/pre>\n<h4>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u043f\u043e\u0440\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432<\/h4>\n<p><em><u>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/u><\/em>:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043a \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044e \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0435\u0437 \u0438\u0445 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ul>\n<p><em><u>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/u><\/em>:<\/p>\n<ul>\n<li>\n<p>\u043d\u0438\u0437\u043a\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0437-\u0437\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a \u0448\u0443\u043c\u0443 \u0438\u043b\u0438 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438<\/h4>\n<p>\u0421\u0442\u0430\u0442\u044c\u0438:<\/p>\n<ul>\n<li>\n<p>\u00abStatistical performance of Support Vector Machines\u00bb, Gilles Blanchard, Olivier Bousquet and Pascal Massart;<\/p>\n<\/li>\n<li>\n<p>\u00abA review of optimization methodologies in Support Vector Machines\u00bb, John Shawe-Taylor, Shiliang Sun;<\/p>\n<\/li>\n<li>\n<p>\u00abOn the Algorithmic Implementation of Multiclass Kernel-based Vector Machines\u00bb, Koby Crammer, Yoram Singer;<\/p>\n<\/li>\n<li>\n<p>\u00abLIBLINEAR: A library for large linear classification\u00bb, Rong-En Fan, Kai-Wei Chang, Cho-Jui Hsieh, Xiang-Rui Wang, Chih-Jen Lin;<\/p>\n<\/li>\n<li>\n<p>\u00abLIBSVM: A Library for Support Vector Machines\u00bb, Chih-Chung Chang and Chih-Jen Lin.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/svm.html#\" rel=\"noopener noreferrer nofollow\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 SVM<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.svm.LinearSVC.html\" rel=\"noopener noreferrer nofollow\">LinearSVC<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.svm.LinearSVR.html\" rel=\"noopener noreferrer nofollow\">LinearSVR<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.svm.SVC.html\" rel=\"noopener noreferrer nofollow\">SVC<\/a>;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.svm.SVR.html\" rel=\"noopener noreferrer nofollow\">SVR<\/a>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0438\u0434\u0435\u043e: <a href=\"https:\/\/www.youtube.com\/watch?v=_PwhiWxHK8o\" rel=\"noopener noreferrer nofollow\">\u043e\u0434\u0438\u043d<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=V7mUNS3qXVY\" rel=\"noopener noreferrer nofollow\">\u0434\u0432\u0430<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=0OLR3If-qS0\" rel=\"noopener noreferrer nofollow\">\u0442\u0440\u0438<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=jMWjN6mJiSw\" rel=\"noopener noreferrer nofollow\">\u0447\u0435\u0442\u044b\u0440\u0435<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=EESZtSOdhEQ\" rel=\"noopener noreferrer nofollow\">\u043f\u044f\u0442\u044c<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=FrsIHCr4TZE\" rel=\"noopener noreferrer nofollow\">\u0448\u0435\u0441\u0442\u044c<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=efR1C6CvhmE\" rel=\"noopener noreferrer nofollow\">\u0441\u0435\u043c\u044c<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=Toet3EiSFcM\" rel=\"noopener noreferrer nofollow\">\u0432\u043e\u0441\u0435\u043c\u044c<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=Qc5IyLW_hns\" rel=\"noopener noreferrer nofollow\">\u0434\u0435\u0432\u044f\u0442\u044c<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=8xbnLHn4jjQ\" rel=\"noopener noreferrer nofollow\">\u0434\u0435\u0441\u044f\u0442\u044c<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=rB-iRIpAPKo\" rel=\"noopener noreferrer nofollow\">\u043e\u0434\u0438\u043d\u043d\u0430\u0434\u0446\u0430\u0442\u044c<\/a>.<\/p>\n<hr\/>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/802435\/\" rel=\"noopener noreferrer nofollow\"><strong>? \u041d\u0430\u0438\u0432\u043d\u044b\u0439 \u0411\u0430\u0439\u0435\u0441  |<\/strong><\/a>  <a href=\"https:\/\/habr.com\/ru\/articles\/801885\/\" rel=\"noopener noreferrer nofollow\"><strong>\u041c\u0435\u0442\u043e\u0434 K-\u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (KNN) ?<\/strong><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/802185\/\"> https:\/\/habr.com\/ru\/articles\/802185\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"float full-width\"><\/figure>\n<p>\u041c\u0435\u0442\u043e\u0434 \u043e\u043f\u043e\u0440\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 (Support Vector Machines \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e SVM) \u2014 \u043c\u043e\u0449\u043d\u044b\u0439 \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043b\u044e\u0431\u043e\u0439 \u0444\u043e\u0440\u043c\u044b, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u043d\u043e \u0438 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e SVM, \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043d\u0443\u043b\u044f \u0435\u0433\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0435\u0439.  <\/p>\n<blockquote>\n<p><em>\u041d\u043e\u0443\u0442\u0431\u0443\u043a \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0430\u00a0<\/em><a href=\"https:\/\/www.kaggle.com\/code\/egazakharenko\/support-vector-machines-svm-from-scratch\" rel=\"noopener noreferrer nofollow\"><strong><em>Kaggle<\/em><\/strong><\/a><em>\u00a0(eng) \u0438\u00a0<\/em><a href=\"https:\/\/github.com\/egaoharu-kensei\/ML-algorithms-from-scratch.-Course-for-beginners\/blob\/main\/Notebooks%20%5Brus%5D\/ML-%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC%D1%8B%20%D1%81%20%D0%BD%D1%83%D0%BB%D1%8F\/05%29%20%D0%9C%D0%B5%D1%82%D0%BE%D0%B4%20%D0%BE%D0%BF%D0%BE%D1%80%D0%BD%D1%8B%D1%85%20%D0%B2%D0%B5%D0%BA%D1%82%D0%BE%D1%80%D0%BE%D0%B2%20%28SVM%29.ipynb\" rel=\"noopener noreferrer nofollow\"><strong><em>GitHub<\/em><\/strong><\/a><em>\u00a0(rus).<\/em>  <\/p>\n<\/blockquote>\n<h4>\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 SVM<\/h4>\n<p><strong>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/strong>\u00a0\u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f SVM \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 \u0438\u043b\u0438 \u043b\u0438\u043d\u0438\u0438, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0431\u043b\u0438\u0436\u0435 \u0432\u0441\u0435\u0433\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 \u043e\u0431\u0440\u0430\u0437\u0446\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f\u00a0<em>\u043e\u043f\u043e\u0440\u043d\u044b\u043c\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438<\/em>. \u041b\u0443\u0447\u0448\u0438\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u043f\u043e\u0440\u043d\u044b\u043c\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0439 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c\u044e. \u042d\u0442\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00a0<em>\u0437\u0430\u0437\u043e\u0440\u043e\u043c<\/em>. \u0417\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430:<\/p>\n<ul>\n<li>\n<p>1)\u00a0<strong>\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0441 \u0436\u0451\u0441\u0442\u043a\u0438\u043c \u0437\u0430\u0437\u043e\u0440\u043e\u043c (hard margin)<\/strong>, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0446\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u043f\u043e\u043b\u043e\u0441\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043a \u0432\u044b\u0431\u0440\u043e\u0441\u0430\u043c.<\/p>\n<\/li>\n<li>\n<p>2)\u00a0<strong>\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0441 \u043c\u044f\u0433\u043a\u0438\u043c \u0437\u0430\u0437\u043e\u0440\u043e\u043c (soft margin)<\/strong>, \u043a\u043e\u0433\u0434\u0430 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u0446\u044b \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u0432 \u043f\u043e\u043b\u043e\u0441\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0448\u0442\u0440\u0430\u0444 \u0437\u0430 \u0442\u0430\u043a\u0438\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 C (\u0447\u0435\u043c \u043d\u0438\u0436\u0435 \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u0435\u043c \u0448\u0438\u0440\u0435 \u043f\u043e\u043b\u043e\u0441\u0430 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0439 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0437\u0430\u0437\u043e\u0440). \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043e\u0431\u0449\u0430\u044e\u0449\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0440\u0438\u0441\u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u0432\u0435\u0441\u043e\u0432 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 OVR (One-Versus-Rest) \u0438\u043b\u0438 OVA (One-Versus-All), \u0430 \u0434\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c hinge.<\/p>\n<blockquote>\n<p><em>\u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 scikit-learn \u043a \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0435\u0449\u0451 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f l1 \u0438\u043b\u0438 l2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0432\u044b\u0431\u043e\u0440, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 loss=&#8217;squared_hinge&#8217;.<\/em><\/p>\n<\/blockquote>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0436\u0451\u0441\u0442\u043a\u0438\u043c \u0438 \u043c\u044f\u0433\u043a\u0438\u043c \u0437\u0430\u0437\u043e\u0440\u043e\u043c \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0432\u044b\u043f\u0443\u043a\u043b\u043e\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0437\u0430\u0434\u0430\u0447\u0430\u043c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Liblinear, \u043d\u043e \u0432 \u0440\u0443\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0438\u0436\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0441\u043f\u0443\u0441\u043a \u0441 \u043e\u0434\u043d\u0438\u043c \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435\u043c: \u0432\u0435\u0441\u0430 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0432\u0441\u0435\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0442\u0441\u0442\u0443\u043f\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 1, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0448\u0435. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u0443\u044e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c hinge loss \u0431\u0435\u0437 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 squared hinge loss \u0441 l2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0432 scikit-learn, \u0430 \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0442\u043e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0432 \u0446\u0435\u043b\u043e\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u043d\u0435\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e.<\/p>\n<figure class=\"full-width\">\n<div><figcaption><strong>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e SVM \u0441 \u0436\u0451\u0441\u0442\u043a\u0438\u043c \u0438 \u043c\u044f\u0433\u043a\u0438\u043c \u0437\u0430\u0437\u043e\u0440\u043e\u043c<\/strong><\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/strong>\u00a0SVM \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0437\u043e\u0440\u043e\u043c \u0438 \u043e\u0431\u0440\u0430\u0437\u0446\u0430\u043c\u0438, \u0447\u0442\u043e \u043b\u0435\u0436\u0430\u0442 \u0437\u0430 \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438, \u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u044c \u0437\u0430\u0437\u043e\u0440\u0430 \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043b\u0438\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u0437\u043e\u0440, \u0448\u0438\u0440\u0438\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c epsilon, \u0430 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f epsilon-insensitive.  <\/p>\n<figure class=\"\">\n<div><figcaption><strong>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e SVM \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/strong><\/figcaption><\/div>\n<\/figure>\n<blockquote>\n<p><em>\u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439, \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 scikit-learn \u0434\u043b\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 SVM \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f l1 \u0438\u043b\u0438 l2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0432\u044b\u0431\u043e\u0440, \u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439.<\/em><\/p>\n<\/blockquote>\n<h4>\u041d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 SVM<\/h4>\n<p><strong>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/strong>\u00a0\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438, \u0433\u0434\u0435 \u043e\u043d\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c\u044b\u043c\u0438. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u00a0<em>\u044f\u0434\u0435\u0440\u043d\u043e\u0433\u043e \u0442\u0440\u044e\u043a\u0430<\/em>\u00a0\u2014 \u044d\u0442\u043e \u043f\u0440\u0438\u0451\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 n-\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 n, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0431\u0435\u0437 \u0438\u0445 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f:<\/p>\n<p>\u0433\u0434\u0435  \u2014 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u0438 .<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u044f\u0434\u0435\u0440\u043d\u043e\u0433\u043e \u0442\u0440\u044e\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043er\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u0442\u0440\u044e\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u043e \u043c\u0435\u0436\u0434\u0443 \u043f\u0430\u0440\u0430\u043c\u0438 \u0442\u043e\u0447\u0435\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u044f\u0434\u0440\u043e\u043c. \u0412 scikit-learn \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u044f\u0434\u0440\u0430: <\/p>\n<ul>\n<li>\n<p>\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u0447\u0442\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443:<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u2014 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e \u0443\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c \u0432 \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0442\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432  :<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u043e\u0435 RBF (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Radial_basis_function\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0434\u0438\u0430\u043b\u044c\u043d\u043e-\u0431\u0430\u0437\u0438\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/a>) \u2014 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u0438 \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043d\u043e \u0438 \u0438\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0441\u0438\u0433\u043c\u043e\u0438\u0434\u0430\u043b\u044c\u043d\u043e\u0435 \u2014 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0433\u0438\u043f\u0435\u0440\u0431\u043e\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0430\u043d\u0433\u0435\u043d\u0441 \u043a \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0432\u0443\u0445\u0441\u043b\u043e\u0439\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0441 \u0441\u0438\u0433\u043c\u043e\u0438\u0434\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438 \u0441\u043b\u0443\u0447\u0430\u044f\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0448\u0443\u043c\u0430 \u0438 \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432:<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435  \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u043c\u0438 \u043e\u0431\u0440\u0430\u0437\u0446\u0430\u043c\u0438: \u0447\u0435\u043c \u043d\u0438\u0436\u0435 \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0434\u0438\u0443\u0441 \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432 \u043d\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0451 \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0430\u0434\u043a\u043e\u0439. \u041c\u0435\u0436\u0434\u0443 \u0442\u0435\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0441\u0434\u0432\u0438\u0433\u0430  (coef0 \u0432 scikit-learn) \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u044f\u0434\u0440\u0430, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u0442\u0440\u044e\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 SVM, \u043d\u043e \u0438 \u043a \u0434\u0440\u0443\u0433\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u0442\u0440\u044e\u043a \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0441 SVM.  <\/p>\n<p><strong>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438<\/strong>\u00a0SVM \u0442\u0430\u043a\u0436\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c\u044b\u043c\u0438 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0437\u043e\u0440\u043e\u043c \u0438 \u043e\u0431\u0440\u0430\u0437\u0446\u0430\u043c\u0438 \u043a\u0430\u043a \u0438 \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<blockquote>\n<p><em>\u0412 scikit-learn \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438 \u0441\u043b\u0443\u0447\u0430\u044f\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u044b SVR \u0438 SVC \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Libsvm, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u044f\u0434\u0435\u0440\u043d\u043e\u0433\u043e \u0442\u0440\u044e\u043a\u0430 \u0438 l2-\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c C.<\/em><\/p>\n<\/blockquote>\n<h4>\u0418\u043c\u043f\u043e\u0440\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/h4>\n<pre><code class=\"python\">import numpy as np import pandas as pd import matplotlib.pyplot as plt from mlxtend.plotting import plot_decision_regions from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score, r2_score from sklearn.utils import check_random_state, check_array from sklearn.svm import LinearSVC, LinearSVR, SVC, SVR, _libsvm from sklearn.datasets import load_iris, load_diabetes, load_wine, load_breast_cancer<\/code><\/pre>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u043d\u0443\u043b\u044f<\/h4>\n<p><strong>Linear SVM<\/strong>  <\/p>\n<pre><code class=\"python\">class LinearSVM:     def __init__(self, regression=False, C=1.0, eps=0, learning_rate=0.001, max_iter=1000,                  random_state=0):         self.regression = regression         self.C = C         self.eps = eps         self.learning_rate = learning_rate         self.max_iter = max_iter         self.random_state = random_state      def fit(self, X, y):         if self.regression:             self.bias, self.weights = self._find_weights(X, y)         else:             classes = np.unique(y)             n_classes = len(classes)             _, n_features = X.shape              self.bias = np.zeros(n_classes)             self.weights = np.zeros((n_classes, n_features))             np.random.seed(self.random_state)              for i, cls in enumerate(classes):                 y_binary = np.where(y == cls, 1, -1)                 self.bias[i], self.weights[i] = self._find_weights(X, y_binary)      def _find_weights(self, X, y):         n_samples, n_features = X.shape         bias = 0         weights = np.zeros(n_features) if self.regression else np.random.randn(n_features)          for _ in range(self.max_iter):             for i in range(n_samples):                 y_pred = X[i] @ weights + bias                 margin = y[i] - y_pred if self.regression else y[i] * y_pred                 condition = np.abs(margin) > self.eps if self.regression else margin &lt; 1                  if condition:                     if self.regression:                         db = -self.C * (margin - self.eps)                         dw = -self.C * (margin - self.eps) * X[i]                     else:                         db = -self.C * y[i]                         dw = -self.C * y[i] * X[i]                      bias -= self.learning_rate * db                     weights -= self.learning_rate * dw          return bias, weights      def predict(self, X):         scores = X @ self.weights.T + self.bias          return scores if self.regression else np.argmax(scores, axis=1)<\/code><\/pre>\n<p><strong>Kernel SVM \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Libsvm<\/strong><\/p>\n<pre><code class=\"python\">class SVM:     def __init__(self, regression=False, C=1.0, kernel='rbf', degree=3, solver='auto',                  gamma='scale', epsilon=0.1, coef0=0.0, shrinking=True, probability=False,                  tol=0.001, cache_size=200, max_iter=-1, random_state=None):         self.regression = regression         self.C = C         self.kernel = kernel         self.degree = degree         self.solver = solver         self.gamma = gamma         self.epsilon = epsilon         self.coef0 = coef0         self.shrinking = shrinking         self.probability = probability         self.tol = tol         self.cache_size = cache_size         self.max_iter = max_iter         self.random_state = random_state      def fit(self, X, y):         X = X.astype(np.float64)         y =<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-371537","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/371537","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=371537"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/371537\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=371537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=371537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=371537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}