#' @param dataHO Matrix or data.frame
#' @param targetHO Vector of targets (generally numeric or factor)
#' @param index Index of the model in 1...nmodels
get = function(dataHO, targetHO, index) {
private$gmodel(dataHO, targetHO, private$params[[index]])
#' @param dataHO Matrix or data.frame
#' @param targetHO Vector of targets (generally numeric or factor)
#' @param index Index of the model in 1...nmodels
get = function(dataHO, targetHO, index) {
private$gmodel(dataHO, targetHO, private$params[[index]])
function(dataHO, targetHO, param) {
require(rpart)
method <- ifelse(task == "classification", "class", "anova")
function(dataHO, targetHO, param) {
require(rpart)
method <- ifelse(task == "classification", "class", "anova")
df <- data.frame(cbind(dataHO, target=targetHO))
model <- rpart::rpart(target ~ ., df, method=method, control=list(cp=param))
df <- data.frame(cbind(dataHO, target=targetHO))
model <- rpart::rpart(target ~ ., df, method=method, control=list(cp=param))
- function(X) predict(model, X)
+ function(X) {
+ if (is.null(colnames(X)))
+ colnames(X) <- paste0("V", 1:ncol(X))
+ predict(model, as.data.frame(X))
+ }
r <- rpart(target ~ ., df, method="class", control=ctrl)
cps <- r$cptable[-1,1]
r <- rpart(target ~ ., df, method="class", control=ctrl)
cps <- r$cptable[-1,1]
step <- (length(cps) - 1) / 10
cps[unique(round(seq(1, length(cps), step)))]
}
step <- (length(cps) - 1) / 10
cps[unique(round(seq(1, length(cps), step)))]
}