memory optimization

This commit is contained in:
El Potaeto 2015-02-19 13:48:39 +01:00
parent 815789bed6
commit 56877338b7

View File

@ -9,6 +9,7 @@
#' @importFrom magrittr %>%
#' @importFrom Matrix colSums
#' @importFrom Matrix cBind
#' @importFrom Matrix sparseVector
#'
#' @param feature_names names of each feature as a character vector. Can be extracted from a sparse matrix (see example). If model dump already contains feature names, this argument should be \code{NULL}.
#'
@ -82,6 +83,10 @@ xgb.importance <- function(feature_names = NULL, filename_dump = NULL, model = N
stop("data/label: Provide the two arguments if you want co-occurence computation or none of them if you are not interested but not one of them only.")
}
if(class(label) == "numeric"){
if(sum(label == 0) / length(label) > 0.5) label <- as(label, "sparseVector")
}
if(is.null(model)){
text <- readLines(filename_dump)
} else {