Skip to content

Commit

Permalink
Suppress NAN warnings when computing MDS of each cluster
Browse files Browse the repository at this point in the history
In general, inspection and convention supports the sqrt trasnformation of cosine dissimilarity matrix for MDS, to reduce the relative impact of very high dissimilarity scores and increases the relative impact of lower scores. Planning on a feature request to make this configurable.
  • Loading branch information
willgryan committed Feb 2, 2024
1 parent 013d5c0 commit 78c27a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/generate_themes.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ generate_themes <-
mds = avg_cluster_embeddings %>%
tibble::column_to_rownames("Cluster") %>%
as.matrix() %>%
cosine_dissimilarity(root = T) %>%
cosine_dissimilarity(root = TRUE) %>%
smacof::mds(type = "ordinal")

#Generate distinct categorical colors for plotting
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cosine_dissimilarity <- function(mat, root = FALSE) {
sim = sim %*% t(sim)

if(root == T) {
D_sim = stats::as.dist(sqrt(1 - sim))
D_sim = stats::as.dist(suppressWarnings(sqrt(1 - sim)))
} else {
D_sim = stats::as.dist(1 - sim)
}
Expand Down

0 comments on commit 78c27a6

Please sign in to comment.