-#' compareToStandard
-#'
-#' Temporary function to compare agghoo to CV
-#' (TODO: extended, in another file, more tests - when faster code).
-#'
-#' @export
-compareToStandard <- function(df, t_idx, task = NA, rseed = -1) {
- if (rseed >= 0)
- set.seed(rseed)
- if (is.na(task))
- task <- ifelse(is.numeric(df[,t_idx]), "regression", "classification")
- n <- nrow(df)
- test_indices <- sample( n, round(n / ifelse(n >= 500, 10, 5)) )
- a <- agghoo(df[-test_indices,-t_idx], df[-test_indices,t_idx], task)
- a$fit(mode="agghoo") #default mode
- pa <- a$predict(df[test_indices,-t_idx])
- print(paste("error agghoo",
- ifelse(task == "classification",
- mean(p != df[test_indices,t_idx]),
- mean(abs(pa - df[test_indices,t_idx])))))
- # Compare with standard cross-validation:
- a$fit(mode="standard")
- ps <- a$predict(df[test_indices,-t_idx])
- print(paste("error CV",
- ifelse(task == "classification",
- mean(ps != df[test_indices,t_idx]),
- mean(abs(ps - df[test_indices,t_idx])))))