topcvfNB <- function(k, listFeatureChoices, mismatchTuning, mismatchTesting){
## Error checking parameters
if(round(k) != k && k > 0){
stop("k must be a positive integer.")
}
## Aggregate mismatch scores for all folds in tuning/testing datasets
sumMismatchTuning <- Reduce("+", mismatchTuning)
sumMismatchTesting <- Reduce("+", mismatchTesting)
listFeatureChoices <- cbind(c(1:nrow(listFeatureChoices)),
listFeatureChoices,
sumMismatchTuning,
sumMismatchTesting)
## Subset top k combinations
topK <- sort(sumMismatchTuning)[1:k]
bestCombos <- which(sumMismatchTuning %in% topK)
if(length(bestCombos) > k){
bestCombos <- bestCombos[1:k]
}
return(bestCombos)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.