Quickly cross-tabulates two binary vectors.
fast_crosstable(target, len_target, pos_target, feature)
target | target. |
---|---|
len_target | length of the target vector. |
pos_target | number of positive cases in the target vector. |
feature | feature vector. |
a vector of length four:
target +, feature+
target +, feature-
target -, feature+
target -, feature-
Input looks odd, but the function was build to be fast
subroutine of calc_ig
, which works on
many features but only one target.
Binary vector means a numeric vector with 0 or 1.
tar <- sample(0L:1, 100, replace = TRUE) feat <- sample(0L:1, 100, replace = TRUE) fast_crosstable(tar, length(tar), sum(tar), feat)#> [1] 22 25 21 32