Bi-normal separation feature selection (BNS) in R I'm doing binary classification on highly dimensional text data, with a biased class distribution. After reading this paper, i found out about BNS feature selection. Is there any package that implements this (i can't find one)? How hard is to implement it by scratch?
Or is there another method (like PCA) which i can use to deal with this kind of data?
Thanks!
 A: I found this paper explained well how BNS was calculated. It is actually easy to write it from scratch in R. Each loop calculates the BNS score for one feature. You may need to modify the code below cater to your case.
names <- colnames(data)
all_feature_bns_score <- c()
for(i in 1:(ncol(data)-1)){
  compute_bns_column <- cbind.data.frame(data[,i], data$label)
# Get BNS score
  tp <- length(which(compute_bns_column[,2]==1 & compute_bns_column[,1]==1)) # number of positive cases with the feature
  tn <- length(which(compute_bns_column[,2]==1 & compute_bns_column[,1]==0)) # number of positive cases with-out the feature
  fp <- length(which(compute_bns_column[,2]==0 & compute_bns_column[,1]==1)) # number of negative cases with the feature
  fn <- length(which(compute_bns_column[,2]==0 & compute_bns_column[,1]==0)) # number of negative cases with-out the feature
  tpr <- tp/(tp+fn) # true positive ratio
  fpr <- fp/(fp+tn) # false positive ratio
  bns_score <- abs(qnorm(tpr)-qnorm(fpr))
  feature <- names[i]
  if(is.infinite(bns_score)){
    bns_score <- 0 # set infinite bns score to be 0
  }
  feature_bns_score <- cbind.data.frame(feature,tpr, fpr,bns_score)

  if(length(all_feature_bns_score) == 0){
    all_feature_bns_score <- feature_bns_score
  }else{
    all_feature_bns_score <- rbind.data.frame(all_feature_bns_score,feature_bns_score)
  }
}

