#' Extract Model Information
#'
#' This function extracts performance information and best predictions from
#' a model list generated by the \code{\link{TrainLEs}} function.
#'
#' @param model.list List of models stored as \code{train} objects
#' @return Returns a list of performance metrics, as well as a matrix
#' storing the predictions made by the local expert models in the best-tuned
#' model (if parameters are tuned).
#' @import data.table
#' @export
ExtractModelInfo <- function(model.list){
# error if model.list is not correct
CheckModelList(model.list)
# take raw performance data and make it a data frame
performance <- lapply(model.list, ExtractPerformance)
accuracy <- sapply(performance, ExtractAccuracy)
accuracySD <- sapply(performance, ExtractAccuracySD)
kappa <- sapply(performance, ExtractKappa)
kappaSD <- sapply(performance, ExtractKappaSD)
performance <- data.frame(accuracy, accuracySD, kappa, kappaSD)
# take prediction data and refine to matrix of DOWN probabilities
best.preds <- lapply(model.list, ExtractBestPreds)
preds.matrix <- sapply(best.preds, ExtractDownProbs)
## TODO: make var.imp usable
#var.imp <- lapply(model.list, ExtractVarImp)
## TODO: append the numeric "y" column to predictions, sort predictions by rowIndex
out <- list("preds.matrix" = preds.matrix, "performance" = performance)
return(out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.