{"id":265863,"date":"2015-09-17T16:22:04","date_gmt":"2015-09-17T12:22:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=265863"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=265863","title":{"rendered":"\u0420\u0430\u0437\u0431\u043e\u0440 \u0437\u0430\u0434\u0430\u0447\u0438 Digit Recognizer \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f Kaggle"},"content":{"rendered":"<p>       \u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/5bb\/a0d\/0af\/5bba0d0af5514b4b9f22caa4bce3f0b7.png\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0440\u0430\u0437\u0431\u043e\u0440\u043e\u0432 \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043f\u0440\u043e\u0440\u0435\u0448\u0430\u043b \u0437\u0430 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0435\u0431\u044f\u0442\u0430\u043c\u0438 \u0438\u0437 <a href=\"http:\/\/dscourse.mlclass.ru\">MLClass.ru<\/a>. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0446\u0438\u0444\u0440 <a href=\"https:\/\/www.kaggle.com\/c\/digit-recognizer\">Digit Recognizer<\/a> \u0441 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b Kaggle. \u0421\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0449\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0449\u0435 \u043d\u0435 \u043f\u043e\u0437\u0434\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u0443\u0440\u0441 <a href=\"http:\/\/dscourse.mlclass.ru\">\u041f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445<\/a>, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0414\u0430\u043d\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c <a href=\"http:\/\/habrahabr.ru\/company\/mlclass\/blog\/266727\/\">\u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f<\/a>, \u0438\u0437\u0443\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0438. \u0412 \u043d\u0435\u0439 \u0434\u043b\u044f \u0431\u044b\u043b\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0441 \u0446\u0435\u043b\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041d\u043e, \u043a\u0440\u043e\u043c\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043b\u0438\u044f\u0435\u0442 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0442\u0435\u0445 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u044b \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0432 <b>R<\/b>.<\/p>\n<pre><code>library(readr) library(caret) library(ggbiplot) library(ggplot2) library(dplyr) library(rgl) data_train &lt;- read_csv(&quot;train.csv&quot;) ##  |================================================================================| 100%   73 MB <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 42000 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 784 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0441\u043e\u0431\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0440\u043a\u043e\u0441\u0442\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0446\u0438\u0444\u0440\u044b. \u0420\u0430\u0437\u043e\u0431\u044a\u0451\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u0443\u044e \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0432 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 60\/40.<\/p>\n<pre><code>set.seed(111) split &lt;- createDataPartition(data_train$label, p = 0.6, list = FALSE) train &lt;- slice(data_train, split) test &lt;- slice(data_train, -split) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443\u0434\u0430\u043b\u0438\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0438\u043c\u0435\u044e\u0449\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<pre><code>zero_var_col &lt;- nearZeroVar(train, saveMetrics = T) train &lt;- train[, !zero_var_col$nzv] test &lt;- test[, !zero_var_col$nzv] dim(train)  ## [1] 25201   253 <\/code><\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c 253 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430.<\/p>\n<h3>\u0422\u0435\u043e\u0440\u0438\u044f<\/h3>\n<p>  \u041c\u0435\u0442\u043e\u0434 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 (PCA) \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0432 \u043d\u043e\u0432\u044b\u0435, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0435\u0439 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0442\u043e \u0435\u0441\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 \u043e\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f) \u0432\u0434\u043e\u043b\u044c \u043d\u0438\u0445 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u0435\u043d. \u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0441\u0436\u0430\u0442\u0438\u044f).<\/p>\n<h3>PCA<\/h3>\n<p>  \u0414\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0442\u0431\u0435\u0440\u0451\u043c \u0438\u0437 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 1000 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0438\u0445 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u044b\u0445 \u0434\u0432\u0443\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432.<\/p>\n<pre><code>train_1000 &lt;- train[sample(nrow(train), size = 1000),] ggplot(data = train_1000, aes(x = pixel152, y = pixel153, color = factor(label))) + geom_point() <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/5f2\/370\/d79\/5f2370d791b34bacab313066aa5b0fa5.png\"\/><\/p>\n<p>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0448\u0430\u043d\u044b \u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 \u0433\u0440\u0443\u043f\u043f\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u0445 \u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e. \u041f\u0440\u043e\u0432\u0435\u0434\u0451\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u044b\u0445 \u0434\u0432\u0443\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442. \u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0432 \u0443\u0431\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0434\u043e\u043b\u044c \u043d\u0438\u0445.<\/p>\n<pre><code>pc &lt;- princomp(train_1000[, -1], cor=TRUE, scores=TRUE) ggbiplot(pc, obs.scale = 1, var.scale = 1, groups = factor(train_1000$label),          ellipse = TRUE, circle = F, var.axes = F) +          scale_color_discrete(name = '') +          theme(legend.direction = 'horizontal', legend.position = 'top') <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f62\/6bd\/23a\/f626bd23aaae4bfc88d29895313e4693.png\"\/><\/p>\n<p>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0434\u0432\u0443\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043d\u044b\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u043e \u0443\u0436\u0435 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u044b\u0445 \u0442\u0440\u0451\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<pre><code>plot3d(pc$scores[,1:3], col= train_1000$label + 1, size = 0.7, type = &quot;s&quot;) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/bd3\/9e8\/5a8\/bd39e85a849047269cb07bedfb37c9f2.png\"\/><\/p>\n<p>  \u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u043e\u0441\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e\u0449\u0438\u0435 \u0435\u0451, \u043d\u043e \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u0441\u044e \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443.<\/p>\n<pre><code>pc &lt;- princomp(train[, -1], cor=TRUE, scores=TRUE) variance &lt;- pc$sdev^2\/sum(pc$sdev^2) cumvar &lt;- cumsum(variance) cumvar &lt;- data.frame(PC = 1:252, CumVar = cumvar) ggplot(data = cumvar, aes(x = PC, y = CumVar)) + geom_point() <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/84f\/517\/6ed\/84f5176ed3c34aed99e574a217ec0f0f.png\"\/><\/p>\n<pre><code>variance &lt;- data.frame(PC = 1:252, Var = variance*100) ggplot(data = variance[1:10,], aes(x = factor(PC), y = Var)) + geom_bar(stat = &quot;identity&quot;) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/83d\/6a2\/1a8\/83d6a21a8d254b76817c3f14bc73105f.png\"\/><\/p>\n<pre><code>sum(variance$Var[1:70]) ## [1] 92.69142 <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 90 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0439\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c 70 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u0442.\u0435. \u043c\u044b \u043e\u0442 784 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u0440\u0438\u0448\u043b\u0438 \u043a 70 \u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 \u043c\u0435\u043d\u0435\u0435 10 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445!<\/p>\n<p>  \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u0443\u044e \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<pre><code>train &lt;- predict(pc) %&gt;% cbind(train$label, .) %&gt;% as.data.frame(.) %&gt;% select(1:71) colnames(train)[1]&lt;- &quot;label&quot; train$label &lt;- as.factor(train$label) test %&lt;&gt;% predict(pc, .) %&gt;% cbind(test$label, .) %&gt;% as.data.frame(.) %&gt;% select(1:71) colnames(test)[1]&lt;- &quot;label&quot; <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043f\u0430\u043a\u0435\u0442 caret, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u043d\u043e\u0433\u043e\u044f\u0434\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432.<\/p>\n<pre><code>library(&quot;doParallel&quot;) cl &lt;- makePSOCKcluster(2) registerDoParallel(cl) <\/code><\/pre>\n<p>  <\/p>\n<h4>KNN<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434 k \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (<b>KNN<\/b>). \u0412 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0431\u0443\u0434\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0435\u0441\u044f\u0442\u0438\u043a\u0440\u0430\u0442\u043d\u043e\u0439 \u043a\u0440\u043e\u0441\u0441-\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 (<b>10-fold cross-validation (CV)<\/b>) \u0441 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043d\u0430 10 \u0447\u0430\u0441\u0442\u0435\u0439. \u041e\u0446\u0435\u043d\u043a\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0414\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0443 <b>Accuracy<\/b>, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<pre><code>set.seed(111) train_1000 &lt;- train[sample(nrow(train), size = 1000),] ctrl &lt;- trainControl(method=&quot;repeatedcv&quot;,repeats = 3) \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.  knnFit &lt;- train(label ~ ., data = train_1000, method = &quot;knn&quot;, trControl = ctrl,tuneLength = 20) knnFit ## k-Nearest Neighbors  ##  ## 1000 samples ##   70 predictor ##   10 classes: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'  ##  ## No pre-processing ## Resampling: Cross-Validated (10 fold, repeated 3 times)  ## Summary of sample sizes: 899, 901, 900, 901, 899, 899, ...  ## Resampling results across tuning parameters: ##  ##   k   Accuracy   Kappa      Accuracy SD  Kappa SD   ##    5  0.8749889  0.8608767  0.03637257   0.04047629 ##    7  0.8679743  0.8530101  0.03458659   0.03853048 ##    9  0.8652707  0.8500155  0.03336461   0.03713965 ##   11  0.8529954  0.8363199  0.03692823   0.04114777 ##   13  0.8433141  0.8255274  0.03184725   0.03548771 ##   15  0.8426833  0.8248052  0.04097424   0.04568565 ##   17  0.8423694  0.8244683  0.04070299   0.04540152 ##   19  0.8340150  0.8151256  0.04291349   0.04788273 ##   21  0.8263450  0.8065723  0.03914363   0.04369889 ##   23  0.8200042  0.7995067  0.03872017   0.04320466 ##   25  0.8156764  0.7946582  0.03825163   0.04269085 ##   27  0.8093227  0.7875839  0.04299301   0.04799252 ##   29  0.8010018  0.7783100  0.04252630   0.04747852 ##   31  0.8019849  0.7794036  0.04327120   0.04827493 ##   33  0.7963572  0.7731147  0.04418378   0.04930341 ##   35  0.7936906  0.7701616  0.04012802   0.04478789 ##   37  0.7889930  0.7649252  0.04163075   0.04644193 ##   39  0.7863463  0.7619669  0.03947693   0.04404655 ##   41  0.7829758  0.7582087  0.03482612   0.03889550 ##   43  0.7796388  0.7544879  0.03745359   0.04179976 ##  ## Accuracy was used to select the optimal model using  the largest value. ## The final value used for the model was k = 5. <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043c \u0435\u0451 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u043e\u0447\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<pre><code>grid &lt;- expand.grid(k=2:5) knnFit &lt;- train(label ~ ., data = train_1000, method = &quot;knn&quot;, trControl = ctrl, tuneGrid=grid) knnFit ## k-Nearest Neighbors  ##  ## 1000 samples ##   70 predictor ##   10 classes: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'  ##  ## No pre-processing ## Resampling: Cross-Validated (10 fold, repeated 3 times)  ## Summary of sample sizes: 900, 901, 901, 899, 901, 899, ...  ## Resampling results across tuning parameters: ##  ##   k  Accuracy   Kappa      Accuracy SD  Kappa SD   ##   2  0.8699952  0.8553199  0.03055544   0.03402108 ##   3  0.8799832  0.8664399  0.02768544   0.03082014 ##   4  0.8736591  0.8593777  0.02591618   0.02888557 ##   5  0.8726753  0.8582703  0.02414173   0.02689738 ##  ## Accuracy was used to select the optimal model using  the largest value. ## The final value used for the model was k = 3. <\/code><\/pre>\n<p>  \u041d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 k \u0440\u0430\u0432\u043d\u043e\u043c\u0443 3. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c <b>Confusion Table<\/b> \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c <b>Accuracy<\/b>.<\/p>\n<pre><code>library(class) prediction_knn &lt;- knn(train, test, train$label, k=3) table(test$label, prediction_knn) ##    prediction_knn ##        0    1    2    3    4    5    6    7    8    9 ##   0 1643    0    6    1    0    1    2    0    0    0 ##   1    0 1861    4    1    2    0    0    0    0    0 ##   2    7    7 1647    3    0    0    1   11    0    0 ##   3    1    0    9 1708    2   19    4    6    1    3 ##   4    0    4    0    0 1589    0   10    7    0    6 ##   5    3    2    1   20    1 1474   13    0    6    2 ##   6    0    0    0    1    2    3 1660    0    0    0 ##   7    0    6    3    0    2    0    0 1721    0   13 ##   8    0    1    0   11    1   16   12    4 1522   20 ##   9    0    0    1    3    3    5    1   23    5 1672 sum(diag(table(test$label, prediction_knn)))\/nrow(test) ## [1] 0.9820227 <\/code><\/pre>\n<h4>Random Forest<\/h4>\n<p>  \u0412\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u2014 \u044d\u0442\u043e <b>Random Forest<\/b>. \u0423 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <b>mtry<\/b> \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0432 \u0430\u043d\u0441\u0430\u043c\u0431\u043b\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432. \u0414\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043f\u043e\u0439\u0434\u0451\u043c \u0442\u0435\u043c \u0436\u0435 \u043f\u0443\u0442\u0451\u043c, \u0447\u0442\u043e \u0438 \u0440\u0430\u043d\u0435\u0435.<\/p>\n<pre><code>rfFit &lt;- train(label ~ ., data = train_1000, method = &quot;rf&quot;, trControl = ctrl,tuneLength = 3) rfFit ## Random Forest  ##  ## 1000 samples ##   70 predictor ##   10 classes: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'  ##  ## No pre-processing ## Resampling: Cross-Validated (10 fold, repeated 3 times)  ## Summary of sample sizes: 901, 900, 900, 899, 902, 899, ...  ## Resampling results across tuning parameters: ##  ##   mtry  Accuracy   Kappa      Accuracy SD  Kappa SD   ##    2    0.8526986  0.8358081  0.02889351   0.03226317 ##   36    0.8324051  0.8133909  0.03442843   0.03836844 ##   70    0.8026823  0.7802912  0.03696172   0.04118363 ##  ## Accuracy was used to select the optimal model using  the largest value. ## The final value used for the model was mtry = 2. grid &lt;- expand.grid(mtry=2:6) rfFit &lt;- train(label ~ ., data = train_1000, method = &quot;rf&quot;, trControl = ctrl,tuneGrid=grid) rfFit ## Random Forest  ##  ## 1000 samples ##   70 predictor ##   10 classes: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'  ##  ## No pre-processing ## Resampling: Cross-Validated (10 fold, repeated 3 times)  ## Summary of sample sizes: 898, 900, 900, 901, 900, 898, ...  ## Resampling results across tuning parameters: ##  ##   mtry  Accuracy   Kappa      Accuracy SD  Kappa SD   ##   2     0.8553016  0.8387134  0.03556811   0.03967709 ##   3     0.8615798  0.8457973  0.03102887   0.03458732 ##   4     0.8669329  0.8517297  0.03306870   0.03690844 ##   5     0.8739532  0.8595897  0.02957395   0.03296439 ##   6     0.8696883  0.8548470  0.03203166   0.03568138 ##  ## Accuracy was used to select the optimal model using  the largest value. ## The final value used for the model was mtry = 5. <\/code><\/pre>\n<p>  \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c <b>mtry<\/b> \u0440\u0430\u0432\u043d\u044b\u043c 4 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <b>Accuracy<\/b> \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0431\u0443\u0447\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0447\u0430\u0441\u0442\u0438 \u043e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442.\u043a. \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u043e, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435, \u044d\u0442\u043e \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<pre><code>library(randomForest) rfFit &lt;- randomForest(label ~ ., data = train[sample(nrow(train), size = 15000),], mtry = 4) prediction_rf&lt;-predict(rfFit,test) table(test$label, prediction_rf) ##    prediction_rf ##        0    1    2    3    4    5    6    7    8    9 ##   0 1608    0    6    3    4    1   20    2    9    0 ##   1    0 1828    9    9    3    5    3    2    9    0 ##   2   12    9 1562   16   15    5    6   19   31    1 ##   3   12    1   26 1625    2   33   12   14   22    6 ##   4    0    6   11    1 1524    0   22    7    6   39 ##   5   12    3    3   48   12 1415   10    1   15    3 ##   6   13    4    8    0    4   11 1623    0    3    0 ##   7    3   14   25    2   13    3    0 1653    4   28 ##   8    4   10   12   64    8   21   12    5 1428   23 ##   9    4    4   10   39   38   10    0   39    7 1562 sum(diag(table(test$label, prediction_rf)))\/nrow(test) ## [1] 0.9421989 <\/code><\/pre>\n<p>  <\/p>\n<h4>SVM<\/h4>\n<p>  \u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, <b>Support Vector Machine<\/b>. \u0412 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <b>Radial Kernel<\/b> \u0438 \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0443\u0436\u0435 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: sigma (\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440) \u0438 <b>C<\/b> (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0444\u043e\u0440\u043c\u0443 \u044f\u0434\u0440\u0430).<\/p>\n<pre><code>svmFit &lt;- train(label ~ ., data = train_1000, method = &quot;svmRadial&quot;, trControl = ctrl,tuneLength = 5) svmFit ## Support Vector Machines with Radial Basis Function Kernel  ##  ## 1000 samples ##   70 predictor ##   10 classes: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'  ##  ## No pre-processing ## Resampling: Cross-Validated (10 fold, repeated 3 times)  ## Summary of sample sizes: 901, 900, 898, 900, 900, 901, ...  ## Resampling results across tuning parameters: ##  ##   C     Accuracy   Kappa      Accuracy SD  Kappa SD   ##   0.25  0.7862419  0.7612933  0.02209354   0.02469667 ##   0.50  0.8545924  0.8381166  0.02931921   0.03262332 ##   1.00  0.8826064  0.8694079  0.02903226   0.03225475 ##   2.00  0.8929180  0.8808766  0.02781461   0.03090255 ##   4.00  0.8986322  0.8872208  0.02607149   0.02898200 ##  ## Tuning parameter 'sigma' was held constant at a value of 0.007650572 ## Accuracy was used to select the optimal model using  the largest value. ## The final values used for the model were sigma = 0.007650572 and C = 4. grid &lt;- expand.grid(C = 4:6, sigma = seq(0.006, 0.009, 0.001)) svmFit &lt;- train(label ~ ., data = train_1000, method = &quot;svmRadial&quot;, trControl = ctrl,tuneGrid=grid) svmFit ## Support Vector Machines with Radial Basis Function Kernel  ##  ## 1000 samples ##   70 predictor ##   10 classes: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'  ##  ## No pre-processing ## Resampling: Cross-Validated (10 fold, repeated 3 times)  ## Summary of sample sizes: 901, 900, 900, 899, 901, 901, ...  ## Resampling results across tuning parameters: ##  ##   C  sigma  Accuracy   Kappa      Accuracy SD  Kappa SD   ##   4  0.006  0.8943835  0.8824894  0.02999785   0.03335171 ##   4  0.007  0.8970537  0.8854531  0.02873482   0.03194698 ##   4  0.008  0.8984139  0.8869749  0.03068411   0.03410783 ##   4  0.009  0.8990838  0.8877269  0.03122154   0.03469947 ##   5  0.006  0.8960834  0.8843721  0.03061547   0.03404636 ##   5  0.007  0.8960703  0.8843617  0.03069610   0.03412880 ##   5  0.008  0.8990774  0.8877134  0.03083329   0.03427321 ##   5  0.009  0.8990838  0.8877271  0.03122154   0.03469983 ##   6  0.006  0.8957534  0.8840045  0.03094360   0.03441242 ##   6  0.007  0.8963971  0.8847267  0.03081294   0.03425451 ##   6  0.008  0.8990774  0.8877134  0.03083329   0.03427321 ##   6  0.009  0.8990838  0.8877271  0.03122154   0.03469983 ##  ## Accuracy was used to select the optimal model using  the largest value. ## The final values used for the model were sigma = 0.009 and C = 4. library(kernlab) svmFit &lt;- ksvm(label ~ ., data = train,type=&quot;C-svc&quot;,kernel=&quot;rbfdot&quot;,kpar=list(sigma=0.008),C=4) prediction_svm &lt;- predict(svmFit, newdata = test) table(test$label, prediction_svm) ##    prediction_svm ##        0    1    2    3    4    5    6    7    8    9 ##   0 1625    0    5    1    0    3   13    0    6    0 ##   1    1 1841    6    6    4    1    0    3    5    1 ##   2    8    4 1624    5    7    1    1   13   11    2 ##   3    2    0   18 1684    0   23    2    6   12    6 ##   4    1    3    3    0 1567    0    9    7    5   21 ##   5    8    3    2   24    6 1465    7    0    6    1 ##   6    2    1    2    1    5    5 1649    0    1    0 ##   7    3    8   15    3    3    0    0 1695    3   15 ##   8    1    6   10   10    5    9    3    4 1530    9 ##   9    3    1    5   13   14    9    0   21    3 1644 sum(diag(table(test$label, prediction_svm)))\/nrow(test) ## [1] 0.9717245 <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0410\u043d\u0441\u0430\u043c\u0431\u043b\u044c \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/h4>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0430\u043d\u0441\u0430\u043c\u0431\u043b\u044c \u0438\u0437 \u0442\u0440\u0451\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u043d\u0435\u0435. \u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u00ab\u0433\u043e\u043b\u043e\u0441\u0443\u0435\u0442\u00bb \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439.<\/p>\n<pre><code>all_prediction &lt;- cbind(as.numeric(levels(prediction_knn))[prediction_knn],                  as.numeric(levels(prediction_rf))[prediction_rf],                  as.numeric(levels(prediction_svm))[prediction_svm])  predictions_ensemble &lt;- apply(all_prediction, 1, function(row) {         row %&gt;% table(.) %&gt;% which.max(.) %&gt;% names(.) %&gt;% as.numeric(.)         }) table(test$label, predictions_ensemble) ##    predictions_ensemble ##        0    1    2    3    4    5    6    7    8    9 ##   0 1636    0    5    1    0    1    8    0    2    0 ##   1    1 1851    3    5    3    0    0    1    4    0 ##   2    7    6 1636    3    6    0    0   11    7    0 ##   3    6    0   14 1690    1   18    4    8    7    5 ##   4    0    5    4    0 1573    0   12    6    2   14 ##   5    5    1    2   21    5 1478    7    0    3    0 ##   6    3    1    2    0    5    3 1651    0    1    0 ##   7    1   11   12    2    1    0    0 1704    0   14 ##   8    1    5   11   17    4   13    4    3 1514   15 ##   9    4    2    4   21   11    5    0   20    1 1645 sum(diag(table(test$label, predictions_ensemble)))\/nrow(test) ## [1] 0.974939 <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>  \u041d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<table>\n<tr>\n<td>Model<\/td>\n<td>Test Accuracy<\/td>\n<\/tr>\n<tr>\n<td>KNN<\/td>\n<td>0.981<\/td>\n<\/tr>\n<tr>\n<td>Random Forest<\/td>\n<td>0.948<\/td>\n<\/tr>\n<tr>\n<td>SVM<\/td>\n<td>0.971<\/td>\n<\/tr>\n<tr>\n<td>Ensemble<\/td>\n<td>0.974<\/td>\n<\/tr>\n<\/table>\n<p>  \u041b\u0443\u0447\u0448\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c <b>Accuracy<\/b> \u0438\u043c\u0435\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0430\u044f \u043c\u0435\u0442\u043e\u0434 k \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (<b>KNN<\/b>).<\/p>\n<p>  \u041e\u0446\u0435\u043d\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Kaggle \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n<table>\n<tr>\n<td>Model<\/td>\n<td>Kaggle Accuracy<\/td>\n<\/tr>\n<tr>\n<td>KNN<\/td>\n<td>0.97171<\/td>\n<\/tr>\n<tr>\n<td>Random Forest<\/td>\n<td>0.93286<\/td>\n<\/tr>\n<tr>\n<td>SVM<\/td>\n<td>0.97786<\/td>\n<\/tr>\n<tr>\n<td>Ensemble<\/td>\n<td>0.97471<\/td>\n<\/tr>\n<\/table>\n<p>  \u0418 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u0434\u0435\u0441\u044c \u0443 SVM.<\/p>\n<h3>Eigenfaces<\/h3>\n<p>  \u041d\u0443 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a, \u0443\u0436\u0435 \u0438\u0437 \u0447\u0438\u0441\u0442\u043e\u0433\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u0441\u0442\u0432\u0430, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0446\u0438\u0444\u0440 \u0432 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<pre><code>set.seed(100) train_1000 &lt;- data_train[sample(nrow(data_train), size = 1000),] colors&lt;-c('white','black') cus_col&lt;-colorRampPalette(colors=colors) default_par &lt;- par() number_row &lt;- 28 number_col &lt;- 28 par(mfrow=c(5,5),pty='s',mar=c(1,1,1,1),xaxt='n',yaxt='n') for(i in 1:25) {         z&lt;-array(as.matrix(train_1000)[i,-1],dim=c(number_row,number_col))         z&lt;-z[,number_col:1]         image(1:number_row,1:number_col,z,main=train_1000[i,1],col=cus_col(256)) }  par(default_par) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cca\/f67\/7de\/ccaf677ded5d4028a3095e9bfbd7fa19.png\"\/><\/p>\n<p>  \u0418 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u0436\u0435 \u0446\u0438\u0444\u0440, \u043d\u043e \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 PCA \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0435 70 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442. \u041f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c eigenfaces<\/p>\n<pre><code>zero_var_col &lt;- nearZeroVar(train_1000, saveMetrics = T) train_1000_cut &lt;- train_1000[, !zero_var_col$nzv] pca &lt;- prcomp(train_1000_cut[, -1], center = TRUE, scale = TRUE) restr &lt;- pca$x[,1:70] %*% t(pca$rotation[,1:70]) restr &lt;- scale(restr, center = FALSE , scale=1\/pca$scale) restr &lt;- scale(restr, center = -1 * pca$center, scale=FALSE) restr &lt;- as.data.frame(cbind(train_1000_cut$label, restr)) test &lt;- data.frame(matrix(NA, nrow = 1000, ncol = ncol(train_1000))) zero_col_number &lt;- 1 for (i in 1:ncol(train_1000)) {         if (zero_var_col$nzv[i] == F) {                 test[, i] &lt;- restr[, zero_col_number]                 zero_col_number &lt;- zero_col_number + 1         }         else test[, i] &lt;- train_1000[, i] } par(mfrow=c(5,5),pty='s',mar=c(1,1,1,1),xaxt='n',yaxt='n') for(i in 1:25) {         z&lt;-array(as.matrix(test)[i,-1],dim=c(number_row,number_col))         z&lt;-z[,number_col:1]         image(1:number_row,1:number_col,z,main=test[i,1],col=cus_col(256)) }  par(default_par) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4cd\/108\/6b3\/4cd1086b349a47799d4d5bbdc4b32ed9.png\"\/><\/p>\n<p>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0434\u043d\u0443 \u0438\u0437 \u0437\u0430\u0434\u0430\u0447 Text Mining&#8217;\u0430, \u043d\u0443 \u0430 \u043f\u043e\u043a\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043a \u043a\u0443\u0440\u0441\u0443 \u043f\u043e <a href=\"http:\/\/dscourse.mlclass.ru\">\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/a> \u2014 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e!               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/267075\/\"> http:\/\/habrahabr.ru\/post\/267075\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440!<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/5bb\/a0d\/0af\/5bba0d0af5514b4b9f22caa4bce3f0b7.png\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0440\u0430\u0437\u0431\u043e\u0440\u043e\u0432 \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043f\u0440\u043e\u0440\u0435\u0448\u0430\u043b \u0437\u0430 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0435\u0431\u044f\u0442\u0430\u043c\u0438 \u0438\u0437 <a href=\"http:\/\/dscourse.mlclass.ru\">MLClass.ru<\/a>. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0446\u0438\u0444\u0440 <a href=\"https:\/\/www.kaggle.com\/c\/digit-recognizer\">Digit Recognizer<\/a> \u0441 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b Kaggle. \u0421\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0449\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0449\u0435 \u043d\u0435 \u043f\u043e\u0437\u0434\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u0443\u0440\u0441 <a href=\"http:\/\/dscourse.mlclass.ru\">\u041f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445<\/a>, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e\u043a\u0430\u0447\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438.  <\/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-265863","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265863","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=265863"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265863\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=265863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=265863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=265863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}