matrix_similarity {sentiment.ai}R Documentation

Cosine Similarity

Description

Cosine Similarity

cosine_match()

Usage

cosine(x, y = NULL)

cosine_match(target, reference, keep_target_order = FALSE)

Arguments

x

A numeric vector or matrix

y

A numeric vector or matrix of the same dimensions as x

target

numeric matrix of j values where each row is one observation. Use row names as ID.

reference

numeric matrix of j values where each row is one observation. Use row names as ID.

keep_target_order

logical include column indicating original row order of target matrix.

Value

data.table containing ranked (1 = top) pairwise similarities between target and reference

Examples

## Not run: 
n <- 5
y <- matrix(rnorm(n * 512), ncol = 512)
x <- matrix(rnorm(n * 512), ncol = 512)

all.equal(cosine(x, y),
          text2vec::sim2(x, y))

## End(Not run)


[Package sentiment.ai version 0.1.1 Index]