# similarities: Pairwise Similarity Matrix Computation In text2vec: Modern Text Mining Framework for R

 similarities R Documentation

## 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"`

### Details

Computes the similarity matrix using given method.

`psim2` takes two matrices and return a single vector. giving the ‘parallel’ similarities of the vectors.

### 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`.

text2vec documentation built on Dec. 1, 2022, 1:18 a.m.