tests/test-existence_collision.R

library(FeatureHashing)
df <- data.frame(a = c("a,b,c", "a,c", "b,c", "a"))
m <- hashed.model.matrix(~ split(a, delim = ",", type = "existence") - 1, df, 
                         hash.size = 4, signed.hash = FALSE, create.mapping = TRUE)
hash.mapping(m)
stopifnot(m@x == 1)

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.