M2 was a little bit misleading. Could have mentioned it M_new_image. Calculated the same way as M1. It is the matrix of the newly to the App uploaded image whose distance to the other images (matrices) is to be calculated.
Same goes for M1; little bit misleading aswell. In my previous post M1 is the matrix of just one image. In my project i go this way: extract the features of the 10 images, transform them into a matrix, and bind them together
# 10 x 25088 matrix
M1 <- rbind(M1, M2, M3, M4, M5, M6, M7, M8, M9, M10)
#f 1x 25088 matrix (new image)
M2
When i calculate the distance between the 10 images and the new image, the output is as follows, where [2,] is the image against itself, resulting in one hundred percent similarity.
1-text2vec::dist2(M1, M2, method = "cosine")
WARN [2019-11-06 13:42:37] Sparsity will be lost - worth to calculate similarity instead of distance.
10 x 1 Matrix of class "dgeMatrix"
[,1]
[1,] 0.7930369
[2,] 1.0000000
[3,] 0.8383663
[4,] 0.8161694
[5,] 0.1866685
[6,] 0.1716610
[7,] 0.1950101
[8,] 0.1831219
[9,] 0.2744161
[10,] 0.2861535
When i deploy it to shinyapps, similarity goes down to ~.75 percent.