{"id":358433,"date":"2024-05-21T00:11:45","date_gmt":"2024-05-21T00:11:45","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=358433"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=358433","title":{"rendered":"<span>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438 \u0432 Python. \u0427\u0430\u0441\u0442\u044c 2<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/av\/um\/lx\/avumlxbj7dsulhw61puxdpfh6mq.png\" data-src=\"https:\/\/habrastorage.org\/webt\/av\/um\/lx\/avumlxbj7dsulhw61puxdpfh6mq.png\"\/><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432\u043e \u0432\u0442\u043e\u0440\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043d\u0430\u0448\u0435\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 &#171;<i>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438 \u0432 Python.<\/i>&#187; <a href=\"https:\/\/habr.com\/ru\/companies\/mvideo\/articles\/769190\/\">\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>, \u043c\u044b \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u043e\u0441\u043d\u043e\u0432\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438 \u0438 \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u0430\u043c \u044d\u0442\u043e\u0439 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0435\u043c\u044b.<a name=\"habracut\"><\/a><\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u0447\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043a\u0443, \u0444\u0438\u043d\u0430\u043d\u0441\u044b \u0438 \u0434\u0430\u0436\u0435 \u043f\u043e\u0433\u043e\u0434\u0443. \u042d\u0442\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u041f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0433\u043e\u0434\u044b<\/h3>\n<p>  \u041f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0433\u043e\u0434\u044b \u2014 \u044d\u0442\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0432\u0430\u0436\u043d\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u0433\u0434\u0435 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0438\u0433\u0440\u0430\u0435\u0442 \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b.<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Dataset<\/h4>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c dataset \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0435 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043b\u0435\u0442.<\/p>\n<pre><code class=\"python\"># \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0430\u0442\u044b \u0441 \u044f\u043d\u0432\u0430\u0440\u044f 2020 \u0433\u043e\u0434\u0430 \u043f\u043e \u0434\u0435\u043a\u0430\u0431\u0440\u044c 2022 \u0433\u043e\u0434\u0430 dates = pd.date_range(start='2020-01-01', end='2022-12-31', freq='D')  # \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b temperature = np.random.normal(loc=25, scale=5, size=len(dates))  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c DataFrame temperature_df = pd.DataFrame({'\u0414\u0430\u0442\u0430': dates, '\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430': temperature})  # \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c '\u0414\u0430\u0442\u0430' \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 temperature_df.set_index('\u0414\u0430\u0442\u0430', inplace=True)  # \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a print(temperature_df.head())<\/code><\/pre>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/b><\/p>\n<pre><code class=\"plaintext\">            \u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0414\u0430\u0442\u0430                    2020-01-01    28.070296 2020-01-02    22.618478 2020-01-03    37.671305 2020-01-04    24.559199 2020-01-05    21.579757<\/code><\/pre>\n<p>  <\/p>\n<h4>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0438\u0445 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443.<\/p>\n<pre><code class=\"python\"># \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0433\u0440\u0430\u0444\u0438\u043a \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b plt.figure(figsize=(12, 6)) plt.plot(temperature_df.index, temperature_df['\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430'], linestyle='-') plt.title('\u0421\u0440\u0435\u0434\u043d\u044f\u044f \u0434\u043d\u0435\u0432\u043d\u0430\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430') plt.xlabel('\u0414\u0430\u0442\u0430') plt.ylabel('\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 (\u00b0C)') plt.grid(True) plt.show()<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/tp\/pa\/no\/tppano0ca_3rce_xu51c8di1-te.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/tp\/pa\/no\/tppano0ca_3rce_xu51c8di1-te.jpeg\" data-blurred=\"true\"\/><\/p>\n<h4>\u0412\u044b\u0431\u043e\u0440 \u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/h4>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0433\u043e\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c SARIMA.<\/p>\n<pre><code class=\"python\">from statsmodels.tsa.statespace.sarimax import SARIMAX  # \u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 SARIMA model = SARIMAX(temperature_df['\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430'], order=(1, 1, 1), seasonal_order=(1, 1, 1, 7)) model_fit = model.fit()  # \u0412\u044b\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 print(model_fit.summary())<\/code><\/pre>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/b><\/p>\n<pre><code class=\"plaintext\">                                     SARIMAX Results                                      ========================================================================================= Dep. Variable:                       \u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430   No. Observations:                 1096 Model:             SARIMAX(1, 1, 1)x(1, 1, 1, 7)   Log Likelihood               -3302.692 Date:                           Mon, 18 Sep 2023   AIC                           6615.384 Time:                                   12:26:34   BIC                           6640.344 Sample:                               01-01-2020   HQIC                          6624.832                                     - 12-31-2022                                          Covariance Type:                             opg                                          ==============================================================================                  coef    std err          z      P>|z|      [0.025      0.975] ------------------------------------------------------------------------------ ar.L1          0.0297      0.033      0.899      0.368      -0.035       0.094 ma.L1         -0.9926      0.005   -182.224      0.000      -1.003      -0.982 ar.S.L7        0.0148      0.033      0.446      0.655      -0.050       0.080 ma.S.L7       -0.9862      0.012    -79.419      0.000      -1.011      -0.962 sigma2        24.5744      1.054     23.311      0.000      22.508      26.641 =================================================================================== Ljung-Box (L1) (Q):                   0.00   Jarque-Bera (JB):                 0.36 Prob(Q):                              0.97   Prob(JB):                         0.84 Heteroskedasticity (H):               0.96   Skew:                             0.04 Prob(H) (two-sided):                  0.69   Kurtosis:                         3.05 ===================================================================================<\/code><\/pre>\n<p>  <\/p>\n<h4>\u041e\u0446\u0435\u043d\u043a\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430<\/h4>\n<p>  \u041e\u0446\u0435\u043d\u043a\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a MSE \u0438 MAE.<\/p>\n<pre><code class=\"python\"># \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e from sklearn.metrics import mean_squared_error, mean_absolute_error  # \u041f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 forecast = model_fit.forecast(steps=7)  # \u0420\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c MSE \u0438 MAE mse = mean_squared_error(temperature_df['\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430'][-7:], forecast) mae = mean_absolute_error(temperature_df['\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430'][-7:], forecast)  print(f'MSE: {mse}') print(f'MAE: {mae}')<\/code><\/pre>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/b><\/p>\n<pre><code class=\"plaintext\">MSE: 10.43521389383251 MAE: 2.4818868765063735<\/code><\/pre>\n<p>  <\/p>\n<h4>\u041f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 7 \u0434\u043d\u0435\u0439.<\/p>\n<pre><code class=\"python\"># \u041f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435 (\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 7 \u0434\u043d\u0435\u0439) forecast_future = model_fit.get_forecast(steps=7)   # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 DataFrame \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 future_dates = pd.date_range(start='2022-12-31', periods=7, freq='D') + pd.DateOffset(days=1) forecast_df = pd.DataFrame({'\u0414\u0430\u0442\u0430': future_dates, '\u041f\u0440\u043e\u0433\u043d\u043e\u0437 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b': forecast_future.predicted_mean})   # \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 DataFrame temperature_df = temperature_df.append(forecast_df)   # \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 plt.figure(figsize=(12, 6)) plt.plot(temperature_df.index[:-7], temperature_df['\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430'][:-7], label='\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435') plt.plot(temperature_df.index[-7:], temperature_df['\u041f\u0440\u043e\u0433\u043d\u043e\u0437 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b'][-7:], label='\u041f\u0440\u043e\u0433\u043d\u043e\u0437') plt.title('\u041f\u0440\u043e\u0433\u043d\u043e\u0437 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b') plt.xlabel('\u0414\u0430\u0442\u0430') plt.ylabel('\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 (\u00b0C)') plt.legend() plt.grid(True) plt.show() <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/oi\/l6\/2l\/oil62lcotcbj6horyasikxbc_xs.png\" data-src=\"https:\/\/habrastorage.org\/webt\/oi\/l6\/2l\/oil62lcotcbj6horyasikxbc_xs.png\"\/><\/p>\n<h3>\u041f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0430 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0435<\/h3>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0435.<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Dataset<\/h4>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c dataset \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u043c \u0442\u0440\u0430\u0444\u0438\u043a\u0435 \u043d\u0430 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0435.<\/p>\n<pre><code class=\"python\">import pandas as pd import numpy as np import matplotlib.pyplot as plt  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0434\u0430\u0442\u044b dates = pd.date_range(start='2020-01-01', end='2022-12-31', freq='D')  # \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439 traffic = np.random.randint(1000, 5000, size=len(dates))  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c DataFrame traffic_df = pd.DataFrame({'\u0414\u0430\u0442\u0430': dates, '\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0438': traffic})  # \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c '\u0414\u0430\u0442\u0430' \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 traffic_df.set_index('\u0414\u0430\u0442\u0430', inplace=True)  # \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a print(traffic_df.head())<\/code><\/pre>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/b><\/p>\n<pre><code class=\"plaintext\">            \u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0438 \u0414\u0430\u0442\u0430                   2020-01-01        3776 2020-01-02        3641 2020-01-03        4092 2020-01-04        2057 2020-01-05        1936<\/code><\/pre>\n<p>  <\/p>\n<h4>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0435 \u043d\u0430 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438\u0445 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443.<\/p>\n<pre><code class=\"python\"># \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0433\u0440\u0430\u0444\u0438\u043a \u0442\u0440\u0430\u0444\u0438\u043a\u0430 plt.figure(figsize=(12, 6)) plt.plot(traffic_df.index, traffic_df['\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0438'], linestyle='-') plt.title('\u0422\u0440\u0430\u0444\u0438\u043a \u043d\u0430 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0435') plt.xlabel('\u0414\u0430\u0442\u0430') plt.ylabel('\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0438') plt.grid(True) plt.show()<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/ly\/at\/ip\/lyatip_dppx09vkkbsoszmyah1g.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/ly\/at\/ip\/lyatip_dppx09vkkbsoszmyah1g.jpeg\" data-blurred=\"true\"\/><\/p>\n<h4>\u0412\u044b\u0431\u043e\u0440 \u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/h4>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0430 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c ARIMA.<\/p>\n<pre><code class=\"python\">from statsmodels.tsa.arima.model import ARIMA # \u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 ARIMA model = ARIMA(traffic_df['\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0438'], order=(1, 1, 1)) model_fit = model.fit()  # \u0412\u044b\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 print(model_fit.summary())<\/code><\/pre>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/b><\/p>\n<pre><code class=\"plaintext\">                               SARIMAX Results                                 ============================================================================== Dep. Variable:             \u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0438   No. Observations:                 1096 Model:                 ARIMA(1, 1, 1)   Log Likelihood               -9283.888 Date:                Mon, 18 Sep 2023   AIC                          18573.776 Time:                        12:36:37   BIC                          18588.771 Sample:                    01-01-2020   HQIC                         18579.450                          - 12-31-2022                                          Covariance Type:                  opg                                          ==============================================================================                  coef    std err          z      P>|z|      [0.025      0.975] ------------------------------------------------------------------------------ ar.L1         -0.0158      0.030     -0.524      0.601      -0.075       0.043 ma.L1         -1.0000      0.067    -14.838      0.000      -1.132      -0.868 sigma2      1.346e+06      5e-08   2.69e+13      0.000    1.35e+06    1.35e+06 =================================================================================== Ljung-Box (L1) (Q):                   0.00   Jarque-Bera (JB):                65.30 Prob(Q):                              0.97   Prob(JB):                         0.00 Heteroskedasticity (H):               0.99   Skew:                            -0.02 Prob(H) (two-sided):                  0.94   Kurtosis:                         1.80 ===================================================================================<\/code><\/pre>\n<p>  <\/p>\n<h4>\u041e\u0446\u0435\u043d\u043a\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430<\/h4>\n<p>  \u041e\u0446\u0435\u043d\u043a\u0430 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a MSE \u0438 MAE.<\/p>\n<pre><code class=\"python\"># \u041f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 forecast = model_fit.forecast(steps=7)  # \u0420\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c MSE \u0438 MAE mse = mean_squared_error(traffic_df['\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0438'][-7:], forecast) mae = mean_absolute_error(traffic_df['\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0438'][-7:], forecast)  print(f'MSE: {mse}') print(f'MAE: {mae}')<\/code><\/pre>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/b><\/p>\n<pre><code class=\"plaintext\">MSE: 836944.4441271863 MAE: 818.829661603483<\/code><\/pre>\n<h1>\u041f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432<\/h1>\n<p>  \u0410\u043d\u0430\u043b\u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438, \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c\u0438, \u0441\u0435\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u043b\u0438 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u044b\u043c\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438. <\/p>\n<h3>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u044f\u0434\u044b \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438<\/h3>\n<p>  \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0441 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c\u0438. \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u044f\u0434\u044b \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043c\u0435\u0434\u0438\u0446\u0438\u043d\u0441\u043a\u0438\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445, \u0433\u0434\u0435 \u043f\u0430\u0446\u0438\u0435\u043d\u0442\u044b \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0441\u0432\u043e\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0434\u0430\u0436 \u0432 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u043c \u0444\u0438\u043b\u0438\u0430\u043b\u0435 \u041c\u0412\u0438\u0434\u0435\u043e. <\/p>\n<pre><code class=\"python\">import pandas as pd import numpy as np  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c dataset \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438 sales_data = {'\u0414\u0430\u0442\u0430': pd.to_datetime(['2023-01-01', '2023-01-03', '2023-01-05', '2023-01-10']),               '\u041f\u0440\u043e\u0434\u0430\u0436\u0438': [100, 150, 80, 200]} sales_df = pd.DataFrame(sales_data)  # \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c '\u0414\u0430\u0442\u0430' \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 sales_df.set_index('\u0414\u0430\u0442\u0430', inplace=True)<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u044f\u0434 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438. \u041a\u0430\u043a \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435? \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0445 \u0431\u043e\u043b\u0435\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"python\"># \u041f\u0435\u0440\u0435\u0441\u0435\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 sales_df_resampled = sales_df.resample('D').asfreq()  # \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0435\u0439 sales_df_interpolated = sales_df_resampled.interpolate(method='linear')  # \u0412\u044b\u0432\u043e\u0434 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 print(sales_df_interpolated)<\/code><\/pre>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/b><\/p>\n<pre><code class=\"plaintext\">                               SARIMAX Results                                 ============================================================================== Dep. Variable:             \u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0438   No. Observations:                 1096 Model:                 ARIMA(1, 1, 1)   Log Likelihood               -9283.888 Date:                Mon, 18 Sep 2023   AIC                          18573.776 Time:                        12:36:37   BIC                          18588.771 Sample:                    01-01-2020   HQIC                         18579.450                          - 12-31-2022                                          Covariance Type:                  opg                                          ==============================================================================                  coef    std err          z      P>|z|      [0.025      0.975] ------------------------------------------------------------------------------ ar.L1         -0.0158      0.030     -0.524      0.601      -0.075       0.043 ma.L1         -1.0000      0.067    -14.838      0.000      -1.132      -0.868 sigma2      1.346e+06      5e-08   2.69e+13      0.000    1.35e+06    1.35e+06 =================================================================================== Ljung-Box (L1) (Q):                   0.00   Jarque-Bera (JB):                65.30 Prob(Q):                              0.97   Prob(JB):                         0.00 Heteroskedasticity (H):               0.99   Skew:                            -0.02 Prob(H) (two-sided):                  0.94   Kurtosis:                         1.80 ===================================================================================<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0421\u0435\u0442\u043e\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432<\/h3>\n<p>  \u0421\u0435\u0442\u043e\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438, \u0432 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435. \u042d\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u0432 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435, \u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u0432 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435 \u041c\u0412\u0438\u0434\u0435\u043e \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0441\u044f\u0446\u0435\u0432. \u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u044b, \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0438, \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u044b \u0438 \u0431\u044b\u0442\u043e\u0432\u0443\u044e \u0442\u0435\u0445\u043d\u0438\u043a\u0443.<\/p>\n<pre><code class=\"python\">import pandas as pd import numpy as np  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c dataset \u0441 \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 data = {'\u0414\u0430\u0442\u0430': pd.date_range(start='2023-01-01', periods=12, freq='M'),         '\u041f\u0440\u043e\u0434\u0430\u0436\u0438 \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u043e\u0432': [50, 45, 55, 60, 70, 80, 90, 85, 75, 70, 60, 55],         '\u041f\u0440\u043e\u0434\u0430\u0436\u0438 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u043e\u0432': [30, 35, 40, 45, 50, 60, 65, 70, 75, 80, 85, 90],         '\u041f\u0440\u043e\u0434\u0430\u0436\u0438 \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u043e\u0432': [70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125],         '\u041f\u0440\u043e\u0434\u0430\u0436\u0438 \u0431\u044b\u0442\u043e\u0432\u043e\u0439 \u0442\u0435\u0445\u043d\u0438\u043a\u0438': [40, 42, 45, 48, 50, 52, 55, 58, 60, 62, 65, 68]} sales_df = pd.DataFrame(data)  # \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c '\u0414\u0430\u0442\u0430' \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 sales_df.set_index('\u0414\u0430\u0442\u0430', inplace=True)<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u0445 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u0432 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435 \u041c\u0412\u0438\u0434\u0435\u043e. \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0441\u0435\u0442\u043e\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u043b\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0438 \u043f\u0440\u043e\u0434\u0430\u0436.<\/p>\n<p>  <b>1. \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445:<\/b><\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0434\u0430\u0436\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438\u0445 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<pre><code class=\"python\">import matplotlib.pyplot as plt  # \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0434\u0430\u0436 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 plt.figure(figsize=(12, 6)) for column in sales_df.columns:     plt.plot(sales_df.index, sales_df[column], label=column)  plt.title('\u0414\u0438\u043d\u0430\u043c\u0438\u043a\u0430 \u043f\u0440\u043e\u0434\u0430\u0436 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432') plt.xlabel('\u0414\u0430\u0442\u0430') plt.ylabel('\u041f\u0440\u043e\u0434\u0430\u0436\u0438') plt.legend() plt.grid(True) plt.show()<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/pm\/al\/pv\/pmalpvepywapehrx4fyu6bkucg4.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/pm\/al\/pv\/pmalpvepywapehrx4fyu6bkucg4.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  <b>2. \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0439:<\/b><\/p>\n<p>  \u0414\u043b\u044f \u0441\u0435\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432.  <\/p>\n<pre><code class=\"python\"># \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u043c\u0438 correlation_matrix = sales_df.corr()  # \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b import seaborn as sns  plt.figure(figsize=(8, 6)) sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', linewidths=0.5) plt.title('\u041a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043f\u0440\u043e\u0434\u0430\u0436') plt.show()<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/ew\/dp\/q7\/ewdpq7vspbkkmohvh49gsvcf-4k.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/ew\/dp\/q7\/ewdpq7vspbkkmohvh49gsvcf-4k.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0432\u0438\u0434\u0435\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432.<\/p>\n<p>  <b>3. \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u043e\u0432:<\/b><\/p>\n<p>  \u0421\u0435\u0442\u043e\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u043e\u0432 \u043f\u0440\u043e\u0434\u0430\u0436 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0434\u043b\u044f \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u043d\u0434\u043e\u0432.<\/p>\n<pre><code class=\"python\"># \u0421\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0433\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e window = 3  # \u0420\u0430\u0437\u043c\u0435\u0440 \u043e\u043a\u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0433\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e smoothed_sales_df = sales_df.rolling(window=window).mean()  # \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0433\u043b\u0430\u0436\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 plt.figure(figsize=(12, 6)) for column in smoothed_sales_df.columns:     plt.plot(smoothed_sales_df.index, smoothed_sales_df[column], label=column)  plt.title(f'\u0421\u0433\u043b\u0430\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0434\u0430\u0436\u0438 \u0441 \u043e\u043a\u043d\u043e\u043c {window}') plt.xlabel('\u0414\u0430\u0442\u0430') plt.ylabel('\u041f\u0440\u043e\u0434\u0430\u0436\u0438') plt.legend() plt.grid(True) plt.show() <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/kn\/me\/ky\/knmekycn27mhfjqy6ov0xodh5r0.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/kn\/me\/ky\/knmekycn27mhfjqy6ov0xodh5r0.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0421\u0433\u043b\u0430\u0436\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u043c \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u0442\u043a\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u044b \u043f\u0440\u043e\u0434\u0430\u0436.<\/p>\n<p>  \u0421\u0435\u0442\u043e\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043e\u0449\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0412\u0430\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435.<\/p>\n<h3>\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u044b\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u044f\u0434\u044b<\/h3>\n<p>  \u0421\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u044b\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u044f\u0434\u044b \u2014 \u044d\u0442\u043e \u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u044c \u0438\u043b\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u0432 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435 \u0438\u043b\u0438 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0432 \u043c\u0435\u0434\u0438\u0446\u0438\u043d\u0441\u043a\u0438\u0445 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u043f\u0440\u043e\u0434\u0430\u0436\u0438 \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u043e\u0432 \u0438 \u043f\u0440\u043e\u0434\u0430\u0436\u0438 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u043e\u0432 \u0432 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435 \u041c\u0412\u0438\u0434\u0435\u043e, \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f.<\/p>\n<pre><code class=\"python\">import pandas as pd import numpy as np  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c dataset \u0441 \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u043c\u0438 \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u043e\u0432 \u0438 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u043e\u0432 data = {'\u0414\u0430\u0442\u0430': pd.date_range(start='2023-01-01', periods=12, freq='M'),         '\u041f\u0440\u043e\u0434\u0430\u0436\u0438 \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u043e\u0432': [50, 45, 55, 60, 70, 80, 90, 85, 75, 70, 60, 55],         '\u041f\u0440\u043e\u0434\u0430\u0436\u0438 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u043e\u0432': [30, 35, 40, 45, 50, 60, 65, 70, 75, 80, 85, 90]} sales_df = pd.DataFrame(data)  # \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c '\u0414\u0430\u0442\u0430' \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 sales_df.set_index('\u0414\u0430\u0442\u0430', inplace=True)  # \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u043c\u0438 \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u043e\u0432 \u0438 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u043e\u0432 correlation = sales_df['\u041f\u0440\u043e\u0434\u0430\u0436\u0438 \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u043e\u0432'].corr(sales_df['\u041f\u0440\u043e\u0434\u0430\u0436\u0438 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u043e\u0432'])  print(f'\u041a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u043c\u0438 \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u043e\u0432 \u0438 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u043e\u0432: {correlation:.2f}')<\/code><\/pre>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/b><\/p>\n<pre><code class=\"plaintext\">\u041a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0434\u0430\u0436\u0430\u043c\u0438 \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u043e\u0432 \u0438 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u043e\u0432: 0.41<\/code><\/pre>\n<p>  \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u0430\u044f \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0410\u043d\u0430\u043b\u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0430\u0436, \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0438\u043d\u0430\u043d\u0441\u0430\u043c\u0438, \u043c\u0435\u0434\u0438\u0446\u0438\u043d\u0441\u043a\u0438\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u041f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0438 \u0443\u043c\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u0445 \u0430\u043d\u0430\u043b\u0438\u0437 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u0432\u044b\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432 \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e. \u041c\u044b \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u0432\u0430\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0432\u0430\u0448\u0438 \u0437\u043d\u0430\u043d\u0438\u044f \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438 \u0438 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b\u0430 \u0432\u0430\u0441 \u043d\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u044d\u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438.<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/769756\/\"> https:\/\/habr.com\/ru\/articles\/769756\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/av\/um\/lx\/avumlxbj7dsulhw61puxdpfh6mq.png\" data-src=\"https:\/\/habrastorage.org\/webt\/av\/um\/lx\/avumlxbj7dsulhw61puxdpfh6mq.png\"\/><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432\u043e \u0432\u0442\u043e\u0440\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043d\u0430\u0448\u0435\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 &#171;<i>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438 \u0432 Python.<\/i>&#187; <a href=\"https:\/\/habr.com\/ru\/companies\/mvideo\/articles\/769190\/\">\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>, \u043c\u044b \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u043e\u0441\u043d\u043e\u0432\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438 \u0438 \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u0430\u043c \u044d\u0442\u043e\u0439 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0435\u043c\u044b.<\/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-358433","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358433","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=358433"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358433\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=358433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=358433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=358433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}