-
Notifications
You must be signed in to change notification settings - Fork 11
/
summary.rgcca_cv.r
56 lines (50 loc) · 1.46 KB
/
summary.rgcca_cv.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#' @export
#' @rdname summary
#' @order 2
summary.rgcca_cv <- function(object, type = c("sd", "quantile"), ...) {
stopifnot(is(object, "rgcca_cv"))
type <- type[1]
type <- match.arg(type, c("sd", "quantile"))
### Print parameters of the function
print_call(object$call)
params <- round(object$params, 3)
rownames(params) <- seq_len(NROW(params))
cat(fill = TRUE)
cat(paste0("Tuning parameters (", object$par_type, ") used: "), fill = TRUE)
print(params, quote = FALSE, ...)
cat("\n")
cat(paste0(
"Validation: ", object$validation,
ifelse(object$validation == "kfold",
paste0(
" with ", object$k, " folds and ",
object$n_run, " run(s))"
), ""
)
), "\n")
cat(paste("Prediction model:", object$prediction_model, "\n"))
cat("\n")
df <- format(object$stats, digits = 3)
if (type == "quantile") {
df <- df[, c(1, 4, 5, 6)]
colnames(df) <- c(
"Tuning parameters", paste("Median", object$metric), "Q1", "Q3"
)
} else {
df <- df[, c(1, 2, 3)]
colnames(df) <- c("Tuning parameters", paste("Mean", object$metric), "Sd")
}
print(df, ...)
cat("\n")
best <- which(apply(
object$params, 1, function(z) identical(z, object$best_params)
))
optimal_y <- object$stats[best, "mean"]
cat(strwrap(paste0(
"The best combination is: ",
object$stats$combinations[best],
" for a mean ", object$metric, " of ",
format(optimal_y, digits = 3)
), getOption("width")))
cat("\n")
}