2-dimensional "discursive space" representation of relationships between documents using Hellinger distances and UMAP.
Usage
umap(x, ...)
# S3 method for class 'matrix'
umap(x, include_data = FALSE, df = TRUE, ...)
# S3 method for class 'tmfast'
umap(x, k, ...)
# S3 method for class 'STM'
umap(x, doc_ids, ...)Value
Tibble with columns document, x, y when df = TRUE; otherwise
an object of class umap with components layout, knn, and config.
Methods (by class)
umap(matrix): Method for distance matricesumap(tmfast): Method for fittedtmfastobjectsumap(STM): Method for fittedSTMobjects
Examples
gamma = rdirichlet(26, 1, 5)
rownames(gamma) = letters
h_gamma = hellinger(gamma)
umap(h_gamma, df = TRUE)
#> # A tibble: 26 × 3
#> document x y
#> <chr> <dbl> <dbl>
#> 1 a -0.375 -0.768
#> 2 b 0.606 1.69
#> 3 c -0.938 -0.925
#> 4 d -1.34 -1.22
#> 5 e -1.48 -0.0102
#> 6 f 0.630 -1.61
#> 7 g -1.12 -1.62
#> 8 h 0.113 -0.977
#> 9 i 0.874 2.35
#> 10 j -0.983 -0.370
#> # ℹ 16 more rows
# \donttest{
set.seed(42)
theta = rdirichlet(30, 1, k = 3)
phi = rdirichlet(3, 0.1, k = 30)
corpus = draw_corpus(rep(50L, 30), theta, phi)
fitted = tmfast(corpus, n = 3)
umap(fitted, 3)
#> # A tibble: 30 × 3
#> document x y
#> <chr> <dbl> <dbl>
#> 1 1 1.06 -1.05
#> 2 2 -2.44 0.223
#> 3 3 1.35 0.636
#> 4 4 0.698 0.279
#> 5 5 1.92 -0.972
#> 6 6 0.532 -1.20
#> 7 7 0.582 -1.53
#> 8 8 1.74 0.0700
#> 9 9 -1.66 1.04
#> 10 10 1.56 -0.504
#> # ℹ 20 more rows
# }