tests/test-signed.hash.R

if (require(RUnit)) {
  library(FeatureHashing)
  m1 <- hashed.model.matrix(~ ., iris, hash.size = 64, signed.hash = TRUE)
  m2 <- hashed.model.matrix(~ ., iris, hash.size = 64, signed.hash = FALSE)
  checkTrue(Reduce(`|`, as.matrix(m1) < 0))
  for(j in 1:64) {
    m1.sign <- sign(sum(m1[,j]))
    checkEqualsNumeric(m1.sign * m1[,j], m2[,j])
  }
}

Try the FeatureHashing package in your browser

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

FeatureHashing documentation built on Oct. 31, 2022, 1:06 a.m.