{"id":323376,"date":"2021-05-19T09:01:43","date_gmt":"2021-05-19T09:01:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=323376"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=323376","title":{"rendered":"Python, \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f \u0438 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f: \u0447\u0430\u0441\u0442\u044c 3"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u043e\u0441\u0442 \u0441\u043c. <a href=\"https:\/\/habr.com\/ru\/post\/558084\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u044b \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f. <\/p>\n<h2>\u041c\u0430\u0442\u0440\u0438\u0446\u044b<\/h2>\n<p>\u041c\u0430\u0442\u0440\u0438\u0446\u0430, \u2014 \u044d\u0442\u043e \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b. \u0420\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u043c \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>A&nbsp;<\/em>\u2014 \u044d\u0442\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441 \u0447\u0435\u0442\u044b\u0440\u044c\u043c\u044f \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0438 \u0434\u0432\u0443\u043c\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1f4\/633\/9d5\/1f46339d5654e2073f7c17a57f03a06e.png\" width=\"136\" height=\"74\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u043f\u0438\u0441\u043d\u043e\u0439 \u0431\u0443\u043a\u0432\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u0432 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u0435\u0435 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445.<\/p>\n<p>\u041c\u0430\u0441\u0441\u0438\u0432 numpy \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pandas <code>df.values<\/code>:<\/p>\n<pre><code class=\"python\">def ex_3_16():     '''\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 (\u043c\u0430\u0442\u0440\u0438\u0446\u0443) numpy         \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0441\u0442\u0430 \u0438 \u0432\u0435\u0441\u0430'''     df = swimmer_data()[['\u0420\u043e\u0441\u0442, \u0441\u043c', '\u0412\u0435\u0441']]     return df.values<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<pre><code>array([[166.,  68.],        [192.,  89.],        [173.,  65.],        ...,        [188.,  79.],        [187.,  78.],        [183.,  70.]])<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy <code>np.array<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d \u043b\u0438\u0431\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0438, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 (\u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>numpy.ndarray<\/code>):<\/p>\n<pre><code class=\"python\">def ex_3_17():     '''\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 (\u043c\u0430\u0442\u0440\u0438\u0446\u0443) numpy         \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u0440\u043e\u0441\u0442\u0435'''     return swimmer_data()['\u0420\u043e\u0441\u0442, \u0441\u043c'].head(20).values # \u043f\u0435\u0440\u0432\u044b\u0435 20<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<pre><code>array([166., 192., 173., 179., 201., 190., 175., 160., 202., 173., 175.,        205., 185., 175., 185., 170., 165., 179., 165., 170.])<\/code><\/pre>\n<p>\u041c\u0430\u0442\u0440\u0438\u0446\u044b \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0440\u0430\u0441\u0442\u0430\u0442\u044c \u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e\u043a\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 pandas head \u0438 <code>tail<\/code> \u043b\u0438\u0431\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy (<code>result_array[:5]<\/code>); \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p><sup>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 pandas \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0432\u044b\u0433\u043e\u0434\u0443 \u043e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a log, exp, sqrt \u0438 \u0434\u0440., \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445\/\u043c\u0430\u0442\u0440\u0438\u0446\u0430\u0445. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 numpy \u043c\u043e\u0433\u0443\u0442 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043a\u0430\u0434\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 DataFrame (\u0438 \u0440\u044f\u0434\u0430\u043c\u0438 Series) \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pandas \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, np.exp(df), np.asarray(df), df.T.dot(df)).<\/sup><\/p>\n<h2>\u0420\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>\u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 <em>i<\/em>-\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 <em>j<\/em>-\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <em>A<\/em><sub>ij<\/sub>. \u0418 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"A_{31}=2\" alt=\"A_{31}=2\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/61b\/8e7\/80b\/61b8e780b37537c8ebc8ab9a37525103.svg\" width=\"55\" height=\"17\"><\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pandas \u0438 numpy \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>shape<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0440\u0442\u0435\u0436 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430: \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a, \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<h2>\u0412\u0435\u043a\u0442\u043e\u0440\u044b<\/h2>\n<p>\u0412\u0435\u043a\u0442\u043e\u0440\u044b \u2014 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0441\u0442\u043e\u043b\u0431\u0435\u0446. \u0427\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/165\/452\/334\/1654523344cd2ee0fdd75e00a673b2c0.png\" width=\"81\" height=\"73\"><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c <em>y&nbsp;<\/em>\u2014 \u044d\u0442\u043e 4-\u043c\u0435\u0440\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440; \u0435\u0433\u043e <em>i<\/em>-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <em>y<\/em><sub>i<\/sub>. \u0412\u0435\u043a\u0442\u043e\u0440\u044b \u0432 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0438\u043d\u043e\u0435.<\/p>\n<p>\u0422\u0430\u043a,    <em>&nbsp;<\/em>\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043d\u0435 \u0432\u0442\u043e\u0440\u043e\u0439. \u0412 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u0447\u043d\u044b\u043c\u0438 \u0431\u0443\u043a\u0432\u0430\u043c\u0438. <\/p>\n<p><sup>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pandas (\u0433\u0434\u0435 Series \u0438 DataFrame \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0438 \u043c\u0430\u0442\u0440\u0438\u0446) \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u043e\u0434\u043d\u043e\u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432\u044b\u043c\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e np.array \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/sup><\/p>\n<h2>\u0421\u0431\u043e\u0440\u043a\u0430<\/h2>\n<p>\u041a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 Python \u0438 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 pandas. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445, \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439, \u043d\u0430\u0434\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0431\u043e\u043a \u043e \u0431\u043e\u043a \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u0438. \u0412 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0435\u0434\u0438\u043d\u0438\u0446 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0438\u043b\u0438 \u043a\u043e\u043d\u0435\u0446 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">'''\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043c\u0430\u0441\u0441\u0438\u0432)''' df = pd.DataFrame({'x':[2, 3, 6, 7],'y':[8, 7, 4, 3]}) df['\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430'] = 1 df<\/code><\/pre>\n<pre><code>\tx\ty\t\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 0\t2\t8\t1 1\t3\t7\t1 2\t6\t4\t1 3\t7\t3\t1<\/code><\/pre>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u0447\u043b\u0435\u043d\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e <em>\u03b2<\/em><sub>1<\/sub><em>&nbsp;<\/em>\u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <em>x<\/em><sub>1<\/sub><em>&nbsp;<\/em>\u0442\u043e\u0436\u0435 \u0431\u044b\u043b \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043e\u0439. \u0411\u0435\u0437 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>y&nbsp;<\/em>\u0440\u0430\u0432\u043d\u044f\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0443\u043b\u044e, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>x<\/em> \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e.<\/p>\n<h2>\u0421\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421\u043a\u0430\u043b\u044f\u0440 \u2014 \u044d\u0442\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043a\u0430\u043b\u044f\u0440 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u043c\u044b \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<p>\u041c\u0430\u0442\u0440\u0438\u0447\u043d\u043e-\u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0443\u0442\u0435\u043c \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438. \u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u0415\u0441\u043b\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u043e \u043d\u0438\u0445 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0435.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/da7\/233\/fb5\/da7233fb53a952a3f48f21404a917e95.png\" width=\"214\" height=\"64\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df1 = pd.DataFrame([[1,0],[2,5],[3,1]]) df2 = pd.DataFrame([[4,0.5],[2,5],[0,1]]) df1 + df2<\/code><\/pre>\n<pre><code> \t0\t   1 0\t5\t 0.5 1\t4\t10.0 2\t3\t 2.0<\/code><\/pre>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0441\u043a\u0430\u043b\u044f\u0440\u043e\u0432 \u0438 \u043c\u0430\u0442\u0440\u0438\u0446, \u0432 pandas \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043a\u0430\u043b\u044f\u0440\u044b \u043b\u0438\u0431\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 \u043d\u0430 \u0441\u043a\u0430\u043b\u044f\u0440 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u0430\u0435\u0442 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u043c\u043d\u043e\u0436\u0435\u043d \u043d\u0430 \u0441\u043a\u0430\u043b\u044f\u0440.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ed9\/040\/548\/ed9040548dd3265843abf5effad932f8.png\" width=\"163\" height=\"60\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df1 * 3<\/code><\/pre>\n<pre><code>\t0\t 1 0\t3\t 0 1\t6\t15 2\t9\t 3<\/code><\/pre>\n<h2>\u041c\u0430\u0442\u0440\u0438\u0447\u043d\u043e-\u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>dot<\/code> \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0440\u0430\u0437\u043c\u0435\u0440\u0430 3 \u00d7 2&nbsp;\u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 2 \u00d7 1&nbsp;\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 3 \u00d7 1, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0441\u043b\u0435\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0447\u0438\u0441\u043b\u043e\u043c \u0441\u0442\u0440\u043e\u043a \u0441\u043f\u0440\u0430\u0432\u0430:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/182\/028\/cfb\/182028cfb842dc05217d7942ff9d996b.png\" width=\"297\" height=\"191\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f <em>Ax<\/em>&nbsp;\u043d\u0430\u0434\u043e \u043f\u043e\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 <em>A&nbsp;<\/em>\u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u044b <em>x<\/em>&nbsp;\u0438 \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <em>A<\/em>&nbsp;\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b 1 \u0438 3. \u041e\u043d\u0438 \u043f\u043e\u043f\u0430\u0440\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 <em>x<\/em>: 1 \u0438 5. \u0417\u0430\u0442\u0435\u043c, \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 16. \u042d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u0442\u043e\u0447\u0435\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c<\/em>, \u0438\u043b\u0438 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c, \u0434\u043b\u044f \u0447\u0435\u0433\u043e, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df3 = pd.DataFrame([[1,3],[0,4],[2,1]]) vec = [1,5] df3.dot(vec)<\/code><\/pre>\n<pre><code>0    16 1    20 2     7 dtype: int64<\/code><\/pre>\n<h2>\u041c\u0430\u0442\u0440\u0438\u0447\u043d\u043e-\u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e-\u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e-\u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435. \u0418\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0430\u0442\u0440\u0438\u0446 <em>A<\/em>&nbsp;\u0438 <em>B<\/em>&nbsp;\u043f\u043e\u043f\u0430\u0440\u043d\u043e, \u0441\u0442\u0440\u043e\u043a\u0430 \u0437\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0438 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0437\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u043c, \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0441\u0443\u043c\u043c\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0439.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/676\/8bf\/a7b\/6768bfa7bcc530ad6cb59cbf9973e22c.png\" width=\"462\" height=\"191\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0438 \u0440\u0430\u043d\u0435\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043c\u043d\u043e\u0436\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0440\u0430\u0432\u043d\u043e \u0447\u0438\u0441\u043b\u0443 \u0441\u0442\u0440\u043e\u043a \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 <em>A <\/em>\u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c <em>m<sub>A<\/sub><\/em> \u00d7 <em>n<sub>A<\/sub><\/em>, \u0430 \u0432\u0442\u043e\u0440\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 <em>B<\/em>&nbsp;\u2014 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c <em>m<sub>B<\/sub><\/em> \u00d7 <em>n<sub>B<\/sub><\/em>, \u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0438\u0442\u044c, <em>n<sub>A<\/sub><\/em>&nbsp;\u0438 <em>m<sub>B<\/sub><\/em>&nbsp;\u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u043c\u0438.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fad\/12e\/39d\/fad12e39d0294c20049b341ab76475bd.png\" width=\"224\" height=\"235\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/218\/39a\/7ce\/21839a7cec6a80d6a7afbfce99dd043a.png\" width=\"173\" height=\"68\"><figcaption><\/figcaption><\/figure>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443. \u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 pandas \u0438 numpy \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u0443\u044e \u0430\u043b\u0433\u0435\u0431\u0440\u0443 \u0437\u0430 \u043d\u0430\u0441.<\/p>\n<pre><code class=\"python\">df3 = pd.DataFrame([[1,3],[0,4],[2,1]]) df4 = pd.DataFrame([[1,0],[5,6]])      df3.dot(df4)<\/code><\/pre>\n<pre><code>\t0    1 0\t16\t18 1\t20\t24 2\t 7\t 6<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 numpy:<\/p>\n<pre><code class=\"python\">np.matmul(df3,np.asarray(df4))<\/code><\/pre>\n<h2>\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043f\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0438\u0437 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u043b\u0435\u0432\u043e\u0433\u043e \u0443\u0433\u043b\u0430 \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u044b\u0439 \u0443\u0433\u043e\u043b. \u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <em>A&nbsp;<\/em>\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <em>A<sup>T<\/sup><\/em>:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4db\/b2b\/c03\/4dbb2bc032d8c06731971b2122a7cbf2.png\" width=\"124\" height=\"46\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0442\u043e\u043b\u0431\u0446\u044b \u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/07c\/450\/ce5\/07c450ce5c3c01aaf276ffc0b7e7ae73.png\" width=\"74\" height=\"35\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b3b\/494\/a51\/b3b494a51aa835b35bcac68f46395747.png\" width=\"70\" height=\"36\"><figcaption><\/figcaption><\/figure>\n<p>\u0442\u043e:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8f5\/2ef\/a36\/8f52efa36813c36e8253a8ac78399e4d.png\" width=\"62\" height=\"38\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df3.T<\/code><\/pre>\n<pre><code>\t0\t1\t2 0\t1\t0\t2 1\t3\t4\t1<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0441 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438 \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0441\u043c. \u0432 \u043c\u043e\u0435\u043c <a href=\"https:\/\/github.com\/capissimo\/python-for-data-science\/blob\/master\/ch03_Correlation.ipynb\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e<\/a> \u043d\u0430 Gitgub \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u043f\u043e\u0441\u0442\u043e\u0432.<\/p>\n<h2>\u041d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430<\/h2>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0441\u043e\u0431\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u0435. \u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u0442\u0440\u0438\u0446 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430, \u0438\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430. \u042d\u0442\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u043c\u0438 \u0432\u0434\u043e\u043b\u044c \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438 \u0438 \u043d\u0443\u043b\u044f\u043c\u0438 \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u0445:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ce7\/fc8\/608\/ce7fc86087edbfeeba2214302f7d43c1.png\" width=\"89\" height=\"78\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0434\u0438\u043d\u0438\u0447\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u2014 \u044d\u0442\u043e \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 (\u0438\u043b\u0438 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f). \u041a\u0430\u043a \u0438 \u043f\u0440\u0438 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e 1, \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 numpy <code>np.identity<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u0442 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0435, \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0448\u0438\u0440\u0438\u043d\u0443 \u0438 \u0432\u044b\u0441\u043e\u0442\u0443 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df = pd.DataFrame(np.identity(5)) df<\/code><\/pre>\n<pre><code>\t  0\t  1\t  2\t  3\t  4 0\t1.0\t0.0\t0.0\t0.0\t0.0 1\t0.0\t1.0\t0.0\t0.0\t0.0 2\t0.0\t0.0\t1.0\t0.0\t0.0 3\t0.0\t0.0\t0.0\t1.0\t0.0 4\t0.0\t0.0\t0.0\t0.0\t1.0<\/code><\/pre>\n<h2>\u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <em>A<\/em>, \u0442\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0434\u043b\u044f <em>A<\/em>&nbsp;\u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <em>A<sup>&#8212;<\/sup><\/em><sup>1<\/sup>, \u0438 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0433\u0434\u0435 <em>I<\/em>&nbsp;\u2014 \u044d\u0442\u043e \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/447\/1e2\/17a\/4471e217ae24480835635d7c954691c0.png\" width=\"172\" height=\"32\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u0441\u0435\u0431\u0435. \u041d\u0435 \u0432\u0441\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u044b. \u041d\u0435\u043e\u0431\u0440\u0430\u0442\u0438\u043c\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <em>\u0441\u0438\u043d\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 <\/em>\u0438\u043b\u0438 <em>\u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u043c\u0438<\/em>. \u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>np.linalg.pinv<\/code> \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy.<\/p>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df5 = pd.DataFrame(np.random.rand(3, 3), list('abc'), list('xyz')) print(df5) df_inv = pd.DataFrame(np.linalg.pinv(df5.values), df5.columns, df5.index) print(df_inv)<\/code><\/pre>\n<pre><code>          x         y         z a  0.625754  0.385261  0.462726 b  0.615084  0.111360  0.255420 c  0.723909  0.270869  0.221620           a         b         c x -1.451613  1.303231  1.528861 y  1.584699 -6.402303  4.070011 z  2.804750  3.568103 -5.456161<\/code><\/pre>\n<h2>\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043e\u0441\u043d\u043e\u0432\u044b \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432 \u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e <em>\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/em>. \u042d\u0442\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u0430\u044f \u0430\u043b\u0433\u0435\u0431\u0440\u0430:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/58e\/c38\/b32\/58ec38b320e935fab3de9eff43889a4c.png\" width=\"130\" height=\"37\"><figcaption><\/figcaption><\/figure>\n<p>\u041c\u044b \u0447\u0438\u0442\u0430\u0435\u043c \u00ab\u0434\u043b\u044f \u043e\u0442\u044b\u0441\u043a\u0430\u043d\u0438\u044f <em>\u03b2<\/em>&nbsp;\u043d\u0430\u0434\u043e \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 <em>X&nbsp;<\/em>\u0438 <em>X<\/em>, \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 <em>X<\/em>&nbsp;\u0438 <em>y<\/em>\u00bb, \u0433\u0434\u0435 <em>X&nbsp;<\/em>\u2014 \u044d\u0442\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0447\u043b\u0435\u043d \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f) \u0438 <em>y&nbsp;<\/em>\u2014 \u0432\u0435\u043a\u0442\u043e\u0440, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u0448\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <em>\u03b2&nbsp;<\/em>\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b. \u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0437 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u043a\u043b\u0430\u0434\u043a\u0438 \u043b\u0435\u0436\u0430\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u043e\u0431\u044a\u0435\u043c\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430.<\/p>\n<p>\u0423\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 Python, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c:<\/p>\n<pre><code class=\"python\">def normal_equation(x, y):     '''\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f'''     # numpy.linalg.inv(A) \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 numpy.linalg.solve(A,I),      # \u0433\u0434\u0435 I - \u044d\u0442\u043e \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430, \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c      # LU \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 lapack     xtx  = np.matmul(x.T.values, x.values)      # \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0438\u043a\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u044b     xtxi = np.matmul(np.linalg.inv(np.matmul(xtx.T,xtx)),xtx.T)     xty  = np.matmul(x.T.values, y.values)      return np.matmul(xtxi, xty)  <\/code><\/pre>\n<p>\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0443 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0432 \u043e\u0447\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u043e\u0439 \u0444\u043e\u0440\u043c\u0435. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u043f\u043e\u043c\u043d\u044f \u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f):<\/p>\n<pre><code class=\"python\">def ex_3_18():     '''\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f         \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0441\u0442\u0430 \u0438 \u0432\u0435\u0441\u0430'''     df = swimmer_data()     X = df[['\u0420\u043e\u0441\u0442, \u0441\u043c']]      X.insert(0, '\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430', 1)     y = df['\u0412\u0435\u0441'].apply(np.log)     return normal_equation(X, y)<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443:<\/p>\n<pre><code>array([ 1.69103131,&nbsp; 0.01429648])<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b <em>\u03b2<\/em><sub>1<\/sub>&nbsp;\u0438 <em>\u03b2<\/em><sub>2<\/sub>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0438 \u043d\u0430\u043a\u043b\u043e\u043d\u0430. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043e\u043d\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u0443\u044e\u0442\u0441\u044f \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435.<\/p>\n<h2>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438<\/h2>\n<p>\u0427\u0430\u0441\u0442\u044c \u043c\u043e\u0449\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 pandas \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0434\u043b\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<p><sup>\u0412 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c \u0443\u0441\u0432\u043e\u0435\u043d\u0438\u0438 \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439 (\u0414\u0430-\u0434\u0430, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a. \u0421\u043c. \u043c\u043e\u0438 \u043f\u043e\u0441\u0442\u044b \u00ab<\/sup><a href=\"https:\/\/habr.com\/ru\/post\/554150\/\" rel=\"noopener noreferrer nofollow\"><sup>\u041d\u0438\u043a\u0442\u043e \u043d\u0438\u043a\u043e\u0433\u043e \u043d\u0435 \u043e\u0431\u0443\u0447\u0430\u0435\u0442<\/sup><\/a><sup>\u00bb \u0438 \u00ab<\/sup><a href=\"https:\/\/habr.com\/ru\/post\/555048\/\" rel=\"noopener noreferrer nofollow\"><sup>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 machine learning?<\/sup><\/a><sup>\u00bb) \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u0430 \u0434\u043b\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u00ab\u043f\u0440\u0438\u0437\u043d\u0430\u043a\u00bb, \u0430\u043d\u0433\u043b. feature. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u00ab\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u00bb, \u00ab\u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u00bb, \u00ab\u0440\u0435\u0433\u0440\u0435\u0441\u0441\u043e\u0440\u00bb, \u00ab\u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f\u00bb, \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u0432\u0445\u043e\u0434\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f\u00bb.<\/sup><\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0448\u0438\u0445 \u0434\u0432\u0443\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043e\u0442\u0431\u0435\u0440\u0435\u043c \u0440\u043e\u0441\u0442 \u0438 \u0432\u043e\u0437\u0440\u0430\u0441\u0442:<\/p>\n<pre><code class=\"python\">def ex_3_19():     '''\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 NumPy        \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0441\u0442\u0430 \u0438 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430'''     X = swimmer_data()[['\u0420\u043e\u0441\u0442, \u0441\u043c', '\u0412\u043e\u0437\u0440\u0430\u0441\u0442']]     X.insert(0, '\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430', 1)     return X.values<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043d\u0438\u0436\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432:<\/p>\n<pre><code>array([[  1., 166.,  23.],        [  1., 192.,  22.],        [  1., 173.,  20.],        ...,        [  1., 188.,  24.],        [  1., 187.,  19.],        [  1., 183.,  22.]])<\/code><\/pre>\n<p>\u041d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0442 \u044d\u0442\u0443 \u043d\u043e\u0432\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0431\u0435\u0437 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">def ex_3_20():     '''\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f         \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0441\u0442\u0430 \u0438 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0438         \u0432\u0435\u0441\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439'''     df = swimmer_data()     X = df[['\u0420\u043e\u0441\u0442, \u0441\u043c', '\u0412\u043e\u0437\u0440\u0430\u0441\u0442']]      X.insert(0, '\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430', 1)     y = df['\u0412\u0435\u0441'].apply(np.log)     return normal_equation(X, y)<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0438\u0436\u0435\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b:<\/p>\n<pre><code>array([1.69002036, 0.01395437, 0.00279859])<\/code><\/pre>\n<p>\u042d\u0442\u0438 \u0442\u0440\u0438 \u0447\u0438\u0441\u043b\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044e, \u043d\u0430\u043a\u043b\u043e\u043d\u0443 (\u0443\u0433\u043b\u043e\u0432\u043e\u043c\u0443 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0443) \u0434\u043b\u044f \u0440\u043e\u0441\u0442\u0430 (0.013954) \u0438 \u043d\u0430\u043a\u043b\u043e\u043d\u0443 \u0434\u043b\u044f \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 (0.002799). \u0412 \u0446\u0435\u043b\u044f\u0445 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u043a\u0442\u0430 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0437\u0430 \u0441\u0447\u0435\u0442 \u044d\u0442\u0438\u0445 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>R<\/em><sup>2<\/sup>&nbsp;\u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0440\u0430\u043d\u0435\u0435.<\/p>\n<h2>\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 R-\u043a\u0432\u0430\u0434\u0440\u0430\u0442<\/h2>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0441\u0447\u0435\u0442\u0435 <em>R<\/em><sup>2<\/sup><em>&nbsp;<\/em>\u0432 \u0440\u0430\u043d\u0435\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u043d \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043c \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438, \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/53c\/812\/7b9\/53c8127b9d91a2f859b89b2f5e0c5d9b.png\" width=\"126\" height=\"51\"><figcaption><\/figcaption><\/figure>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u2014 \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043e\u0431\u0430 \u0447\u043b\u0435\u043d\u0430 <em>var<\/em>(<em>\u03b5<\/em>)<em>&nbsp;<\/em>\u0438 <em>var<\/em>(<em>y<\/em>) \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438 \u043f\u0440\u0438\u0439\u0442\u0438 \u043a \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c\u0443 \u043d\u0438\u0436\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0434\u043b\u044f <em>R<\/em><sup>2<\/sup>:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/309\/56d\/a5e\/30956da5ee105bebe251b2c3802c0811.png\" width=\"145\" height=\"52\"><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u0441\u0443\u043c\u043c\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u044b\u0445 \u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u043d\u0430 \u0441\u0443\u043c\u043c\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u044b\u0445 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0439 \u043e\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pandas <code>dot<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0443\u043c\u043c\u044b \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e, \u0447\u0442\u043e \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e <em>R<\/em>-\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"python\">def matrix_r_squared(coefs, x, y):     '''\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0439 R-\u043a\u0432\u0430\u0434\u0440\u0430\u0442'''     fitted      = x.dot(coefs)      residuals   = y - fitted      difference  = y - y.mean()       rss         = residuals.dot(residuals)  # \u0441\u0443\u043c\u043c\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432     ess         = difference.dot(difference)     return 1 - (rss \/ ess)<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f rss \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 <em>\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432<\/em>, \u043e\u0442 \u0430\u043d\u0433\u043b. residual sum of squares (RSS), \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f ess \u2014 <em>\u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432<\/em>, \u043e\u0442 \u0430\u043d\u0433\u043b. explained sum of squares (ESS). \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0439 <em>R<\/em><sup>2<\/sup>&nbsp;\u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">def ex_3_21():     '''\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0439 R-\u043a\u0432\u0430\u0434\u0440\u0430\u0442         \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0441\u0442\u0430 \u0438 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0438         \u0432\u0435\u0441\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439'''     df = swimmer_data()     X = df[['\u0420\u043e\u0441\u0442, \u0441\u043c', '\u0412\u043e\u0437\u0440\u0430\u0441\u0442']]      X.insert(0, '\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430', 1)     y = df['\u0412\u0435\u0441'].apply(np.log)     beta = normal_equation(X, y)      return matrix_r_squared(beta, X, y)<\/code><\/pre>\n<pre><code>0.7568466547183842<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0.757. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>R<\/em><sup>2<\/sup>&nbsp;\u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u043e\u0441\u044c \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, <em>R<\/em><sup>2<\/sup><em>&nbsp;<\/em>\u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0446\u0438\u0438<\/em>.<\/p>\n<h2>\u0421\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0439 R-\u043a\u0432\u0430\u0434\u0440\u0430\u0442<\/h2>\n<p>\u041c\u043e\u0442\u0438\u0432\u043e\u043c \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c&nbsp; \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>R<\/em><sup>2<\/sup><em>&nbsp;<\/em>\u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0441\u0442\u0435\u0442. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u2014 \u0435\u0441\u043b\u0438 \u043d\u043e\u0432\u0430\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0438\u043b\u044b, \u0442\u043e \u0435\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d 0, \u0438 <em>R<\/em><sup>2<\/sup><em>&nbsp;<\/em>\u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u0436\u0435, \u043a\u0430\u043a\u0438\u043c \u043e\u043d \u0431\u044b\u043b \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e\u0431 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0438 \u0438\u043b\u0438 \u0443\u0445\u0443\u0434\u0448\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043b\u0438 \u043d\u043e\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0434\u0433\u043e\u043d\u043a\u0443 \u043a \u0434\u0430\u043d\u043d\u044b\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c    , \u043d\u0435\u0440\u0435\u0434\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u043c \u043a\u0430\u043a <em>R\u0305<\/em><sup>2<\/sup>. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <em>R<\/em><sup>2<\/sup>, \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <em>R\u0305<\/em><sup>2<\/sup>&nbsp;\u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0442\u0438, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043d\u043e\u0432\u0430\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 <em>R<\/em><sup>2<\/sup><em>&nbsp;<\/em>\u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"python\">def matrix_adj_r_squared(coefs, x, y):     '''\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0439 R-\u043a\u0432\u0430\u0434\u0440\u0430\u0442'''     r_squared = matrix_r_squared(coefs, x, y)      n = y.shape[0]  # \u0441\u0442\u0440\u043e\u043a\u0438     p = coefs.shape[0]     dec = lambda x: x-1     return 1 - (1 - r_squared) * (dec(n) \/ dec(n-p))<\/code><\/pre>\n<p>\u0421\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <em>R\u0305<\/em><sup>2<\/sup><em>&nbsp;<\/em>\u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0432\u0443\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, <em>n&nbsp;<\/em>\u0438 <em>p<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438 \u0447\u0438\u0441\u043b\u0443 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:<\/p>\n<pre><code class=\"python\">def ex_3_22():     '''\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0439 R-\u043a\u0432\u0430\u0434\u0440\u0430\u0442         \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0441\u0442\u0430 \u0438 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0438         \u0432\u0435\u0441\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439'''     df = swimmer_data()     X = df[['\u0420\u043e\u0441\u0442, \u0441\u043c', '\u0412\u043e\u0437\u0440\u0430\u0441\u0442']]      X.insert(0, '\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430', 1)     y = df['\u0412\u0435\u0441'].apply(np.log)     beta = normal_equation(X, y)      return matrix_adj_r_squared(beta, X, y)<\/code><\/pre>\n<pre><code>0.7559934850858171<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0.756. \u041e\u043d\u043e \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043a\u0440\u0443\u043f\u043d\u0435\u0435 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e \u043d\u0435\u0441\u0435\u0442 \u043d\u0435\u043a\u0443\u044e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u043b\u0443.<\/p>\n<h4>\u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0432 numpy \u0438 scipy<\/h4>\n<p>\u0425\u043e\u0442\u044f \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438 <em>R\u0305<\/em><sup>2<\/sup><em>&nbsp;<\/em>\u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0446\u0435\u043d\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u043e\u0439, \u0432\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy \u0438 scipy \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>np.linalg.lstsq<\/code> \u0438 <code>stats.linregress<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u0432\u0441\u0435 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0438 \u0434\u0430\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435. \u0412 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u043a \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u043f\u043e\u0441\u0442\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. <\/p>\n<p>\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0444\u0443\u043d\u043a\u0446\u0438\u044f numpy <code>np.linalg.lstsq<\/code> \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 <em>x<\/em>&nbsp;\u0438 <em>y<\/em>&nbsp;(\u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u043b\u0438\u0431\u043e \u043c\u0430\u0442\u0440\u0438\u0446, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438). \u0423\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0435\u0442 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e <code>x<\/code>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432, \u043e\u0441\u0442\u0430\u0442\u043a\u0438 <code>residuals<\/code>, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u0430\u043d\u0433 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <code>rank<\/code> \u0438 \u0441\u0438\u043d\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>s<\/code>. \u041c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043e\u0431\u0435\u0440\u0442\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f. \u041d\u0430\u0448\u0430 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0431\u0435\u0442\u044b, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043d\u0438\u0436\u0435 <em>F<\/em>-\u0442\u0435\u0441\u0442\u0435:<\/p>\n<pre><code class=\"python\">def linear_model(x, y):     '''\u041e\u0431\u0435\u0440\u0442\u043a\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438         \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u043c\u0438 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430\u043c\u0438,         \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e         \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f normal_equation'''     return np.linalg.lstsq(x,y,rcond=-1)[0]<\/code><\/pre>\n<h2>F-\u0442\u0435\u0441\u0442 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0435\u0440\u0438\u0438 \u043f\u043e\u0441\u0442\u043e\u0432 \u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0433\u0438\u043f\u043e\u0442\u0435\u0437, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <em>F<\/em>-\u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0441\u0442\u043e\u0432 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u0438. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0435\u0439, \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043d\u0435\u043e\u0442\u043b\u0438\u0447\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u043d\u0443\u043b\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0448\u0438 \u043d\u0443\u043b\u0435\u0432\u0430\u044f \u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c5f\/00f\/a8f\/c5f00fa8fc495a53bad7e10d5fd4d529.png\" width=\"148\" height=\"71\"><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c <em>j <\/em>\u2014 \u044d\u0442\u043e \u043d\u0435\u043a\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f, \u0442.\u0435. \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u0447\u043b\u0435\u043d\u0430. \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u0430\u044f \u043d\u0430\u043c\u0438 <em>F<\/em>-\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u043d\u043e\u0439 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438 \u043d\u0430 \u043d\u0435\u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u043d\u043e\u0439 (\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439) \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438. \u041e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 <em>\u0441\u0440\u0435\u0434\u043d\u0435\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438<\/em>, \u043e\u0442 \u0430\u043d\u0433\u043b. mean squared model (MSM) \u043d\u0430 <em>\u0441\u0440\u0435\u0434\u043d\u0435\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u043e\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0435<\/em>, \u043e\u0442 \u0430\u043d\u0433\u043b. mean square error (MSE):<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad1\/4d9\/08c\/ad14d908c2778f2f328496b126240828.png\" width=\"80\" height=\"48\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0440\u0435\u0434\u043d\u0435\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u044b\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (MSM) \u0440\u0430\u0432\u0435\u043d <em>\u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432<\/em><strong> <\/strong>(ESS) \u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u044b, \u0433\u0434\u0435 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u044b \u2014 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u0447\u043b\u0435\u043d\u0430. \u0421\u0440\u0435\u0434\u043d\u0435\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0430\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 (MSE) \u0440\u0430\u0432\u043d\u0430 <em>\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432<\/em> (RSS) \u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0443\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u044b, \u0433\u0434\u0435 \u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u044b \u2014 \u044d\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043c\u0438\u043d\u0443\u0441 \u0447\u0438\u0441\u043b\u043e \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u0447\u0435\u0442\u0430 <em>F<\/em>-\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043c\u044b \u043e\u0442\u044b\u0441\u043a\u0438\u0432\u0430\u0435\u043c \u0435\u0435 \u0432 <em>F<\/em>-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0442\u0435\u043c\u0438 \u0436\u0435 \u0434\u0432\u0443\u043c\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044f\u043c\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u044b:<\/p>\n<pre><code class=\"python\">def f_test(fitted, x, y):     '''F-\u0442\u0435\u0441\u0442 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438'''     difference = fitted - y.mean()      residuals  = y - fitted     ess        = difference.dot(difference) # \u0441\u0443\u043c\u043c\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432     rss        = residuals.dot(residuals)     p          = x.shape[1]    # \u0441\u0442\u043e\u043b\u0431\u0446\u044b     n          = y.shape[0]    # \u0441\u0442\u0440\u043e\u043a\u0438     df1        = p - 1     df2        = n - p     msm        = ess \/ df1     mse        = rss \/ df2     f_stat     = msm \/ mse     # mse \u043c\u043e\u0434\u0435\u043b\u0438 \/ mse \u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432     f_test     = 1-stats.f.cdf(f_stat, df1, df2)      return f_test<\/code><\/pre>\n<pre><code class=\"python\">def ex_3_23():     '''\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 F-\u0442\u0435\u0441\u0442\u0430        \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0441\u0442\u0430, \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u0438 \u0432\u0435\u0441\u0430'''     df = swimmer_data()     X = df[['\u0420\u043e\u0441\u0442, \u0441\u043c', '\u0412\u043e\u0437\u0440\u0430\u0441\u0442']]     X.insert(0, '\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430', 1.0)     y = df['\u0412\u0435\u0441'].apply(np.log)     beta = linear_model(X, y)         fittedvalues = np.dot(X,beta)       # \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438     return ('F-\u0442\u0435\u0441\u0442', f_test(fittedvalues, X, y))<\/code><\/pre>\n<pre><code>('F-\u0442\u0435\u0441\u0442', 1.1102230246251565e-16)<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0447\u0438\u0441\u043b\u043e 1.11x10e-16. \u042d\u0442\u043e \u043d\u0438\u0447\u0442\u043e\u0436\u043d\u043e \u043c\u0430\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0438, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u0437\u043d\u0430\u0447\u0438\u043c\u0430.<\/p>\n<p>\u041e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043c\u0430\u043b\u044b\u0445 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445 <em>F<\/em>-\u0442\u0435\u0441\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0443\u044e\u0441\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u0430. \u0412 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438\u0437 \u043f\u044f\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u0435\u0434\u0432\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043a\u0430\u043a\u0443\u044e-\u043b\u0438\u0431\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c \u0432\u043e\u043e\u0431\u0449\u0435, \u0438 <em>F<\/em>-\u0442\u0435\u0441\u0442 \u0442\u0440\u0430\u043a\u0442\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u0430\u043a \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0435 \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 50%-\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h2>\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0438 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u00ab\u041f\u043e\u043b\u00bb \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u043c\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u044b \u043d\u0435 \u0447\u0438\u0441\u043b\u043e\u043c, \u0430 \u043a\u0430\u043a \u00ab\u041c\u00bb \u0438\u043b\u0438 \u00ab\u0416\u00bb. \u042d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439: \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u0445 \u0438 (\u043e\u0431\u044b\u0447\u043d\u043e) \u043d\u0435\u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0438\u0434 \u0441\u043f\u043e\u0440\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043f\u043e\u0440\u0442\u0441\u043c\u0435\u043d \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0438\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432\u0437\u044f\u0442\u043e\u0435 \u0441\u043e\u0441\u0442\u044f\u0437\u0430\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d. <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u044b \u043e\u043f\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041a\u0430\u043a\u0438\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043f\u043b\u0430\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u043b\u0435\u0433\u043a\u043e\u0439 \u0430\u0442\u043b\u0435\u0442\u0438\u043a\u043e\u0439 \u0432 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438? \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u043d\u0430\u0448\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<p><sup>\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043b\u0438 \u043d\u043e\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u043e\u044f\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u044f\u0434\u0443 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u0442.\u043a. \u043e\u043d\u0438 \u043d\u0435 \u043b\u0435\u0436\u0430\u0442 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u043e\u0441\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0446\u0438\u0444\u0440\u0430\u043c\u0438, \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0441 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u044b \u043b\u0438\u0431\u043e \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c\u0438 \u0440\u0430\u0432\u043d\u044b\u0439.<\/sup><\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0434\u0438\u0445\u043e\u0442\u043e\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0438, \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u0448\u0438 \u0432\u044b\u0431\u043e\u0440\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0434\u0432\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043f\u043e\u043b\u043e\u0432\u043e\u0439 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u043d\u0430\u0448\u0443 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0438\u0445 \u0432 \u0434\u0432\u0430 \u0447\u0438\u0441\u043b\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 0 \u0438 1.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0442\u0430\u043a\u0430\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f, \u043a\u0430\u043a \u0432\u0438\u0434 \u0441\u043f\u043e\u0440\u0442\u0430, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0434\u0432\u0443\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u0441\u043f\u043e\u0440\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u043f\u043b\u0430\u0432\u0430\u043d\u0438\u044f \u0438 \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0434\u043b\u044f \u0442\u044f\u0436\u0435\u043b\u043e\u0439 \u0430\u0442\u043b\u0435\u0442\u0438\u043a\u0438 \u0438 \u0442.\u0434. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043b\u0430\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 1 \u0434\u043b\u044f \u043f\u043b\u043e\u0432\u0446\u043e\u0432 \u0438 0 \u2014 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445.<\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u043b\u043e\u0432\u0430\u044f \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0436\u0435\u043d\u0441\u043a\u0438\u0439 \u043f\u043e\u043b \u0432 0 \u0438 \u043c\u0443\u0436\u0441\u043a\u043e\u0439 \u2014 \u0432 1 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>R\u0305<\/em><sup>2<\/sup>, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0438\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0432 \u044d\u0442\u043e\u043c \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435:<\/p>\n<pre><code class=\"python\">def ex_3_25():     '''\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432         (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439)'''     df = swimmer_data()     df['\u0431\u0438\u043d_\u041f\u043e\u043b'] = df['\u041f\u043e\u043b'].map({'\u041c': 1, '\u0416': 0}).astype(int) # \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 -&gt; \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435      X = df[['\u0420\u043e\u0441\u0442, \u0441\u043c', '\u0412\u043e\u0437\u0440\u0430\u0441\u0442', '\u0431\u0438\u043d_\u041f\u043e\u043b']]      X.insert(0, '\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430', 1)     y = df['\u0412\u0435\u0441'].apply(np.log)            beta = linear_model(X, y)      return matrix_adj_r_squared(beta, X, y)<\/code><\/pre>\n<pre><code>0.8082954905432824<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c 0.809. \u0421 \u0443\u0447\u0430\u0441\u0442\u0438\u0435\u043c \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043a\u0430\u043a \u0440\u043e\u0441\u0442, \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u0438 \u043f\u043e\u043b, \u043c\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 80% \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438 \u0432 \u0432\u0435\u0441\u0435 \u043d\u0430\u0448\u0438\u0445 \u043e\u043b\u0438\u043c\u043f\u0438\u0439\u0441\u043a\u0438\u0445 \u043f\u043b\u043e\u0432\u0446\u043e\u0432.<\/p>\n<h2>\u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0431\u044b\u043b\u043e \u0431\u044b \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c \u043f\u043e\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0438\u0433\u0440\u0430\u0435\u0442 \u0441\u0430\u043c\u0443\u044e \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u0432\u0435\u0441\u0430: \u0432\u043e\u0437\u0440\u0430\u0441\u0442, \u043f\u043e\u043b \u0438\u043b\u0438 \u0440\u043e\u0441\u0442? \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0438\u043c \u0441\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c <em>R<\/em><sup>2<\/sup> \u0438 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043d\u043e \u044d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u043e\u0442 \u043d\u0430\u0441 &nbsp;\u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c.<\/p>\n<p>\u041c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u043d\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f: \u0432\u044b\u0441\u043e\u0442\u0430 \u0432 \u0441\u0430\u043d\u0442\u0438\u043c\u0435\u0442\u0440\u0430\u0445, \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u0432 \u0433\u043e\u0434\u0430\u0445 \u0438 \u043f\u043e\u043b \u0432 \u0432\u0438\u0434\u0435 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 1.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043a\u043b\u0430\u0434 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u0438\u043b\u0438 \u0431\u0435\u0442\u0430-\u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/63b\/acb\/091\/63bacb09103ce87e1ad595e9231cd726.png\" width=\"121\" height=\"49\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0446\u0435\u043b\u044f\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0431\u0435\u0442\u0430-\u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043d\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043a \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043d\u0438\u0436\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 Python:<\/p>\n<pre><code class=\"python\">def beta_weight(coefs, x, y):     '''\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u043a\u043b\u0430\u0434\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430'''     sdx = x.std()     sdy = y.std()     return [x \/ sdy * c for x,c in zip(sdx,coefs)] <\/code><\/pre>\n<pre><code class=\"python\">def ex_3_26():     '''\u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043a\u043b\u0430\u0434 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0432 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0438 \u0432\u0435\u0441\u0430        \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0441\u0442\u0430, \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u0438 \u043f\u043e\u043b\u0430'''     df = swimmer_data()     # \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u043f\u043e\u043b\u0435     df['\u0431\u0438\u043d_\u041f\u043e\u043b'] = df['\u041f\u043e\u043b'].map({'\u041c': 1, '\u0416': 0}).astype(int)     X = df[['\u0420\u043e\u0441\u0442, \u0441\u043c', '\u0412\u043e\u0437\u0440\u0430\u0441\u0442', '\u0431\u0438\u043d_\u041f\u043e\u043b']]      X.insert(0, '\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430', 1)     y = df['\u0412\u0435\u0441'].apply(np.log)      beta = linear_model(X, y)      res = beta_weight(beta, X, y)     return res<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c (\u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043e \u0434\u043e \u0442\u0440\u0435\u0445 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u043a\u043e\u0432):<\/p>\n<pre><code>[0.0, 0.6501469135033348, 0.05842998157513067, 0.30387262631851747]<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0440\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0439 \u0432\u0430\u0436\u043d\u043e\u0439 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438\u0434\u0443\u0442 \u043f\u043e\u043b \u0438 \u0432\u043e\u0437\u0440\u0430\u0441\u0442. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f \u0432 \u0440\u043e\u0441\u0442\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u0432\u0435\u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 0.65 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0439.<\/p>\n<h2>\u041a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c, \u0441\u0442\u0430\u0440\u0430\u044f\u0441\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u043b\u0443.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u00ab\u0414\u0430\u0442\u0430 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f\u00bb, \u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0441\u043e\u0431\u043b\u0430\u0437\u043d \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0435\u0441\u0442\u0438 \u0438 \u0435\u0433\u043e. \u042d\u0442\u043e \u0434\u0430\u0442\u0430, \u043d\u043e \u043c\u044b \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0432 \u0447\u0438\u0441\u043b\u043e, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u0432\u0437\u044f\u0432 \u0433\u043e\u0434 \u0438\u0437 \u0434\u0430\u0442\u044b \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 pandas <code>pd.to_datetime<\/code>:<\/p>\n<pre><code class=\"python\">'''\u0421\u043b\u0443\u0436\u0435\u0431\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e     \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u0442\u044b \u043a \u0442\u0438\u043f\u0443 DateTime \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0433\u043e\u0434\u0430''' str_to_year = lambda x: pd.to_datetime(x).year  def ex_3_27():     '''\u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043a\u043b\u0430\u0434 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0432 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0438 \u0432\u0435\u0441\u0430        \u0441 \u0443\u0447\u0430\u0441\u0442\u0438\u0435\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0441 \u0434\u0430\u0442\u043e\u0439 (\u0433\u043e\u0434)'''     df = swimmer_data()     df['\u0431\u0438\u043d_\u041f\u043e\u043b'] = df['\u041f\u043e\u043b'].map({'\u041c': 1, '\u0416': 0}).astype(int)      df['\u0413\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f'] = df['\u0414\u0430\u0442\u0430 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f'].map(str_to_year)     X = df[['\u0420\u043e\u0441\u0442, \u0441\u043c', '\u0412\u043e\u0437\u0440\u0430\u0441\u0442', '\u0431\u0438\u043d_\u041f\u043e\u043b', '\u0413\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f']]      X.insert(0, '\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430', 1.0)     y = df['\u0412\u0435\u0441'].apply(np.log)           beta = linear_model(X, y)      return beta_weight(beta, X, y)<\/code><\/pre>\n<pre><code>[-0.0,  0.650070475196164,  0.09580282723307212,  0.3041431115029873,  0.03769748899125406]<\/code><\/pre>\n<p>\u041d\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u00ab\u0413\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f\u00bb \u0438\u043c\u0435\u0435\u0442 \u0431\u0435\u0442\u0430-\u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0432\u0441\u0435\u0433\u043e 0.038, \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0435\u0441\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u00ab\u0412\u043e\u0437\u0440\u0430\u0441\u0442\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u0435\u0441 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u00ab\u0412\u043e\u0437\u0440\u0430\u0441\u0442\u00bb \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0.096. \u0415\u0433\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0430\u0441\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043d\u0430 65%, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u00ab\u0413\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f\u00bb. \u0422\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.<\/p>\n<p>\u0412\u043a\u043b\u044e\u0447\u0438\u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u00ab\u0413\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f\u00bb, \u043c\u044b \u043d\u0435\u043f\u0440\u0435\u0434\u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043d\u0430\u0440\u0443\u0448\u0438\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0447\u0435\u043c\u0443:<\/p>\n<pre><code class=\"python\">def ex_3_28():     '''\u0413\u0440\u0430\u0444\u0438\u043a \u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u0441\u043f\u043e\u0440\u0442\u0441\u043c\u0435\u043d\u043e\u0432 \u0438 \u0434\u0430\u0442\u044b \u0438\u0445 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f'''     df = swimmer_data()     df['\u0413\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f'] = df['\u0414\u0430\u0442\u0430 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f'].map(str_to_year)     xs = df['\u0412\u043e\u0437\u0440\u0430\u0441\u0442'].apply(jitter(0.5))     ys = df['\u0413\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f']     pd.DataFrame(np.array([xs,ys]).T).plot.scatter(0, 1, s=3, grid=True)     plt.xlabel('\u0412\u043e\u0437\u0440\u0430\u0441\u0442')     plt.ylabel('\u0413\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f')     #saveplot('ex_3_28.png')     plt.show()<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u0442\u043e\u0447\u0435\u0447\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430 \u043f\u043b\u043e\u0432\u0446\u043e\u0432 (\u0441 \u0434\u0436\u0438\u0442\u0442\u0435\u0440\u043e\u043c) \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u0432 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441 \u0438\u0445 \u0433\u043e\u0434\u043e\u043c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f. \u041a\u0430\u043a \u0432\u044b \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u0438, \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0438\u0437\u043a\u043e \u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u0443\u044e\u0442:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cff\/3a6\/c10\/cff3a6c10964a78cb56d232c32e9afc9.png\" width=\"360\" height=\"295\"><figcaption><\/figcaption><\/figure>\n<h2>\u041c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>\u0412 \u0446\u0435\u043b\u044f\u0445 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u0445 \u043e\u0446\u0435\u043d\u043e\u043a \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0434\u0447\u0438\u043d\u044f\u0442\u044c\u0441\u044f \u0442\u0435\u043c \u0436\u0435 \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u0438\u044f\u043c, \u0447\u0442\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043f\u043b\u044e\u0441 \u043e\u0434\u043d\u043e\u043c\u0443 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u2014 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044e \u043f\u043e\u043b\u043d\u043e\u0439 <em>\u043c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u0438<\/em>. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0442\u0440\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p><sup>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0440\u0435 \u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u044b. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u0438 \u0440\u043e\u0441\u0442 \u0438\u043b\u0438 \u043f\u043e\u043b \u0438 \u0440\u043e\u0441\u0442 \u0441\u0430\u043c\u0438 \u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u0443\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u0421\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u0440\u0430\u0439\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/sup><\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c\u0438, \u0442\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043a\u043b\u0430\u0434 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0415\u0441\u043b\u0438 \u0434\u0432\u0430 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0442\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e \u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0447\u0442\u043e \u043e\u043d\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435, \u0442\u043e \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0442\u044c \u0438\u0445 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u044c? \u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0432 \u043e\u0446\u0435\u043d\u043a\u0430\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u0438 \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430.<\/p>\n<p>\u041c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u043f\u0442\u043e\u043c \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u0438: \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0437 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f. \u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u0438\u043c\u043f\u0442\u043e\u043c \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432\u0437\u044f\u0442\u043e\u0439 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043d\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 <em>R<\/em><sup>2<\/sup>&nbsp;\u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0436\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>\u0425\u043e\u0442\u044f \u044d\u0442\u0438 \u0441\u0438\u043c\u043f\u0442\u043e\u043c\u044b \u0441\u043b\u0443\u0436\u0430\u0442 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u0438, \u0432 \u0446\u0435\u043b\u044f\u0445 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0432\u0437\u0430\u0438\u043c\u043d\u043e\u0439 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043d\u0443\u044e \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043e\u0442\u044b\u0441\u043a\u0438\u0432\u0430\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0435 0.8 \u0438\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435. \u0425\u043e\u0442\u044f \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0447\u0430\u0441\u0442\u043e \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u043d\u0435\u0440\u0435\u0434\u043a\u043e \u0435\u043c\u0443 \u043d\u0435 \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0438\u043c\u0435\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u0432\u0437\u044f\u0442\u044b\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u0435.<\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u0432\u0435\u0440\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043e\u0446\u0435\u043d\u043a\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u043b\u044e\u0431\u043e\u0439 <em>R<\/em><sup>2<\/sup>&nbsp;\u0438\u0437 \u044d\u0442\u0438\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0431\u043b\u0438\u0437\u043e\u043a \u043a 1.0, \u0442\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u044c. \u041d\u0430 \u0434\u0435\u043b\u0435 \u0441\u0430\u043c\u044b\u0439 \u043a\u0440\u0443\u043f\u043d\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 <em>R<\/em><sup>2<\/sup>&nbsp;\u0441\u043b\u0443\u0436\u0438\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0443\u043b\u044c\u0442\u0438\u043a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443:<\/p>\n<ul>\n<li>\n<p>\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438. \u0411\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u0434\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u0435 \u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u0437\u043d\u0430\u043a. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u0440\u044f\u044e\u0442 \u0442\u043e\u0442 \u0436\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442, \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0439\u0442\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0445 \u0443\u043d\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u0437\u043d\u0430\u043a.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e (\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435).<\/p>\n<\/li>\n<li>\n<p>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f. \u041a\u043e\u043b\u043b\u0438\u043d\u0435\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438, \u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u0438 \u0433\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0441\u0443\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043c\u044b \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u041c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0438\u043b\u044b, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0432 \u0434\u0432\u0443\u0445\u0444\u0430\u043a\u0442\u043e\u0440\u043d\u0443\u044e \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>\u00ab\u0412\u043e\u0437\u0440\u0430\u0441\u0442\u00bb <em>R<\/em><sup>2 <\/sup>= 0.1049, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u00ab\u0413\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f\u00bb <em>R<\/em><sup>2<\/sup> = 0.1050.<\/p>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c, \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0442 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043d\u0438\u0445 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 10% \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438 \u0432 \u0432\u0435\u0441\u0435. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0433\u043e\u0434 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438, \u043c\u044b \u0435\u0433\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0438 \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u00ab\u0412\u043e\u0437\u0440\u0430\u0441\u0442\u00bb. <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043c\u043e\u0435\u043c&nbsp;<a href=\"https:\/\/github.com\/capissimo\/python-for-data-science\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e<\/a>&nbsp;\u043d\u0430 Github. \u0412\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0437\u044f\u0442\u044b \u0432&nbsp;<a href=\"https:\/\/github.com\/clojuredatascience\/ch3-correlation\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>&nbsp;\u0430\u0432\u0442\u043e\u0440\u0430 \u043a\u043d\u0438\u0433\u0438.&nbsp; <\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u043c \u043f\u043e\u0441\u0442\u0435, <a href=\"https:\/\/habr.com\/ru\/post\/558158\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0441\u0442\u0435 \u21164<\/a>, \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/558146\/\"> https:\/\/habr.com\/ru\/post\/558146\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u043e\u0441\u0442 \u0441\u043c. <a href=\"https:\/\/habr.com\/ru\/post\/558084\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u044b \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f. <\/p>\n<h2>\u041c\u0430\u0442\u0440\u0438\u0446\u044b<\/h2>\n<p>\u041c\u0430\u0442\u0440\u0438\u0446\u0430, \u2014 \u044d\u0442\u043e \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0447\u0438\u0441\u0435\u043b. \u0420\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u043c \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>A&nbsp;<\/em>\u2014 \u044d\u0442\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441 \u0447\u0435\u0442\u044b\u0440\u044c\u043c\u044f \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0438 \u0434\u0432\u0443\u043c\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u043f\u0438\u0441\u043d\u043e\u0439 \u0431\u0443\u043a\u0432\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u0432 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c \u0435\u0435 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445.<\/p>\n<p>\u041c\u0430\u0441\u0441\u0438\u0432 numpy \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 pandas <code>df.values<\/code>:<\/p>\n<pre><code class=\"python\">def ex_3_16():     '''\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 (\u043c\u0430\u0442\u0440\u0438\u0446\u0443) numpy         \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0441\u0442\u0430 \u0438 \u0432\u0435\u0441\u0430'''     df = swimmer_data()[['\u0420\u043e\u0441\u0442, \u0441\u043c', '\u0412\u0435\u0441']]     return df.values<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<pre><code>array([[166.,  68.],        [192.,  89.],        [173.,  65.],        ...,        [188.,  79.],        [187.,  78.],        [183.,  70.]])<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy <code>np.array<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d \u043b\u0438\u0431\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0438, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 (\u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>numpy.ndarray<\/code>):<\/p>\n<pre><code class=\"python\">def ex_3_17():     '''\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 (\u043c\u0430\u0442\u0440\u0438\u0446\u0443) numpy         \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u0440\u043e\u0441\u0442\u0435'''     return swimmer_data()['\u0420\u043e\u0441\u0442, \u0441\u043c'].head(20).values # \u043f\u0435\u0440\u0432\u044b\u0435 20<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<pre><code>array([166., 192., 173., 179., 201., 190., 175., 160., 202., 173., 175.,        205., 185., 175., 185., 170., 165., 179., 165., 170.])<\/code><\/pre>\n<p>\u041c\u0430\u0442\u0440\u0438\u0446\u044b \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0440\u0430\u0441\u0442\u0430\u0442\u044c \u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e\u043a\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 pandas head \u0438 <code>tail<\/code> \u043b\u0438\u0431\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy (<code>result_array[:5]<\/code>); \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p><sup>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 pandas \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0432\u044b\u0433\u043e\u0434\u0443 \u043e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a log, exp, sqrt \u0438 \u0434\u0440., \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445\/\u043c\u0430\u0442\u0440\u0438\u0446\u0430\u0445. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 numpy \u043c\u043e\u0433\u0443\u0442 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043a\u0430\u0434\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 DataFrame (\u0438 \u0440\u044f\u0434\u0430\u043c\u0438 Series) \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pandas \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, np.exp(df), np.asarray(df), df.T.dot(df)).<\/sup><\/p>\n<h2>\u0420\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>\u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 <em>i<\/em>-\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 <em>j<\/em>-\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <em>A<\/em><sub>ij<\/sub>. \u0418 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pandas \u0438 numpy \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>shape<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0440\u0442\u0435\u0436 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430: \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a, \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<h2>\u0412\u0435\u043a\u0442\u043e\u0440\u044b<\/h2>\n<p>\u0412\u0435\u043a\u0442\u043e\u0440\u044b \u2014 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0441\u0442\u043e\u043b\u0431\u0435\u0446. \u0427\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c\u044e:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c <em>y&nbsp;<\/em>\u2014 \u044d\u0442\u043e 4-\u043c\u0435\u0440\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440; \u0435\u0433\u043e <em>i<\/em>-\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <em>y<\/em><sub>i<\/sub>. \u0412\u0435\u043a\u0442\u043e\u0440\u044b \u0432 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0438\u043d\u043e\u0435.<\/p>\n<p>\u0422\u0430\u043a,    <em>&nbsp;<\/em>\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043d\u0435 \u0432\u0442\u043e\u0440\u043e\u0439. \u0412 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u0447\u043d\u044b\u043c\u0438 \u0431\u0443\u043a\u0432\u0430\u043c\u0438. <\/p>\n<p><sup>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pandas (\u0433\u0434\u0435 Series \u0438 DataFrame \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0438 \u043c\u0430\u0442\u0440\u0438\u0446) \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u043e\u0434\u043d\u043e\u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432\u044b\u043c\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e np.array \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/sup><\/p>\n<h2>\u0421\u0431\u043e\u0440\u043a\u0430<\/h2>\n<p>\u041a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 Python \u0438 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 pandas. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445, \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0435\u0439, \u043d\u0430\u0434\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0431\u043e\u043a \u043e \u0431\u043e\u043a \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u0438. \u0412 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0435\u0434\u0438\u043d\u0438\u0446 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0438\u043b\u0438 \u043a\u043e\u043d\u0435\u0446 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">'''\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043c\u0430\u0441\u0441\u0438\u0432)''' df = pd.DataFrame({'x':[2, 3, 6, 7],'y':[8, 7, 4, 3]}) df['\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430'] = 1 df<\/code><\/pre>\n<pre><code>\tx\ty\t\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 0\t2\t8\t1 1\t3\t7\t1 2\t6\t4\t1 3\t7\t3\t1<\/code><\/pre>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u0447\u043b\u0435\u043d\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e <em>\u03b2<\/em><sub>1<\/sub><em>&nbsp;<\/em>\u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <em>x<\/em><sub>1<\/sub><em>&nbsp;<\/em>\u0442\u043e\u0436\u0435 \u0431\u044b\u043b \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043e\u0439. \u0411\u0435\u0437 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>y&nbsp;<\/em>\u0440\u0430\u0432\u043d\u044f\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0443\u043b\u044e, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>x<\/em> \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e.<\/p>\n<h2>\u0421\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421\u043a\u0430\u043b\u044f\u0440 \u2014 \u044d\u0442\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043a\u0430\u043b\u044f\u0440 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u043c\u044b \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0430\u0442\u0440\u0438\u0446\u044b.<\/p>\n<p>\u041c\u0430\u0442\u0440\u0438\u0447\u043d\u043e-\u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0443\u0442\u0435\u043c \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438. \u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u0415\u0441\u043b\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u043e \u043d\u0438\u0445 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u043e\u043d\u0438 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0435.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df1 = pd.DataFrame([[1,0],[2,5],[3,1]]) df2 = pd.DataFrame([[4,0.5],[2,5],[0,1]]) df1 + df2<\/code><\/pre>\n<pre><code> \t0\t   1 0\t5\t 0.5 1\t4\t10.0 2\t3\t 2.0<\/code><\/pre>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0441\u043a\u0430\u043b\u044f\u0440\u043e\u0432 \u0438 \u043c\u0430\u0442\u0440\u0438\u0446, \u0432 pandas \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043a\u0430\u043b\u044f\u0440\u044b \u043b\u0438\u0431\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446 \u043d\u0430 \u0441\u043a\u0430\u043b\u044f\u0440 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u0430\u0435\u0442 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u043c\u043d\u043e\u0436\u0435\u043d \u043d\u0430 \u0441\u043a\u0430\u043b\u044f\u0440.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df1 * 3<\/code><\/pre>\n<pre><code>\t0\t 1 0\t3\t 0 1\t6\t15 2\t9\t 3<\/code><\/pre>\n<h2>\u041c\u0430\u0442\u0440\u0438\u0447\u043d\u043e-\u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>dot<\/code> \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0440\u0430\u0437\u043c\u0435\u0440\u0430 3 \u00d7 2&nbsp;\u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 2 \u00d7 1&nbsp;\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 3 \u00d7 1, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0441\u043b\u0435\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0447\u0438\u0441\u043b\u043e\u043c \u0441\u0442\u0440\u043e\u043a \u0441\u043f\u0440\u0430\u0432\u0430:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f <em>Ax<\/em>&nbsp;\u043d\u0430\u0434\u043e \u043f\u043e\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 <em>A&nbsp;<\/em>\u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u044b <em>x<\/em>&nbsp;\u0438 \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <em>A<\/em>&nbsp;\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b 1 \u0438 3. \u041e\u043d\u0438 \u043f\u043e\u043f\u0430\u0440\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 <em>x<\/em>: 1 \u0438 5. \u0417\u0430\u0442\u0435\u043c, \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 16. \u042d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u0442\u043e\u0447\u0435\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c<\/em>, \u0438\u043b\u0438 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c, \u0434\u043b\u044f \u0447\u0435\u0433\u043e, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df3 = pd.DataFrame([[1,3],[0,4],[2,1]]) vec = [1,5] df3.dot(vec)<\/code><\/pre>\n<pre><code>0    16 1    20 2     7 dtype: int64<\/code><\/pre>\n<h2>\u041c\u0430\u0442\u0440\u0438\u0447\u043d\u043e-\u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e-\u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e-\u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435. \u0418\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0430\u0442\u0440\u0438\u0446 <em>A<\/em>&nbsp;\u0438 <em>B<\/em>&nbsp;\u043f\u043e\u043f\u0430\u0440\u043d\u043e, \u0441\u0442\u0440\u043e\u043a\u0430 \u0437\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0438 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0437\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u043c, \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0441\u0443\u043c\u043c\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0439.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0438 \u0440\u0430\u043d\u0435\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043c\u043d\u043e\u0436\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0440\u0430\u0432\u043d\u043e \u0447\u0438\u0441\u043b\u0443 \u0441\u0442\u0440\u043e\u043a \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 <em>A <\/em>\u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c <em>m<sub>A<\/sub><\/em> \u00d7 <em>n<sub>A<\/sub><\/em>, \u0430 \u0432\u0442\u043e\u0440\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 <em>B<\/em>&nbsp;\u2014 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c <em>m<sub>B<\/sub><\/em> \u00d7 <em>n<sub>B<\/sub><\/em>, \u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0438\u0442\u044c, <em>n<sub>A<\/sub><\/em>&nbsp;\u0438 <em>m<sub>B<\/sub><\/em>&nbsp;\u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u043c\u0438.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443. \u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445 pandas \u0438 numpy \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u0443\u044e \u0430\u043b\u0433\u0435\u0431\u0440\u0443 \u0437\u0430 \u043d\u0430\u0441.<\/p>\n<pre><code class=\"python\">df3 = pd.DataFrame([[1,3],[0,4],[2,1]]) df4 = pd.DataFrame([[1,0],[5,6]])      df3.dot(df4)<\/code><\/pre>\n<pre><code>\t0    1 0\t16\t18 1\t20\t24 2\t 7\t 6<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 numpy:<\/p>\n<pre><code class=\"python\">np.matmul(df3,np.asarray(df4))<\/code><\/pre>\n<h2>\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043f\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0438\u0437 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u043b\u0435\u0432\u043e\u0433\u043e \u0443\u0433\u043b\u0430 \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u043f\u0440\u0430\u0432\u044b\u0439 \u0443\u0433\u043e\u043b. \u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <em>A&nbsp;<\/em>\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <em>A<sup>T<\/sup><\/em>:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0442\u043e\u043b\u0431\u0446\u044b \u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u043b\u0438:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0442\u043e:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df3.T<\/code><\/pre>\n<pre><code>\t0\t1\t2 0\t1\t0\t2 1\t3\t4\t1<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0441 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438 \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0441\u043c. \u0432 \u043c\u043e\u0435\u043c <a href=\"https:\/\/github.com\/capissimo\/python-for-data-science\/blob\/master\/ch03_Correlation.ipynb\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e<\/a> \u043d\u0430 Gitgub \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u043f\u043e\u0441\u0442\u043e\u0432.<\/p>\n<h2>\u041d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430<\/h2>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0441\u043e\u0431\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u0435. \u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u0442\u0440\u0438\u0446 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430, \u0438\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430. \u042d\u0442\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u043c\u0438 \u0432\u0434\u043e\u043b\u044c \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438 \u0438 \u043d\u0443\u043b\u044f\u043c\u0438 \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u0445:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0434\u0438\u043d\u0438\u0447\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u2014 \u044d\u0442\u043e \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 (\u0438\u043b\u0438 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f). \u041a\u0430\u043a \u0438 \u043f\u0440\u0438 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e 1, \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 numpy <code>np.identity<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u0442 \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0435, \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0448\u0438\u0440\u0438\u043d\u0443 \u0438 \u0432\u044b\u0441\u043e\u0442\u0443 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df = pd.DataFrame(np.identity(5)) df<\/code><\/pre>\n<pre><code>\t  0\t  1\t  2\t  3\t  4 0\t1.0\t0.0\t0.0\t0.0\t0.0 1\t0.0\t1.0\t0.0\t0.0\t0.0 2\t0.0\t0.0\t1.0\t0.0\t0.0 3\t0.0\t0.0\t0.0\t1.0\t0.0 4\t0.0\t0.0\t0.0\t0.0\t1.0<\/code><\/pre>\n<h2>\u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <em>A<\/em>, \u0442\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0434\u043b\u044f <em>A<\/em>&nbsp;\u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <em>A<sup>&#8212;<\/sup><\/em><sup>1<\/sup>, \u0438 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0433\u0434\u0435 <em>I<\/em>&nbsp;\u2014 \u044d\u0442\u043e \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u0441\u0435\u0431\u0435. \u041d\u0435 \u0432\u0441\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u044b. \u041d\u0435\u043e\u0431\u0440\u0430\u0442\u0438\u043c\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <em>\u0441\u0438\u043d\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 <\/em>\u0438\u043b\u0438 <em>\u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u043c\u0438<\/em>. \u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>np.linalg.pinv<\/code> \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0430\u043b\u0433\u0435\u0431\u0440\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 numpy.<\/p>\n<p>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c pandas:<\/p>\n<pre><code class=\"python\">df5 = pd.DataFrame(np.random.rand(3, 3), list('abc'), list('xyz')) print(df5) df_inv = pd.DataFrame(np.linalg.pinv(df5.values), df5.columns, df5.index) print(df_inv)<\/code><\/pre>\n<pre><code>          x         y         z a  0.625754  0.385261  0.462726 b  0.615084  0.111360  0.255420 c  0.723909  0.270869  0.221620           a         b         c x -1.451613  1.303231  1.528861 y  1.584699 -6.402303  4.070011 z  2.804750  3.568103 -5.456161<\/code><\/pre>\n<h2>\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043e\u0441\u043d\u043e\u0432\u044b \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432 \u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044e <em>\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/em>. \u042d\u0442\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u0430\u044f \u0430\u043b\u0433\u0435\u0431\u0440\u0430:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041c\u044b \u0447\u0438\u0442\u0430\u0435\u043c \u00ab\u0434\u043b\u044f \u043e\u0442\u044b\u0441\u043a\u0430\u043d\u0438\u044f <em>\u03b2<\/em>&nbsp;\u043d\u0430\u0434\u043e \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 <em>X&nbsp;<\/em>\u0438 <em>X<\/em>, \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 <em>X<\/em>&nbsp;\u0438 <em>y<\/em>\u00bb, \u0433\u0434\u0435 <em>X&nbsp;<\/em>\u2014 \u044d\u0442\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0447\u043b\u0435\u043d \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f) \u0438 <em>y&nbsp;<\/em>\u2014 \u0432\u0435\u043a\u0442\u043e\u0440, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u0448\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <em>\u03b2&nbsp;<\/em>\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b. \u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435<\/p>\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-323376","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/323376","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=323376"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/323376\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=323376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=323376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=323376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}