Calculating Entropy
问题 I've tried for several hours to calculate the Entropy and I know I'm missing something. Hopefully someone here can give me an idea! EDIT: I think my formula is wrong! CODE: info <- function(CLASS.FREQ){ freq.class <- CLASS.FREQ info <- 0 for(i in 1:length(freq.class)){ if(freq.class[[i]] != 0){ # zero check in class entropy <- -sum(freq.class[[i]] * log2(freq.class[[i]])) #I calculate the entropy for each class i here }else{ entropy <- 0 } info <- info + entropy # sum up entropy from all