powered by
Quickly cross-tabulates two binary vectors.
fast_crosstable(target_b, len_target, pos_target, feature)
target in bits (as per as.bit).
as.bit
length of the target vector.
number of positive cases in the target vector.
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 as fast as possible subroutine of calc_ig, which works on many features but only one target.
calc_ig
# NOT RUN { tar <- sample(0L:1, 100, replace = TRUE) feat <- sample(0L:1, 100, replace = TRUE) library(bit) # used to code vector as bit fast_crosstable(as.bit(tar), length(tar), sum(tar), feat) # }
Run the code above in your browser using DataLab