Learn R Programming

text2vec (version 0.6)

similarities: Pairwise Similarity Matrix Computation

Description

sim2 calculates pairwise similarities between the rows of two data matrices. Note that some methods work only on sparse matrices and others work only on dense matrices.

psim2 calculates "parallel" similarities between the rows of two data matrices.

Usage

sim2(x, y = NULL, method = c("cosine", "jaccard"), norm = c("l2",
  "none"))

psim2(x, y, method = c("cosine", "jaccard"), norm = c("l2", "none"))

Arguments

x

first matrix.

y

second matrix. For sim2 y = NULL set by default. This means that we will assume y = x and calculate similarities between all rows of the x.

method

character, the similarity measure to be used. One of c("cosine", "jaccard").

norm

character = c("l2", "none") - how to scale input matrices. If they already scaled - use "none"

Value

sim2 returns matrix of similarities between each row of matrix x and each row of matrix y.

psim2 returns vector of "parallel" similarities between rows of x and y.

Details

Computes the similarity matrix using given method.

psim2 takes two matrices and return a single vector. giving the <U+2018>parallel<U+2019> similarities of the vectors.