Learn R Programming

resemble (version 3.0.1)

diss_cosine: Cosine dissimilarity method constructor

Description

Creates a configuration object for computing cosine dissimilarity (also known as spectral angle mapper). Pass the result to dissimilarity() to compute the dissimilarity matrix.

The cosine dissimilarity between two observations x_ix_i and x_jx_j is:

c(x_i, x_j) = ^-1 _k=1^p x_i,k\, x_j,k _k=1^p x_i,k^2\, _k=1^p x_j,k^2c(x_i, x_j) = acos(sum_k x_i,k * x_j,k / (sqrt(sum_k x_i,k^2) * sqrt(sum_k x_j,k^2)))

where pp is the number of variables.

Usage

diss_cosine(center = TRUE, scale = FALSE)

Value

An object of class c("diss_cosine", "diss_method").

Arguments

center

Logical. Center the data before computing dissimilarities? Applied jointly to Xr and Xu if both are provided. Default TRUE.

scale

Logical. Scale the data before computing dissimilarities? Applied jointly to Xr and Xu if both are provided. Default FALSE.

See Also

dissimilarity, diss_euclidean, diss_mahalanobis

Examples

Run this code
m <- diss_cosine()
m <- diss_cosine(center = FALSE)

Run the code above in your browser using DataLab