col_mut_info | R Documentation |
Calculate mutual information for every column of a matrix or data frame. Only discrete values are allowed. For better performance, data frame is preferred.
col_mut_info(x, y, args = NULL)
x |
Matrix or data frame of discrete values (integers). Rows contain samples and columns contain features/variables. |
y |
Factor of class labels for the data samples. A response vector with one label for each row/component of |
args |
|
An output is a single matrix with the same number of columns as X and 1 row.
Change log:
0.1.0 Xiurui Zhu - Initiate the function.
infotheo::mutinformation
for the original computation
of mutual information in R (and also the computation methods).
col_mut_info_vec
for the vectorized version.
if (require("MASS", quietly = TRUE) == TRUE) {
data(cats)
print(res_cpp <- col_mut_info(round(cats[, 2L:3L]), cats[, 1L]))
# Validate with caTools::colAUC()
if ((require("infotheo", quietly = TRUE) == TRUE) &&
(require("magrittr", quietly = TRUE) == TRUE)) {
print(res_r <- sapply(round(cats[, 2L:3L]), infotheo::mutinformation, cats[, 1L]) %>%
{matrix(., nrow = 1L, dimnames = list(NULL, names(.)))})
identical(res_cpp, res_r)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.