Description Usage Arguments Value Examples
Calculates a cosine similarity of either a matrix or between two vectors.
If given a matrix, will return a cosine-similarity matrix. If given two
vectors will calculate the cosine-similarity between the two. Specific
functions for cosine vectors or matrices can be called with
cosine_sim_vector
and cosine_sim_mat
respectively.
1 |
... |
Either a numerical matrix, or two numerical vectors of the same length. |
out A matrix if given a matrix, or a single number if given two vectors.
1 2 3 4 5 6 7 8 9 | # example matrix
mat <- as.matrix(iris[,1:4])
out <- cosine_sim(mat)
image(out)
# two vectors
a <- rnorm(20)
b <- rnorm(20)
cosine_sim(a, b)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.