tests/testthat/test-glove.R

context("GloVe")

logger = lgr::get_logger('rsparse')
logger$set_threshold('warn')


k = 10
tcm = crossprod(sign(movielens100k))

test_that("test GloVe", {
  model = GloVe$new(rank = k, x_max = 100, learning_rate = 0.1)
  res = model$fit_transform(tcm, n_iter = 3)
  # basic dimensions check
  expect_equal(ncol(res), k)
  expect_equal(nrow(res), nrow(tcm))
  expect_equal(rownames(tcm), rownames(tcm))
  expect_equal(colnames(tcm), colnames(model$components))
})

Try the rsparse package in your browser

Any scripts or data that you put into this service are public.

rsparse documentation built on June 28, 2024, 5:06 p.m.