{"id":276286,"date":"2016-03-16T18:20:03","date_gmt":"2016-03-16T15:20:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=276286"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=276286","title":{"rendered":"\u041b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438: \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f"},"content":{"rendered":"<p>       \u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/278513\/\">\u043c\u043d\u043e\u0433\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/a>. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043e\u0442 \u0442\u0435\u043e\u0440\u0438\u0438 \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u0430\u043c\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u0443\u044e, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043b\u0435\u0433\u043a\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a \u0441\u0432\u043e\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0430\u043c. \u041c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043a\u043e\u0434\u043e\u043c \u043d\u0430 R \u0438 Python, \u043f\u0440\u0438\u0447\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0432 \u0442\u0440\u0435\u0445 \u0430\u0440\u043e\u043c\u0430\u0442\u0430\u0445: scikit-learn, statsmodels \u0438 Patsy.<a name=\"habracut\"><\/a><\/p>\n<h4><b>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0430\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/b><\/h4>\n<p>  \u041f\u0443\u0441\u0442\u044c \u043d\u0430\u043c \u0434\u0430\u043d\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438 <i>x1<\/i>, <i>x2<\/i>, <i>x3<\/i> \u0438 <i>y<\/i>. \u0418 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 <i>y<\/i> \u043e\u0442 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 <i>x<\/i>, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<br \/>  <i>y = b<sub>0<\/sub> + b<sub>1<\/sub> x<sub>1<\/sub> + b<sub>2<\/sub> x<sub>2<\/sub> + b<sub>3<\/sub> x<sub>3<\/sub> + \u2107<\/i><br \/>  \u0433\u0434\u0435 <i>x<\/i>, <i>y<\/i> \u2014 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, <i>b<\/i> \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u0438, <i>\u2107<\/i> \u2014 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430.<br \/>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <i>\u0445<\/i> \u0438 <i>y<\/i> \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c, \u0442\u043e \u043d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0441\u0447\u0435\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 <i>b<\/i>.<br \/>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u0432\u0432\u0435\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <i>b<sub>0<\/sub><\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <i>intercept<\/i>, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442. \u0415\u0441\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0442\u043e \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.<br \/>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e <i>\u2107<\/i> \u2014 \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041a\u0430\u043a\u043e\u0439 \u043f\u043e\u043f\u0430\u043b\u043e \u043c\u0435\u0442\u043e\u0434 \u043c\u044b \u043d\u0435 \u0438\u043c\u0435\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0440\u0438\u0441\u043a\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u00ab\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0430\u044f\u00bb \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \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 (\u041e\u041d\u041a).  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 R<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 df &lt;- read.csv(&quot;http:\/\/roman-kh.github.io\/files\/linear-models\/simple1.csv&quot;) # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 # \u043c\u043e\u0434\u0435\u043b\u044c glm \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 intercept, \u044f\u0432\u043d\u043e \u0435\u0433\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f g &lt;- glm(&quot;y ~ x1 + x2 + x3&quot;, data=df) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438 coef(g) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 Python: \u043e\u0431\u0449\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import numpy as np import pandas as pd import statsmodels.api as sm import patsy as pt import sklearn.linear_model as lm  # \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 df = pd.DataFrame.from_csv(&quot;http:\/\/roman-kh.github.io\/files\/linear-models\/simple1.csv&quot;) # x - \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 (x1, x2, x3) x = df.iloc[:,:-1] # y - \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 y = df.iloc[:,-1] <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 Python: scikit-learn<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"># \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c skm = lm.LinearRegression() # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 skm.fit(x, y) # \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 print skm.intercept_, skm.coef_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 Python: statsmodels<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"># \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 intercept'\u0430 x_ = sm.add_constant(x) # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \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 (Ordinary Least Squares) smm = sm.OLS(y, x_) # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 res = smm.fit() # \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 print res.params <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 Python: statsmodels \u0441 \u0444\u043e\u0440\u043c\u0443\u043b\u0430\u043c\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u0441 R \u043d\u0430 Python, \u043c\u043d\u043e\u0433\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0441\u043e statsmodels, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 R&#8217;\u043e\u0432\u0441\u043a\u0438\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b:  <\/p>\n<pre><code class=\"python\"># \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b smm = sm.OLS.from_formula(&quot;y ~ x1 + x2 + x3&quot;, data=df) # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 res = smm.fit() # \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 print res.params <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 Python: Patsy + numpy<\/b><\/p>\n<div class=\"spoiler_text\">\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Patsy \u0432\u044b \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c R-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0432 \u043b\u044e\u0431\u043e\u0439 \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435:  <\/p>\n<pre><code class=\"python\"># \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0438\u0437 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u0430 pt_y, pt_x = pt.dmatrices(&quot;y ~ x1 + x2 + x3&quot;, df) # \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e numpy'\u0432\u0441\u043a\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e \u041c\u041d\u041a # \u043a\u0441\u0442\u0430\u0442\u0438, \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0435 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 LinearRegression \u0438\u0437 scikit-learn \u0434\u043b\u044f \u043d\u0435\u0440\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 # \u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f scipy.sparse.linalg.lsqr res = np.linalg.lstsq(pt_x, pt_y) # \u0434\u043e\u0441\u0442\u0430\u0435\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438 b = res[0].ravel() print b <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0434\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0418 \u044d\u0442\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e. \u0412\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b (\u041e\u041d\u041a, OLS) \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u0443\u043a\u043b\u044b\u043c, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u043c\u0435\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u0438 \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c.<br \/>  \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u0430\u0436\u0435 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0445\u043e\u0442\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0436\u0438\u0437\u043d\u044c \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0438 \u043f\u0440\u0438\u0440\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u0436\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e\u0439, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u0432\u0435\u0434\u044c \u043f\u043e \u0438\u0434\u0435\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<h4><b>\u0418\u0437\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435<\/b><\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0443\u0436\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c\u2026 \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043c\u044b \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u0438 \u043d\u0435 \u043e\u0434\u043d\u0443. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043d\u0435 \u0438\u0437\u0443\u0447\u0438\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0437\u0430 \u043c\u043e\u0434\u0435\u043b\u044c, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0447\u0435\u0433\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u0435 \u0436\u0435 \u0437\u0430\u0433\u043b\u044f\u043d\u0435\u043c \u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u0442\u0430\u043c \u0435\u0441\u0442\u044c.<br \/>  \u041a\u0430\u043a \u0432\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0431\u044b\u043b\u043e 4 \u0441\u0442\u043e\u043b\u0431\u0446\u0430: <i>x1<\/i>, <i>x2<\/i>, <i>x3<\/i> \u0438 <i>y<\/i>. \u0418 \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c <i>y<\/i> \u043e\u0442 \u0432\u0441\u0435\u0445 <i>x<\/i>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u0434\u043d\u0438\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u043e\u043c \u0441\u0440\u0430\u0437\u0443 \u043e\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0432\u0435\u0441\u044c 4-\u043c\u0435\u0440\u043d\u044b\u0439 \u0433\u0438\u043f\u0435\u0440\u043a\u0443\u0431, \u0442\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 <i>x-y<\/i>.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/315\/0b0\/cd4\/3150b0cd4bb0442b80450abc7d621376.png\"\/><br \/>  \u0421\u0440\u0430\u0437\u0443 \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 <i>x3<\/i> \u2014 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u2014 \u0430 \u0441 \u043d\u0438\u043c\u0438 \u0441\u0442\u043e\u0438\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 <i>x<\/i> \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 <i>x3<\/i>.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1d8\/5c0\/395\/1d85c0395f054184ac0ecc97be4c8afb.png\"\/><br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u0418 \u0442\u0443\u0442 \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u2014 \u044d\u0442\u043e \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u043b\u0438\u043d\u0438\u044f, \u0430 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0440\u0435\u0437 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0433\u0438\u043f\u0435\u0440\u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u0445 <i>x1<\/i>&#8212;<i>y<\/i> \u043d\u0430\u0434\u043e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <i>x2<\/i> \u0438 <i>x3<\/i>, \u0430, \u043c\u0435\u043d\u044f\u044f \u0438\u0445, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u2014 \u0438 \u0432\u0441\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 (\u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0435\u0439 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u044c <i>x1<\/i>&#8212;<i>y<\/i>).<br \/>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <i>x3<\/i> \u2014 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u2014 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043b\u0438\u043d\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u0430 <i>x1<\/i> \u0438 <i>x2<\/i> \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0440\u0438\u0441\u0443\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0438 y=f(x1&nbsp;|&nbsp;x2=E(x2)) \u0438 y=f(x2&nbsp;|&nbsp;x1=E(x1)), \u0433\u0434\u0435 E \u2014 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e \u0432\u0441\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c x1 \u0438 x2 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b03\/56e\/466\/b0356e4665774ecd8412146f487a7b7f.png\"\/><br \/>  \u0418 \u0441\u0440\u0430\u0437\u0443 \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430, \u0447\u0442\u043e \u0433\u0440\u0430\u0444\u0438\u043a <i>y~x2<\/i> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a-\u0442\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u041f\u043e\u043c\u043d\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 <i>y<\/i>, \u0442\u0443\u0442 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0441\u043e\u043e\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u0433\u043e\u043b\u0443\u0431\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0438\u0436\u0435 \u0433\u043e\u043b\u0443\u0431\u043e\u0439 \u043b\u0438\u043d\u0438\u0438, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u2014 \u0432\u044b\u0448\u0435, \u043f\u0440\u0438\u0447\u0435\u043c \u0443 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0432\u0441\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0445\u043e\u0442\u044f \u043e\u0431\u0435 \u043b\u0438\u043d\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u0441\u0440\u0435\u0434\u0438\u043d\u0435 \u043e\u0431\u043b\u0430\u043a\u0430 \u0442\u043e\u0447\u0435\u043a.<br \/>  \u041f\u0440\u0438\u0433\u043b\u044f\u0434\u0435\u0432\u0448\u0438\u0441\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0433\u043e\u043b\u0443\u0431\u0430\u044f \u0438 \u043a\u0440\u0430\u0441\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0434\u0430\u0436\u0435 \u043d\u0435\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b. \u041a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438? \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c <i>\u0443=f(x1,x2,x3)<\/i> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u0438\u043d\u0438\u0439 \u0432\u0438\u0434\u0430 <i>y=f(x2 | x1,x3)<\/i>, \u0442\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0432 \u0434\u0432\u0435 \u0438\u0437 \u0442\u0440\u0435\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0422\u0430\u043a, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u043a\u0440\u0430\u0441\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u044f <i>\u0443=f(x2&nbsp;|&nbsp;x1=E(x),&nbsp;x3=0)<\/i> \u0438 \u0433\u043e\u043b\u0443\u0431\u0430\u044f <i>\u0443=f(x2&nbsp;|&nbsp;x1=E(x),&nbsp;x3=1)<\/i> \u043d\u0430 \u043f\u0440\u0430\u0432\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u0441\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043b\u0438\u043d\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b.<\/p>\n<h4><b>\u041d\u0435\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0430\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c<\/b><\/h4>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0432\u043d\u0435\u0441\u0442\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043c \u0435\u0435, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0435:<br \/>  <i>y = b<sub>0<\/sub> + b<sub>1<\/sub> x<sub>1<\/sub> + b<sub>2<\/sub> x<sub>2<\/sub> + b<sub>3<\/sub> x<sub>3<\/sub> + <b>b<sub>4<\/sub> x<sub>2<\/sub> x<sub>3<\/sub><\/b> + \u2107<\/i><br \/>  \u041a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442? \u0420\u0430\u043d\u044c\u0448\u0435 \u043b\u044e\u0431\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 <i>y~x<sub>2<\/sub><\/i> \u0438\u043c\u0435\u043b\u0430 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043d\u0430\u043a\u043b\u043e\u043d, \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u043c <i>b<sub>2<\/sub><\/i>. \u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <i>x<sub>3<\/sub><\/i> \u043b\u0438\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0430\u043a\u043b\u043e\u043d <i>b<sub>2<\/sub><\/i> (\u0434\u043b\u044f <i>x<sub>3<\/sub>=0<\/i>) \u0438\u043b\u0438 <i>b<sub>2<\/sub>+b<sub>4<\/sub><\/i> (\u0434\u043b\u044f <i>x<sub>3<\/sub>=1<\/i>).  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 R<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"># \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 df &lt;- read.csv(&quot;http:\/\/roman-kh.github.io\/files\/linear-models\/simple1.csv&quot;) # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 # \u043c\u043e\u0434\u0435\u043b\u044c glm \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 intercept, \u044f\u0432\u043d\u043e \u0435\u0433\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f g &lt;- glm(&quot;y ~ x1 + x2 + x3 + x2*x3&quot;, data=df) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438 coef(g) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 Python: \u043e\u0431\u0449\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">import numpy as np import pandas as pd import statsmodels.api as sm import patsy as pt import sklearn.linear_model as lm  # \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 df = pd.DataFrame.from_csv(&quot;http:\/\/roman-kh.github.io\/files\/linear-models\/simple1.csv&quot;) # x - \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 (x1, x2, x3) x = df.iloc[:,:-1] # y - \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 y = df.iloc[:,-1] <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 Python: scikit-learn<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"># \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u043a\u0442\u043e\u0440 x[&quot;x4&quot;] = x[&quot;x2&quot;] * x[&quot;x3&quot;]  # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c skm = lm.LinearRegression() # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 skm.fit(x, y) # \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 print skm.intercept_, skm.coef_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 Python: statsmodels<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"># \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u043a\u0442\u043e\u0440 x[&quot;x4&quot;] = x[&quot;x2&quot;] * x[&quot;x3&quot;]  # \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 intercept'\u0430 x_ = sm.add_constant(x) # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \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 (Ordinary Least Squares) smm = sm.OLS(y, x_) # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 res = smm.fit() # \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 print res.params <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 Python: statsmodels \u0441 \u0444\u043e\u0440\u043c\u0443\u043b\u0430\u043c\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u0441 R \u043d\u0430 Python, \u043c\u043d\u043e\u0433\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0441\u043e statsmodels, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 R&#8217;\u043e\u0432\u0441\u043a\u0438\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b:  <\/p>\n<pre><code class=\"python\"># \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b smm = sm.OLS.from_formula(&quot;y ~ x1 + x2 + x3 + x2*x3&quot;, data=df) # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 res = smm.fit() # \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 print res.params <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 Python: Patsy + numpy<\/b><\/p>\n<div class=\"spoiler_text\">\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Patsy \u0432\u044b \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c R-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0432 \u043b\u044e\u0431\u043e\u0439 \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435:  <\/p>\n<pre><code class=\"python\"># \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0438\u0437 \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u0430 pt_y, pt_x = pt.dmatrices(&quot;y ~ x1 + x2 + x3 + x2*x3&quot;, df) # \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e numpy'\u0432\u0441\u043a\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e \u041c\u041d\u041a # \u043a\u0441\u0442\u0430\u0442\u0438, \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0435 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 LinearRegression \u0438\u0437 scikit-learn \u0434\u043b\u044f \u043d\u0435\u0440\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 # \u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f scipy.sparse.linalg.lsqr res = np.linalg.lstsq(pt_x, pt_y) # \u0434\u043e\u0441\u0442\u0430\u0435\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438 b = res[0].ravel() print b <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/18d\/192\/365\/18d1923656b7485685faf6a114793b02.png\"\/><br \/>  \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435! <\/p>\n<p>  \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u0435\u043c \u2014 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u2014 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439\u043d\u044b\u0439 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e \u0441\u0443\u0442\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u043c\u0443\u0436\u0447\u0438\u043d \u0438 \u0436\u0435\u043d\u0449\u0438\u043d, \u0440\u044f\u0434\u043e\u0432\u044b\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432, \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439, \u0440\u043e\u043a \u0438\u043b\u0438 \u043f\u043e\u043f-\u043c\u0443\u0437\u044b\u043a\u0438). \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439\u043d\u044b\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432.<\/p>\n<p>  \u041f\u043e\u0434\u0432\u043e\u0434\u0438\u043c \u0438\u0442\u043e\u0433: \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u043f\u0443\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435 \u0432\u0435\u0441\u044c\u043c\u0430 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u0441\u0443\u0434\u044f \u043f\u043e \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u043c, \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u0441\u0435 \u044d\u0442\u0438 \u00ab\u0432\u0435\u0441\u044c\u043c\u0430\u00bb \u0438 \u00ab\u043d\u0435\u043f\u043b\u043e\u0445\u043e\u00bb \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0438\u0437\u043c\u0435\u0440\u0438\u043c\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430\u0445. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043a\u0430 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u0430 \u043a \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043a \u0432\u0437\u0430\u0438\u043c\u043e\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0444\u0430\u043a\u0442\u043e\u0440\u0430\u043c\u0438). \u041a \u044d\u0442\u0438\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c \u043c\u044b \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f.               <\/p>\n<div class=\"clear\"><\/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:\/\/habrahabr.ru\/post\/279117\/\"> https:\/\/habrahabr.ru\/post\/279117\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/278513\/\">\u043c\u043d\u043e\u0433\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/a>. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043e\u0442 \u0442\u0435\u043e\u0440\u0438\u0438 \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u0430\u043c\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u0443\u044e, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043b\u0435\u0433\u043a\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a \u0441\u0432\u043e\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0430\u043c. \u041c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043a\u043e\u0434\u043e\u043c \u043d\u0430 R \u0438 Python, \u043f\u0440\u0438\u0447\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0432 \u0442\u0440\u0435\u0445 \u0430\u0440\u043e\u043c\u0430\u0442\u0430\u0445: scikit-learn, statsmodels \u0438 Patsy.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-276286","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/276286","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=276286"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/276286\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=276286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=276286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=276286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}