{"id":337624,"date":"2022-08-28T09:00:05","date_gmt":"2022-08-28T09:00:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=337624"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=337624","title":{"rendered":"<span>\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432 R<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0440\u0435\u0448\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u0430 \u0433\u0440\u0443\u043f\u043f\u044b (\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u044b) \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0432\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0441\u0444\u0435\u0440 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e \u0440\u0435\u043a\u043b\u0430\u043c\u0430 \u0438 \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433. \u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u00ab\u043f\u043e\u0445\u043e\u0436\u0438\u0445\u00bb \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430 \u0438\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u044f\u0437\u044b\u043a\u0430 R.<\/p>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438\u0437 csv-\u0444\u0430\u0439\u043b\u0430. \u0417\u0430\u0434\u0430\u0447\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u0430\u0441\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u043e\u0432, \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0432\u0448\u0438\u0445 \u0432 \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u043e\u0439 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0436\u0443\u0440\u043d\u0430\u043b.<\/p>\n<pre><code>adv_dataframe &lt;- read.csv('.\/advert_dataset.csv', header=T) head(adv_dataframe) --------------------------------------------------------------------------------------------------------------------------------- \u0413\u043e\u0440\u043e\u0434                \u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a \u041a\u043e\u0442_\u0438_\u043f\u0451\u0441 \u0414\u0430\u0447\u0430       \u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f_\u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f   \u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f_\u0432\u044b\u043f\u0435\u0447\u043a\u0430   \u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f \u041a\u0430\u0441\u043b\u0420\u043e\u043a            30000                   200             10           9000                                    11000                           500 \u0422\u0432\u0438\u043d\u041f\u0438\u043a\u0441         15000                   750              5            7000                                    6000                             1000 \u0421\u0430\u0439\u043b\u0435\u043d\u0442\u0425\u0438\u043b\u043b   10000                   4500            0            650                                      15                                 4200 \u0425\u0430\u0440\u043b\u043e\u0443              5000                    1                  1100       10                                        260                               400 \u0413\u0430\u0442\u043b\u0438\u043d               3000                    1800            20           18                                        20                                 1000 \u041a\u0435\u0439\u043f\u041a\u043e\u0434           1200                     16                800         2                                          60                                 10 <\/code><\/pre>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u044f\u044e %-\u043d\u043e\u0435 \u00a0\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a \u043f\u043e \u0433\u043e\u0440\u043e\u0434\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0436\u0443\u0440\u043d\u0430\u043b\u0430:<\/p>\n<pre><code>adv_dataframe$'\u041a\u043e\u0442_\u0438_\u043f\u0451\u0441_%' &lt;- 100 * adv_dataframe$'\u041a\u043e\u0442_\u0438_\u043f\u0451\u0441'\/ adv_dataframe$'\u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a' adv_dataframe$'\u0414\u0430\u0447\u0430_%' &lt;- 100 * adv_dataframe$'\u0414\u0430\u0447\u0430'\/ adv_dataframe$'\u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a' adv_dataframe$'\u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f_\u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f_%'&lt;-100*adv_dataframe$'\u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f_\u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f'\/ adv_dataframe$'\u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a' adv_dataframe$'\u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f_\u0432\u044b\u043f\u0435\u0447\u043a\u0430_%' &lt;- 100 * adv_dataframe$'\u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f_\u0432\u044b\u043f\u0435\u0447\u043a\u0430'\/ adv_dataframe$'\u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a' adv_dataframe$'\u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f_%' &lt;- 100 * adv_dataframe$'\u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f'\/ adv_dataframe$'\u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a' df4analysis &lt;- subset(adv_dataframe, select = c('\u0413\u043e\u0440\u043e\u0434','\u041a\u043e\u0442_\u0438_\u043f\u0451\u0441_%','\u0414\u0430\u0447\u0430_%','\u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f_\u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f_%','\u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f_\u0432\u044b\u043f\u0435\u0447\u043a\u0430_%','\u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f_%')) <\/code><\/pre>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0438\u0440\u0443\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430. \u0418 \u0441\u043b\u0435\u0434\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 (distance_matrix).<\/p>\n<pre><code>pure_data &lt;- df4analysis[,-c(1,1)] means &lt;- apply(pure_data,2,mean) sds &lt;- apply(pure_data,2,sd) norm_ &lt;- scale(pure_data,center=means,scale=sds) distance_martix = dist(norm_)<\/code><\/pre>\n<p><strong>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e. <\/strong><\/p>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u044e \u0434\u0435\u043d\u0434\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439.<\/p>\n<pre><code>df4analysis.hclust&lt;-hclust(distance_martix,method=\"average\")  plot(df4analysis.hclust) rect.hclust(df4analysis.hclust , k = 3, border = 2:6) abline(h = 2.6, col = 'red')<\/code><\/pre>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c 3 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u0422\u0430\u043a \u0436\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0434\u0435\u043d\u0434\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0440\u043e\u0432\u043e\u0436\u0443 \u043b\u0438\u043d\u0438\u044e \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 3 \u0438 \u0432\u044b\u0434\u0435\u043b\u044f\u044e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u044b (<em>rect.hclust<\/em>) \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0446\u0432\u0435\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u043d\u0430\u0448 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0441 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043a \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443.<\/p>\n<pre><code>cut_ &lt;- cutree(df4analysis.hclust, k = 3) df4analysis.cut_ = factor(cut_)<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>head(df4analysis) ---------------------------------------------------------------------------------------------------------------------------------------- \u0413\u043e\u0440\u043e\u0434                \u041a\u043e\u0442_\u0438_\u043f\u0451\u0441_%      \u0414\u0430\u0447\u0430_%               \u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f_\u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f_% \u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f_\u0432\u044b\u043f\u0435\u0447\u043a\u0430_% \u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f_% cut_ \u041a\u0430\u0441\u043b\u0420\u043e\u043a            0.6666667            0.03333333          30.0000000                            36.6666667                      1.6666667          1 \u0422\u0432\u0438\u043d\u041f\u0438\u043a\u0441         5.0000000            0.03333333           46.6666667                            40.0000000                     6.6666667          1 \u0421\u0430\u0439\u043b\u0435\u043d\u0442\u0425\u0438\u043b\u043b   45.0000000          0.00000000           6.5000000                              0.1500000                       42.0000000        2 \u0425\u0430\u0440\u043b\u043e\u0443              0.0200000            22.00000000         0.2000000                              5.2000000                       8.0000000          3 \u0413\u0430\u0442\u043b\u0438\u043d               60.0000000          0.66666667           0.6000000                              0.6666667                      33.3333333         2 \u041a\u0435\u0439\u043f\u041a\u043e\u0434            1.3333333            66.66666667         0.1666667                              5.0000000                      0.8333333           3<\/code><\/pre>\n<p>\u0418\u0437 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 1- \u0434\u0432\u0430 \u0433\u043e\u0440\u043e\u0434\u0430 \u0441 \u043f\u0440\u0435\u043e\u0431\u043b\u0430\u0434\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a \u043d\u0430 \u0436\u0443\u0440\u043d\u0430\u043b\u044b \u00ab<em>\u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f\u00bb<\/em> \u0438 \u00ab<em>\u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f \u0432\u044b\u043f\u0435\u0447\u043a\u0430\u00bb<\/em>, \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 2- \u044d\u0442\u043e \u00ab<em>\u041a\u043e\u0442 \u0438 \u043f\u0451\u0441\u00bb<\/em> \u0438 \u00ab<em>\u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f\u00bb<\/em> \u0438 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 3- \u0433\u043e\u0440\u043e\u0434\u0430 \u0441 \u043f\u0440\u0435\u043e\u0431\u043b\u0430\u0434\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a \u043d\u0430 \u0436\u0443\u0440\u043d\u0430\u043b \u00ab<em>\u0414\u0430\u0447\u0430\u00bb<\/em>. <\/p>\n<p><strong>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <em>K<\/em>-\u0441\u0440\u0435\u0434\u043d\u0438\u0445<\/strong> (<strong><em>k-means<\/em><\/strong>). <\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <strong><em>kmeans<\/em><\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e \u043c\u0435\u0442\u043e\u0434 <strong><em>fviz_cluster<\/em><\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<strong> <\/strong><a href=\"https:\/\/cran.r-project.org\/web\/packages\/factoextra\/index.html\" rel=\"noopener noreferrer nofollow\"><strong><em>factoextra<\/em><\/strong><\/a><em> <\/em>\u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<pre><code>library(factoextra)  k_ &lt;- kmeans(norm_, centers = 3, nstart = 25) rownames(norm_) &lt;- df4analysis$'\u0413\u043e\u0440\u043e\u0434' fviz_cluster(k_, data = norm_)<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ba6\/a40\/0ef\/ba6a400ef4823ff90bccdf13a979e5fd.png\" width=\"725\" height=\"342\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ba6\/a40\/0ef\/ba6a400ef4823ff90bccdf13a979e5fd.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u0430\u0441\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u043d\u0430 \u0442\u0435 \u0436\u0435 3 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 (\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443).<\/p>\n<p>\u0414\u043b\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0443\u043c \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u00a0 <strong><em>fviz_nbclust<\/em><\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<strong> <\/strong><a href=\"https:\/\/cran.r-project.org\/web\/packages\/factoextra\/index.html\" rel=\"noopener noreferrer nofollow\"><strong><em>factoextra<\/em><\/strong><\/a>. <\/p>\n<pre><code>fviz_nbclust(norm_, kmeans, method = &lt;\u043c\u0435\u0442\u043e\u0434>) <\/code><\/pre>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <strong><em>method<\/em><\/strong> \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>&#171;gap_stat&#187; (Gap static method)<\/em>, <em>&#171;silhouette&#187;(Silhouette method), &#171;wss&#187; (Elbow method)<\/em>. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 <em>fviz_nbclust<\/em> \u0432\u044b\u0434\u0430\u0451\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 <strong><em>method<\/em><\/strong> \u0433\u0440\u0430\u0444\u0438\u043a.<\/p>\n<p>\u0422\u0435\u043c\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043e\u0431\u0448\u0438\u0440\u043d\u0430, \u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b \u0432\u0430\u0441 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043f\u0440\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c, \u044f \u0445\u043e\u0442\u0435\u043b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u043a\u0430\u043a \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043e\u0431\u0448\u0438\u0440\u0435\u043d \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u044f\u0437\u044b\u043a\u0430 R, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0440\u0435\u0448\u0430\u0442\u044c \u044d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/685040\/\"> https:\/\/habr.com\/ru\/post\/685040\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0440\u0435\u0448\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u0430 \u0433\u0440\u0443\u043f\u043f\u044b (\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u044b) \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0432\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0441\u0444\u0435\u0440 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e \u0440\u0435\u043a\u043b\u0430\u043c\u0430 \u0438 \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433. \u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u00ab\u043f\u043e\u0445\u043e\u0436\u0438\u0445\u00bb \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430 \u0438\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u044f\u0437\u044b\u043a\u0430 R.<\/p>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438\u0437 csv-\u0444\u0430\u0439\u043b\u0430. \u0417\u0430\u0434\u0430\u0447\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f: \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u0430\u0441\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u043e\u0432, \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0432\u0448\u0438\u0445 \u0432 \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u043e\u0439 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0436\u0443\u0440\u043d\u0430\u043b.<\/p>\n<pre><code>adv_dataframe &lt;- read.csv('.\/advert_dataset.csv', header=T) head(adv_dataframe) --------------------------------------------------------------------------------------------------------------------------------- \u0413\u043e\u0440\u043e\u0434                \u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a \u041a\u043e\u0442_\u0438_\u043f\u0451\u0441 \u0414\u0430\u0447\u0430       \u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f_\u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f   \u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f_\u0432\u044b\u043f\u0435\u0447\u043a\u0430   \u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f \u041a\u0430\u0441\u043b\u0420\u043e\u043a            30000                   200             10           9000                                    11000                           500 \u0422\u0432\u0438\u043d\u041f\u0438\u043a\u0441         15000                   750              5            7000                                    6000                             1000 \u0421\u0430\u0439\u043b\u0435\u043d\u0442\u0425\u0438\u043b\u043b   10000                   4500            0            650                                      15                                 4200 \u0425\u0430\u0440\u043b\u043e\u0443              5000                    1                  1100       10                                        260                               400 \u0413\u0430\u0442\u043b\u0438\u043d               3000                    1800            20           18                                        20                                 1000 \u041a\u0435\u0439\u043f\u041a\u043e\u0434           1200                     16                800         2                                          60                                 10 <\/code><\/pre>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u044f\u044e %-\u043d\u043e\u0435 \u00a0\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a \u043a \u043e\u0431\u0449\u0435\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a \u043f\u043e \u0433\u043e\u0440\u043e\u0434\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0436\u0443\u0440\u043d\u0430\u043b\u0430:<\/p>\n<pre><code>adv_dataframe$'\u041a\u043e\u0442_\u0438_\u043f\u0451\u0441_%' &lt;- 100 * adv_dataframe$'\u041a\u043e\u0442_\u0438_\u043f\u0451\u0441'\/ adv_dataframe$'\u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a' adv_dataframe$'\u0414\u0430\u0447\u0430_%' &lt;- 100 * adv_dataframe$'\u0414\u0430\u0447\u0430'\/ adv_dataframe$'\u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a' adv_dataframe$'\u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f_\u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f_%'&lt;-100*adv_dataframe$'\u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f_\u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f'\/ adv_dataframe$'\u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a' adv_dataframe$'\u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f_\u0432\u044b\u043f\u0435\u0447\u043a\u0430_%' &lt;- 100 * adv_dataframe$'\u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f_\u0432\u044b\u043f\u0435\u0447\u043a\u0430'\/ adv_dataframe$'\u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a' adv_dataframe$'\u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f_%' &lt;- 100 * adv_dataframe$'\u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f'\/ adv_dataframe$'\u0412\u0441\u0435\u0433\u043e_\u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a' df4analysis &lt;- subset(adv_dataframe, select = c('\u0413\u043e\u0440\u043e\u0434','\u041a\u043e\u0442_\u0438_\u043f\u0451\u0441_%','\u0414\u0430\u0447\u0430_%','\u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f_\u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f_%','\u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f_\u0432\u044b\u043f\u0435\u0447\u043a\u0430_%','\u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f_%')) <\/code><\/pre>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0438\u0440\u0443\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430. \u0418 \u0441\u043b\u0435\u0434\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 (distance_matrix).<\/p>\n<pre><code>pure_data &lt;- df4analysis[,-c(1,1)] means &lt;- apply(pure_data,2,mean) sds &lt;- apply(pure_data,2,sd) norm_ &lt;- scale(pure_data,center=means,scale=sds) distance_martix = dist(norm_)<\/code><\/pre>\n<p><strong>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e. <\/strong><\/p>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u044e \u0434\u0435\u043d\u0434\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439.<\/p>\n<pre><code>df4analysis.hclust&lt;-hclust(distance_martix,method=\"average\")  plot(df4analysis.hclust) rect.hclust(df4analysis.hclust , k = 3, border = 2:6) abline(h = 2.6, col = 'red')<\/code><\/pre>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c 3 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u0422\u0430\u043a \u0436\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0434\u0435\u043d\u0434\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0440\u043e\u0432\u043e\u0436\u0443 \u043b\u0438\u043d\u0438\u044e \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 3 \u0438 \u0432\u044b\u0434\u0435\u043b\u044f\u044e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u044b (<em>rect.hclust<\/em>) \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0446\u0432\u0435\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0432 \u043d\u0430\u0448 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0441 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043a \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443.<\/p>\n<pre><code>cut_ &lt;- cutree(df4analysis.hclust, k = 3) df4analysis.cut_ = factor(cut_)<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>head(df4analysis) ---------------------------------------------------------------------------------------------------------------------------------------- \u0413\u043e\u0440\u043e\u0434                \u041a\u043e\u0442_\u0438_\u043f\u0451\u0441_%      \u0414\u0430\u0447\u0430_%               \u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f_\u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f_% \u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f_\u0432\u044b\u043f\u0435\u0447\u043a\u0430_% \u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f_% cut_ \u041a\u0430\u0441\u043b\u0420\u043e\u043a            0.6666667            0.03333333          30.0000000                            36.6666667                      1.6666667          1 \u0422\u0432\u0438\u043d\u041f\u0438\u043a\u0441         5.0000000            0.03333333           46.6666667                            40.0000000                     6.6666667          1 \u0421\u0430\u0439\u043b\u0435\u043d\u0442\u0425\u0438\u043b\u043b   45.0000000          0.00000000           6.5000000                              0.1500000                       42.0000000        2 \u0425\u0430\u0440\u043b\u043e\u0443              0.0200000            22.00000000         0.2000000                              5.2000000                       8.0000000          3 \u0413\u0430\u0442\u043b\u0438\u043d               60.0000000          0.66666667           0.6000000                              0.6666667                      33.3333333         2 \u041a\u0435\u0439\u043f\u041a\u043e\u0434            1.3333333            66.66666667         0.1666667                              5.0000000                      0.8333333           3<\/code><\/pre>\n<p>\u0418\u0437 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 1- \u0434\u0432\u0430 \u0433\u043e\u0440\u043e\u0434\u0430 \u0441 \u043f\u0440\u0435\u043e\u0431\u043b\u0430\u0434\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a \u043d\u0430 \u0436\u0443\u0440\u043d\u0430\u043b\u044b \u00ab<em>\u0423\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0433\u0435\u043e\u043b\u043e\u0433\u0438\u044f\u00bb<\/em> \u0438 \u00ab<em>\u0414\u043e\u043c\u0430\u0448\u043d\u044f\u044f \u0432\u044b\u043f\u0435\u0447\u043a\u0430\u00bb<\/em>, \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 2- \u044d\u0442\u043e \u00ab<em>\u041a\u043e\u0442 \u0438 \u043f\u0451\u0441\u00bb<\/em> \u0438 \u00ab<em>\u041f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f\u00bb<\/em> \u0438 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 3- \u0433\u043e\u0440\u043e\u0434\u0430 \u0441 \u043f\u0440\u0435\u043e\u0431\u043b\u0430\u0434\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a \u043d\u0430 \u0436\u0443\u0440\u043d\u0430\u043b \u00ab<em>\u0414\u0430\u0447\u0430\u00bb<\/em>. <\/p>\n<p><strong>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <em>K<\/em>-\u0441\u0440\u0435\u0434\u043d\u0438\u0445<\/strong> (<strong><em>k-means<\/em><\/strong>). <\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <strong><em>kmeans<\/em><\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e \u043c\u0435\u0442\u043e\u0434 <strong><em>fviz_cluster<\/em><\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<strong> <\/strong><a href=\"https:\/\/cran.r-project.org\/web\/packages\/factoextra\/index.html\" rel=\"noopener noreferrer nofollow\"><strong><em>factoextra<\/em><\/strong><\/a><em> <\/em>\u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<pre><code>library(factoextra)  k_ &lt;- kmeans(norm_, centers = 3, nstart = 25) rownames(norm_) &lt;- df4analysis$'\u0413\u043e\u0440\u043e\u0434' fviz_cluster(k_, data = norm_)<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u0430\u0441\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u043d\u0430 \u0442\u0435 \u0436\u0435 3 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 (\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443).<\/p>\n<p>\u0414\u043b\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0443\u043c \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u00a0 <strong><em>fviz_nbclust<\/em><\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<strong> <\/strong><a href=\"https:\/\/cran.r-project.org\/web\/packages\/factoextra\/index.html\" rel=\"noopener noreferrer nofollow\"><strong><em>factoextra<\/em><\/strong><\/a>. <\/p>\n<pre><code>fviz_nbclust(norm_, kmeans, method = &lt;\u043c\u0435\u0442\u043e\u0434>) <\/code><\/pre>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <strong><em>method<\/em><\/strong> \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>&#171;gap_stat&#187; (Gap static method)<\/em>, <em>&#171;silhouette&#187;(Silhouette method), &#171;wss&#187; (Elbow method)<\/em>. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 <em>fviz_nbclust<\/em> \u0432\u044b\u0434\u0430\u0451\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 <strong><em>method<\/em><\/strong> \u0433\u0440\u0430\u0444\u0438\u043a.<\/p>\n<p>\u0422\u0435\u043c\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043e\u0431\u0448\u0438\u0440\u043d\u0430, \u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b \u0432\u0430\u0441 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043f\u0440\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c, \u044f \u0445\u043e\u0442\u0435\u043b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u043a\u0430\u043a \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043e\u0431\u0448\u0438\u0440\u0435\u043d \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u044f\u0437\u044b\u043a\u0430 R, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0440\u0435\u0448\u0430\u0442\u044c \u044d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/685040\/\"> https:\/\/habr.com\/ru\/post\/685040\/<\/a><br \/><\/br><\/br><\/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-337624","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337624","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=337624"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/337624\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}