{"id":210530,"date":"2014-01-27T23:11:03","date_gmt":"2014-01-27T19:11:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=210530"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=210530","title":{"rendered":"<span class=\"post_title\">\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 SARIMA \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python+R<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f <a href=\"http:\/\/habrahabr.ru\/post\/207160\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430<\/a> \u043f\u0440\u043e \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u043d\u0430 Python, \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043d\u043e \u043f\u0440\u0438 \u0438\u0445 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0440\u044f\u0434\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 ARIMA, \u0442.\u043a. \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430 \u043f\u0430\u043a\u0435\u0442\u0435 <a href=\"http:\/\/statsmodels.sourceforge.net\/stable\/index.html\">statsmodels<\/a> \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b. \u0412 \u0438\u0442\u043e\u0433\u0435 \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 <a href=\"http:\/\/r-project.org\/\">R<\/a>, \u0430 \u043f\u043e\u0438\u0441\u043a\u0438 \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043c\u0435\u043d\u044f \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <a href=\"http:\/\/rpy.sourceforge.net\/rpy2.html\">rpy2<\/a> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430.<br \/>  \u0423 \u043c\u043d\u043e\u0433\u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e?\u00bb, \u0432\u0435\u0434\u044c \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c <b>R<\/b> \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043d\u0435\u043c. \u042f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0433\u043b\u0430\u0441\u0435\u043d \u0441 \u044d\u0442\u0438\u043c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435\u043c, \u043d\u043e \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u043e \u0435\u0435 \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 <b>Python<\/b>, \u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 <b>R<\/b> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0434\u0430\u0447\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 R \u0432 <a href=\"http:\/\/ipython.org\/notebook.html\">IPython Notebook.<\/a><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 Rpy2<\/h4>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0442\u044c rpy2. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">pip install rpy2 <\/code><\/pre>\n<p>  \u041d\u0430\u0434\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0447\u0442\u043e, \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a <b>R<\/b>. \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441 <a href=\"http:\/\/www.r-project.org\/\">\u043e\u0444\u0444. \u0441\u0430\u0439\u0442\u0430<\/a>.<br \/>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435\u0435 \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u0414\u043b\u044f Windows \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:  <\/p>\n<ul>\n<li><i>PATH<\/i> \u2014 \u043f\u0443\u0442\u044c \u0434\u043e R.dll \u0438 \u0434\u043e R.exe  <\/li>\n<li><i>R_HOME<\/i> \u2014 \u043f\u0443\u0442\u044c \u0434\u043e \u043f\u0430\u043f\u043a\u0438 \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d R  <\/li>\n<li><i>R_USER<\/i> \u2014 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d windows  <\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u0430 Mac OS X, \u0442\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c.<\/p>\n<h4>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0432 <b>IPython Notebook<\/b>, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">%load_ext rmagic <\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u0442\u043e\u0440\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <b>R<\/b> \u0447\u0435\u0440\u0435\u0437 <i>rpy2<\/i>, \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u044f\u043c\u043e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c IPython Notebook, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e (\u043d\u0438\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c). \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e <a href=\"http:\/\/nbviewer.ipython.org\/github\/ipython\/ipython\/blob\/3607712653c66d63e0d7f13f073bde8c0f209ba8\/docs\/examples\/notebooks\/rmagic_extension.ipynb\">\u0437\u0434\u0435\u0441\u044c<\/a>.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c, \u043d\u0443\u0436\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">from pandas import read_csv, DataFrame, Series import statsmodels.api as sm import rpy2.robjects as R from rpy2.robjects.packages import importr import pandas.rpy.common as com from pandas import date_range <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043d\u0435\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c:<\/p>\n<pre><code class=\"python\">dataset = read_csv('DataSets\/tovar_moving.csv',';', index_col=['date'], parse_dates=['date'], dayfirst=True) otg = dataset.qty w = otg.resample('w', how='sum') w.plot(figsize=(12,6)) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/178\/381\/044\/178381044129ab253be51e6c54b32cf6.png\"\/><br \/>  \u0418\u0442\u0430\u043a, \u0438\u0437 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0435\u0436\u0435\u0433\u043e\u0434\u043d\u0443\u044e \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c (52 \u043d\u0435\u0434\u0435\u043b\u0438) \u0438 \u044f\u0440\u043a\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u044b\u0439 \u0442\u0440\u0435\u043d\u0434. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u0440\u0435\u043d\u0434\u0430 \u0438 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h4>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u0418\u0442\u0430\u043a \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043f\u0440\u043e\u043b\u043e\u0433\u043e\u0440\u0438\u0444\u043c\u0438\u0440\u0443\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0440\u044f\u0434, \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"python\">w_log = log(w) w_log.plot(figsize=(12,6)) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/682\/047\/eeb\/682047eeba8c441dabd70c913dc5bcd8.png\"\/><br \/>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u044f\u0434 \u043d\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u0435\u043d. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"http:\/\/ru.wikipedia.org\/wiki\/\u0422\u0435\u0441\u0442_\u0414\u0438\u043a\u0438_\u2014_\u0424\u0443\u043b\u043b\u0435\u0440\u0430\">\u0442\u0435\u0441\u0442\u0430 \u0414\u0438\u043a\u043a\u0438-\u0424\u0443\u043b\u0435\u0440\u0430<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0433\u0438\u043f\u043e\u0442\u0438\u0437\u0443 \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u0440\u043d\u0435\u0439 \u0438 \u0441\u043e\u043e\u0442\u0432\u0442\u0432\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c \u0440\u044f\u0434 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u043c. \u041a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <b>statsmodels<\/b>, \u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"http:\/\/www.inside-r.org\/packages\/cran\/tseries\/docs\/adf.test\">adf.test()<\/a> \u0438\u0437 <b>R<\/b>.<br \/>  \u0418\u0442\u0430\u043a, \u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 R-\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <a href=\"http:\/\/cran.r-project.org\/web\/packages\/tseries\/index.html\">tseries<\/a>. \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"http:\/\/rpy.sourceforge.net\/rpy2\/doc-dev\/html\/robjects_rpackages.html?highlight=importr#rpy2.robjects.packages.importr\">importr()<\/a>.<\/p>\n<pre><code class=\"python\">stats = importr('stats') tseries = importr('tseries') <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u0440\u043e\u043c\u0435 <i>tseries<\/i>, \u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0438 \u0435\u0449\u0435 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <i>stats<\/i>. \u041e\u043d\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f\u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0442\u0438\u043f\u0430 Python \u0432 \u0442\u0438\u043f \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 R. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"http:\/\/pandas.pydata.org\/pandas-docs\/stable\/r_interface.html\">convert_to_r_dataframe()<\/a> \u043d\u0430 \u0432\u0445\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0430\u0435\u0442\u0441\u044f DataFrame, \u0430 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f <i>\u0432\u0435\u043a\u0442\u043e\u0440 \u0434\u043b\u044f R<\/i>.<\/p>\n<pre><code class=\"python\">r_df = com.convert_to_r_dataframe(DataFrame(w_log)) <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u0432\u0435\u043a\u0442\u043e\u0440 \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0435\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 R \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-patched\/library\/stats\/html\/ts.html\">ts()<\/a>, \u0432\u044b\u0437\u043e\u0432 \u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">y = stats.ts(r_df) <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430 \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">ad = tseries.adf_test(y, alternative=&quot;stationary&quot;, k=52) <\/code><\/pre>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0440\u044f\u0434 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u0430\u0433\u043e\u0432, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0435\u0441\u0442. \u0412 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0431\u0440\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u043e\u0435 \u0433\u043e\u0434\u0443, \u0430 \u0442.\u043a. \u0434\u0430\u043d\u043d\u044b\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0436\u0435\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u044b\u0435, \u0430 \u0432 \u0433\u043e\u0434\u0443 52 \u043d\u0435\u0434\u0435\u043b\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 ad \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f R-\u043e\u0431\u044a\u0435\u043a\u0442. \u0415\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043d\u0435 \u043d\u0430\u0439\u0442\u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u043c \u0432\u0438\u0434\u0435:<\/p>\n<pre><code class=\"python\">a = ad.names[:5] {ad.names[i]:ad[i][0] for i in xrange(len(a))} <\/code><\/pre>\n<p>  {&#8216;alternative&#8217;: &#8216;stationary&#8217;,<br \/>   &#8216;method&#8217;: &#8216;Augmented Dickey-Fuller Test&#8217;,<br \/>   &#8216;p.value&#8217;: 0.23867869477446427,<br \/>   &#8216;parameter&#8217;: 52.0,<br \/>   &#8216;statistic&#8217;: -2.8030060277420006}<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u0430, \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0440\u044f\u0434 \u043d\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u0435\u043d. \u0422.\u043a. \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430 \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u0440\u043d\u0435\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0441 \u043c\u0430\u043b\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e, \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0440\u044f\u0434 \u043d\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u0435\u043d. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u0440\u044f\u0434 \u043f\u0435\u0440\u0432\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0435\u0439.<br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c ADF-\u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"python\">diff1lev = w.diff(periods=1).dropna() print 'p.value: %f' % sm.tsa.adfuller(diff1lev, maxlag=52)[1] <\/code><\/pre>\n<p>  p.value: 0.000000<\/p>\n<pre><code class=\"python\">diff1lev.plot(figsize=(12,6)) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/8c0\/481\/79f\/8c048179f290691125cb064d41c9fb7d.png\"\/><br \/>  \u0420\u044f\u0434 \u043f\u0435\u0440\u0432\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0435\u0439, \u043f\u043e \u0438\u0442\u043e\u0433\u0430\u043c \u0442\u0435\u0441\u0442\u0430, \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u044b\u043c. \u0410 \u0433\u0440\u0430\u0444\u0438\u043a \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043d\u0430\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0442\u0435\u043d\u0434\u0435\u043d\u0446\u0438\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0441\u0435\u0437\u043e\u043d\u043d\u0443\u044e \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c, \u043e\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u0440\u044f\u0434\u0430. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/onlinecourses.science.psu.edu\/stat510\/?q=node\/67\">\u0442\u0443\u0442<\/a>. \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u044f\u0434 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043c\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044f\u0437\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0435\u0432\u0443\u044e \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0435.<\/p>\n<pre><code class=\"python\">diff1lev_season = diff1lev.diff(52).dropna() <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0435\u0435 \u043d\u0430 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ADF-\u0442\u0435\u0441\u0442 \u0438\u0437 R:<\/p>\n<pre><code class=\"python\">r_df = com.convert_to_r_dataframe(DataFrame(diff1lev_season)) y = stats.ts(r_df) ad = tseries.adf_test(y, alternative=&quot;stationary&quot;, k=52) a = ad.names[:5] {ad.names[i]:ad[i][0] for i in xrange(len(a))} <\/code><\/pre>\n<p>  {&#8216;alternative&#8217;: &#8216;stationary&#8217;,<br \/>   &#8216;method&#8217;: &#8216;Augmented Dickey-Fuller Test&#8217;,<br \/>   &#8216;p.value&#8217;: 0.551977997289418,<br \/>   &#8216;parameter&#8217;: 52.0,<br \/>   &#8216;statistic&#8217;: -2.0581183466564776}<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0440\u044f\u0434 \u043d\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u0435\u043d, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0435\u0433\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"python\">diff1lev_season1lev = diff1lev_season.diff().dropna() print 'p.value: %f' % sm.tsa.adfuller(diff1lev_season1lev, maxlag=52)[1] <\/code><\/pre>\n<p>  p.value: 0.000395<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0440\u044f\u0434 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u0435\u043d. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<h4>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e <i>\u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 ARIMA<\/i> <b>(SARIMA)<\/b>.<br \/>  \u041e\u0431\u0449\u0438\u0439 \u0432\u0438\u0434 \u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 <img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-3d3eba8d8ec9c4bbd0b4583aebff1d60_l3.svg\"\/><br \/>  \u0412 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<ul>\n<li><img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-49efae298d9b9c6f2b8d9e8e6e3abb5c_l3.svg\"\/> \u2014 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0438 <img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-d97b4b16be57d923ab70bc68075c3bc6_l3.svg\"\/><\/li>\n<li><img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-3121693096bc69f82e965e9a02f27191_l3.svg\"\/> \u2014 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-edcf7df73b5ab2e301f916e1336b0120_l3.svg\"\/> \u2014 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0438 <img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-d7f7a5e200e943a5a059b3ce5374682d_l3.svg\"\/><\/li>\n<li><img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-f7b1ce2ffdc3faafc0a0d7a4af2161c6_l3.svg\"\/> \u2014 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 <img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-2968841cc07f4ea016af919eef449b2f_l3.svg\"\/><\/li>\n<li><img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-84dedb740a969f8a3cb7d7f181b57ebd_l3.svg\"\/> \u2014 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-b96dfe5bf806240042183cc7ca7d2d3c_l3.svg\"\/> \u2014 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 <img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-e27d1ff8c795d661b0c1a88e770ac69c_l3.svg\"\/><\/li>\n<li><img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-2eaf4a23b918e708fd8976dace2dca8b_l3.svg\"\/> \u2014 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438(\u043c\u0435\u0441\u044f\u0446, \u043a\u0432\u0430\u0440\u0442\u0430\u043b \u0438 \u0442.\u0434.)<\/li>\n<\/ul>\n<p>  \u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c <b>p<\/b>, <b>d<\/b>, <b>q<\/b>, \u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043e\u043f\u0438\u0448\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0435\u0437\u043e\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 <b>P<\/b>,<b>D<\/b>,<b>Q<\/b>.<br \/>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <b>D<\/b>. \u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438, \u0442.\u0435. \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u0440\u0430\u0432\u0435\u043d <b>1<\/b>. \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f <b>P<\/b> \u0438 <b>Q<\/b> \u043d\u0430\u043c \u043a\u0430\u043a \u0438 \u043f\u0440\u0435\u0436\u0434\u0435 \u043d\u0430\u0434\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043b\u043e\u0433\u0440\u0430\u043c\u043c\u044b <i>ACF<\/i> \u0438 <i>PACF<\/i>.<\/p>\n<pre><code class=\"python\">fig = plt.figure(figsize=(12,8)) ax1 = fig.add_subplot(211) fig = sm.graphics.tsa.plot_acf(diff1lev_season1lev.values.squeeze(), lags=150, ax=ax1) ax2 = fig.add_subplot(212) fig = sm.graphics.tsa.plot_pacf(diff1lev_season1lev, lags=150, ax=ax2) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/226\/229\/359\/2262293596cffa6ca0d9e2b430fb8e72.png\"\/><br \/>  \u0418\u0437 \u0433\u0430\u0440\u0444\u0438\u043a\u0430 <i>PACF<\/i> \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a AR \u0431\u0443\u0434\u0435\u0442 <b>p=4<\/b>, \u0430 \u043f\u043e <i>ACF<\/i> \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a MA <b>q = 13<\/b>, \u0442.\u043a. 13 \u043b\u0430\u0433 \u2014 \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043b\u0430\u0433 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u0442 0.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u0435\u0437\u043e\u043d\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u043c. \u0414\u043b\u044f \u0438\u0445 \u043e\u0446\u0435\u043d\u043a\u0438 \u043d\u0430\u0434\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043b\u0430\u0433\u0438 \u043a\u0440\u0430\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438, \u0442.\u0435., \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c 52, \u0442\u043e \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043b\u0430\u0433\u0438 52, 104, 156, &#8230;<br \/>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <b>P<\/b> \u0438 <b>Q<\/b> \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0432\u043d\u044b 0 (\u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 ACF \u0438 PACF \u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043b\u0430\u0433\u0430\u0445).<br \/>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0430\u0448\u0438\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c <img decoding=\"async\" src=\"http:\/\/computerscinece.ru\/wp-content\/ql-cache\/quicklatex.com-ea664646771d517a32af6b70768ae861_l3.svg\"\/><br \/>  \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0447\u0442\u043e \u043d\u0430\u0439\u0442\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 Python \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0438\u043d\u044f\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <a href=\"http:\/\/stat.ethz.ch\/R-manual\/R-patched\/library\/stats\/html\/arima.html\">arima()<\/a> \u0438\u0437 R. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0438 ARIMA \u0438, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439. \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043c \u043d\u0430\u0448 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 R \u0438 \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430.<\/p>\n<pre><code class=\"python\">r_df = com.convert_to_r_dataframe(DataFrame(w)) y = stats.ts(r_df) <\/code><\/pre>\n<p>  \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 R, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"python\">order = R.IntVector((4,1,13)) <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0435\u0435 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0435\u0440\u0438\u043e\u0434\u0430:<\/p>\n<pre><code class=\"python\">season = R.ListVector({'order': R.IntVector((0,1,0)), 'period' : 52}) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<pre><code class=\"python\">model = stats.arima(y, order = order, seasonal=season) <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0433\u043e\u0442\u043e\u0432\u0430 \u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u043d\u0430 \u0435\u0435 \u043e\u0441\u043d\u043e\u0432\u0435.<\/p>\n<h4>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438.<\/h4>\n<p>  \u0418\u0442\u0430\u043a \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0432\u0443\u044e\u0442 \u043b\u0438 \u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u00ab\u0431\u0435\u043b\u043e\u043c\u0443 \u0448\u0443\u043c\u0443\u00bb. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0434\u044f <a href=\"http:\/\/ru.wikipedia.org\/wiki\/Q-\u0442\u0435\u0441\u0442_\u041b\u044c\u044e\u043d\u0433\u0430_\u2014_\u0411\u043e\u043a\u0441\u0430\">Q-\u0442\u0435\u0441\u0442 \u041b\u044c\u044e\u043d\u0433\u0430 \u2014 \u0411\u043e\u043a\u0441\u0430<\/a> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044e \u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 R \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f tsdiag(), \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u0430\u0433\u043e\u0432 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430.<br \/>  \u0412\u044b\u0437\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">%Rpush model %R tsdiag(model, 100) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/862\/b05\/b55\/862b05b557d1baf2e03a330204de727c.png\"\/><br \/>  \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <b><i>%Rpush<\/i><\/b> \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 R. \u0418\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <b><i>%R<\/i><\/b> \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u0434 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u044f\u0437\u044b\u043a\u0430 R. \u0414\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 <b>IPython Notebook<\/b>.<br \/>  \u0418\u0437 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u0432\u044b\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b (\u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043f\u043e <i>ACF<\/i>). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0438\u0437 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 Q-\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0447\u0442\u043e \u0432\u043e \u0432\u0441\u0435\u0445 \u0442\u043e\u0447\u043a\u0430\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <i>p-value<\/i> \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u0438, \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u0442\u043a\u0438, \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u00ab\u0431\u0435\u043b\u044b\u043c \u0448\u0443\u043c\u043e\u043c\u00bb.<\/p>\n<h4>\u041f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0433\u043e\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"http:\/\/cran.r-project.org\/web\/packages\/forecast\/index.html\">forecast<\/a><\/p>\n<pre><code class=\"python\">forecast = importr('forecast') <\/code><\/pre>\n<p>  \u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u044b \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438.<\/p>\n<p>  <b>\u0421\u043f\u043e\u0441\u043e\u0431 1.<\/b> \u042d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 IPython \u0438 R. \u041a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435:<\/p>\n<pre><code class=\"python\">%R plot(forecast(model)) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/b23\/497\/7da\/b234977da1dab1918dd9756af48ff50b.png\"\/><\/p>\n<p>  <b>\u0421\u043f\u043e\u0441\u043e\u0431 2.<\/b> \u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 forecast, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441\u0435\u0440\u0438\u044e pandas \u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0438\u0445 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d. \u041a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"python\">f = forecast.forecast(model) #\u0441\u0442\u0440\u043e\u0438\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 pred = [i[1] for i in f[3].iteritems()] #\u043f\u0430\u0440\u0441\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 dt = date_range(w.index[-1], periods=len(pred)+1,freq='W')[1:] #\u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0437 \u0434\u0430\u0442 pr = Series(pred, index = dt)  #\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 TimeSeries <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d<\/p>\n<pre><code class=\"python\">w.plot(figsize=(12,6)) pr.plot(color = 'red') <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/b23\/497\/7da\/b234977da1dab1918dd9756af48ff50b.png\"\/><\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 7-10 \u0441\u0435\u0437\u043e\u043d\u0430\u043c\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0441\u043f\u0430\u0441\u0438\u0431\u043e <a href=\"http:\/\/habrahabr.ru\/users\/werwooolf\/\" class=\"user_link\">werwooolf<\/a> \u0437\u0430 \u043e\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u043f\u043e\u043c\u043e\u0449\u044c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0441\u0442\u0430\u0442\u044c\u0438.<br \/>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0435\u0437\u043e\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c ARIMA, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u043a\u0443 \u044f\u0437\u044b\u043a\u043e\u0432 <b>R<\/b> \u0438 <b>Python<\/b> \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u042f \u0434\u0443\u043c\u0430\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u044b \u0438 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u043f\u043e\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u044f\u0437\u044b\u043a\u0443 \u043d\u0430\u0439\u0434\u0443\u0442 \u043a\u0430\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u043a\u0443.    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/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=\"http:\/\/habrahabr.ru\/post\/210530\/\"> http:\/\/habrahabr.ru\/post\/210530\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438.<br \/>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f <a href=\"http:\/\/habrahabr.ru\/post\/207160\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430<\/a> \u043f\u0440\u043e \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u043d\u0430 Python, \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043d\u043e \u043f\u0440\u0438 \u0438\u0445 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0440\u044f\u0434\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 ARIMA, \u0442.\u043a. \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430 \u043f\u0430\u043a\u0435\u0442\u0435 <a href=\"http:\/\/statsmodels.sourceforge.net\/stable\/index.html\">statsmodels<\/a> \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b. \u0412 \u0438\u0442\u043e\u0433\u0435 \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 <a href=\"http:\/\/r-project.org\/\">R<\/a>, \u0430 \u043f\u043e\u0438\u0441\u043a\u0438 \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043c\u0435\u043d\u044f \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <a href=\"http:\/\/rpy.sourceforge.net\/rpy2.html\">rpy2<\/a> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430.<br \/>  \u0423 \u043c\u043d\u043e\u0433\u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e?\u00bb, \u0432\u0435\u0434\u044c \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c <b>R<\/b> \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043d\u0435\u043c. \u042f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0433\u043b\u0430\u0441\u0435\u043d \u0441 \u044d\u0442\u0438\u043c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435\u043c, \u043d\u043e \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u043e \u0435\u0435 \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 <b>Python<\/b>, \u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 <b>R<\/b> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0434\u0430\u0447\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 R \u0432 <a href=\"http:\/\/ipython.org\/notebook.html\">IPython Notebook.<\/a>  <\/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-210530","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/210530","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=210530"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/210530\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=210530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=210530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=210530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}