diff --git a/R/RcppExports.R b/R/RcppExports.R index 1ab7b6196..5015f8180 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -241,6 +241,16 @@ sample_features_cpp <- function(m, n_features) { .Call(`_shapr_sample_features_cpp`, m, n_features) } +#' We here return a vector of strings/characters, i.e., a CharacterVector, +#' where each string is a space-separated list of integers. +#' @param m Integer The number of elements to sample from, i.e., the number of features. +#' @param n_features IntegerVector The number of features to sample for each feature combination. +#' @param paired_shap_sampling Logical Should we return both the sampled coalition S and its complement Sbar. +#' @keywords internal +sample_features_cpp_str_paired <- function(m, n_features, paired_shap_sampling = TRUE) { + .Call(`_shapr_sample_features_cpp_str_paired`, m, n_features, paired_shap_sampling) +} + #' Get imputed data #' #' @param index_xtrain Positive integer. Represents a sequence of row indices from \code{xtrain}, diff --git a/R/check_convergence.R b/R/check_convergence.R index b260d9a77..b6707dc71 100644 --- a/R/check_convergence.R +++ b/R/check_convergence.R @@ -13,14 +13,20 @@ check_convergence <- function(internal) { paired_shap_sampling <- internal$parameters$paired_shap_sampling n_shapley_values <- internal$parameters$n_shapley_values + n_sampled_coalitions <- internal$iter_list[[iter]]$n_sampled_coalitions exact <- internal$iter_list[[iter]]$exact + shap_names <- internal$parameters$shap_names + shap_names_with_none <- c("none", shap_names) + dt_shapley_est <- internal$iter_list[[iter]]$dt_shapley_est dt_shapley_sd <- internal$iter_list[[iter]]$dt_shapley_sd - n_sampled_coalitions <- internal$iter_list[[iter]]$n_coalitions - 2 # Subtract the zero and full predictions + if (!all.equal(names(dt_shapley_est), names(dt_shapley_sd))) { + stop("The column names of the dt_shapley_est and dt_shapley_df are not equal.") + } - max_sd <- dt_shapley_sd[, max(.SD, na.rm = TRUE), .SDcols = -1, by = .I]$V1 # Max per prediction + max_sd <- dt_shapley_sd[, max(.SD, na.rm = TRUE), .SDcols = shap_names_with_none, by = .I]$V1 # Max per prediction max_sd0 <- max_sd * sqrt(n_sampled_coalitions) # Scales UP the sd as it scales at this rate dt_shapley_est0 <- copy(dt_shapley_est) @@ -33,8 +39,8 @@ check_convergence <- function(internal) { } else { converged_exact <- FALSE if (!is.null(convergence_tol)) { - dt_shapley_est0[, maxval := max(.SD, na.rm = TRUE), .SDcols = -c(1, 2), by = .I] - dt_shapley_est0[, minval := min(.SD, na.rm = TRUE), .SDcols = -c(1, 2), by = .I] + dt_shapley_est0[, maxval := max(.SD, na.rm = TRUE), .SDcols = shap_names, by = .I] + dt_shapley_est0[, minval := min(.SD, na.rm = TRUE), .SDcols = shap_names, by = .I] dt_shapley_est0[, max_sd0 := max_sd0] dt_shapley_est0[, req_samples := (max_sd0 / ((maxval - minval) * convergence_tol))^2] dt_shapley_est0[, conv_measure := max_sd0 / ((maxval - minval) * sqrt(n_sampled_coalitions))] diff --git a/R/compute_estimates.R b/R/compute_estimates.R index 05b7fd1d8..c4b1c42f2 100644 --- a/R/compute_estimates.R +++ b/R/compute_estimates.R @@ -285,7 +285,7 @@ bootstrap_shapley <- function(internal, dt_vS, n_boot_samps = 100, seed = 123) { dt_vS_this <- dt_vS[, dt_cols, with = FALSE] result[[i]] <- bootstrap_shapley_inner(X, n_shapley_values, shap_names, internal, dt_vS_this, n_boot_samps, seed) } - result <- rbindlist(result, fill = TRUE) + result <- cbind(internal$parameters$output_labels, rbindlist(result, fill = TRUE)) } else { X <- internal$iter_list[[iter]]$X n_shapley_values <- internal$parameters$n_shapley_values @@ -310,8 +310,10 @@ bootstrap_shapley_inner <- function(X, n_shapley_values, shap_names, internal, d boot_sd_array <- array(NA, dim = c(n_explain, n_shapley_values + 1, n_boot_samps)) X_keep <- X_org[c(1, .N), .(id_coalition, coalitions, coalition_size, N)] - X_samp <- X_org[-c(1, .N), .(id_coalition, coalitions, coalition_size, N, shapley_weight, sample_freq)] - X_samp[, coalitions_tmp := sapply(coalitions, paste, collapse = " ")] + X_samp <- X_org[ + -c(1, .N), + .(id_coalition, coalitions, coalitions_str, coalition_size, N, shapley_weight, sample_freq) + ] n_coalitions_boot <- X_samp[, sum(sample_freq)] @@ -331,12 +333,12 @@ bootstrap_shapley_inner <- function(X, n_shapley_values, shap_names, internal, d X_boot00_paired <- copy(X_boot00[, .(coalitions, boot_id)]) X_boot00_paired[, coalitions := lapply(coalitions, function(x) seq(n_shapley_values)[-x])] - X_boot00_paired[, coalitions_tmp := sapply(coalitions, paste, collapse = " ")] + X_boot00_paired[, coalitions_str := sapply(coalitions, paste, collapse = " ")] # Extract the paired coalitions from X_samp X_boot00_paired <- merge(X_boot00_paired, - X_samp[, .(id_coalition, coalition_size, N, shapley_weight, coalitions_tmp)], - by = "coalitions_tmp" + X_samp[, .(id_coalition, coalition_size, N, shapley_weight, coalitions_str)], + by = "coalitions_str" ) X_boot0 <- rbind( X_boot00[, .(boot_id, id_coalition, coalitions, coalition_size, N)], diff --git a/R/prepare_next_iteration.R b/R/prepare_next_iteration.R index 13bd231bc..5628a2809 100644 --- a/R/prepare_next_iteration.R +++ b/R/prepare_next_iteration.R @@ -21,8 +21,10 @@ prepare_next_iteration <- function(internal) { est_remaining_coalitions <- internal$iter_list[[iter]]$est_remaining_coalitions n_coal_next_iter_factor <- internal$iter_list[[iter]]$n_coal_next_iter_factor - current_n_coalitions <- internal$iter_list[[iter]]$n_coalitions + current_n_coalitions <- internal$iter_list[[iter]]$n_sampled_coalitions + 2 # Used instead of n_coalitions to + # deal with forecast special case current_coal_samples <- internal$iter_list[[iter]]$coal_samples + current_coal_samples_n_unique <- internal$iter_list[[iter]]$coal_samples_n_unique if (is.null(fixed_n_coalitions_per_iter)) { proposal_next_n_coalitions <- current_n_coalitions + ceiling(est_remaining_coalitions * n_coal_next_iter_factor) @@ -69,6 +71,7 @@ prepare_next_iteration <- function(internal) { next_iter_list$prev_coal_samples <- current_coal_samples + next_iter_list$prev_coal_samples_n_unique <- current_coal_samples_n_unique } else { next_iter_list <- list() } diff --git a/R/print_iter.R b/R/print_iter.R index 174eea7ab..037f1c929 100644 --- a/R/print_iter.R +++ b/R/print_iter.R @@ -79,10 +79,9 @@ print_iter <- function(internal) { } if ("shapley" %in% verbose) { - n_explain <- internal$parameters$n_explain - - dt_shapley_est <- internal$iter_list[[iter]]$dt_shapley_est[, -1] - dt_shapley_sd <- internal$iter_list[[iter]]$dt_shapley_sd[, -1] + shap_names_with_none <- c("none", internal$parameters$shap_names) + dt_shapley_est <- internal$iter_list[[iter]]$dt_shapley_est[, shap_names_with_none, with = FALSE] + dt_shapley_sd <- internal$iter_list[[iter]]$dt_shapley_sd[, shap_names_with_none, with = FALSE] # Printing the current Shapley values matrix1 <- format(round(dt_shapley_est, 3), nsmall = 2, justify = "right") @@ -99,7 +98,7 @@ print_iter <- function(internal) { print_dt <- as.data.table(matrix1) } else { msg <- paste0(msg, "estimated Shapley values (sd)") - print_dt <- as.data.table(matrix(paste(matrix1, " (", matrix2, ") ", sep = ""), nrow = n_explain)) + print_dt <- as.data.table(matrix(paste(matrix1, " (", matrix2, ") ", sep = ""), nrow = nrow(matrix1))) } cli::cli_h3(msg) diff --git a/R/setup.R b/R/setup.R index 743764f23..5298dae21 100644 --- a/R/setup.R +++ b/R/setup.R @@ -524,7 +524,6 @@ get_extra_parameters <- function(internal, type) { internal$parameters$n_groups <- length(group) internal$parameters$group_names <- names(group) internal$parameters$group <- group - internal$parameters$n_shapley_values <- internal$parameters$n_groups if (type == "forecast") { if (internal$parameters$group_lags) { @@ -543,8 +542,9 @@ get_extra_parameters <- function(internal, type) { internal$parameters$n_groups <- NULL internal$parameters$group_names <- NULL internal$parameters$shap_names <- internal$parameters$feature_names - internal$parameters$n_shapley_values <- internal$parameters$n_features } + internal$parameters$n_shapley_values <- length(internal$parameters$shap_names) + # Get the number of unique approaches internal$parameters$n_approaches <- length(internal$parameters$approach) @@ -616,7 +616,7 @@ check_and_set_parameters <- function(internal, type) { # Check the arguments related to asymmetric and causal Shapley # Check the causal_ordering, which must happen before checking the causal sampling - internal <- check_and_set_causal_ordering(internal) + if (type == "normal") internal <- check_and_set_causal_ordering(internal) if (!is.null(internal$parameters$confounding)) internal <- check_and_set_confounding(internal) # Check the causal sampling @@ -798,7 +798,7 @@ check_and_set_asymmetric <- function(internal) { internal$objects$dt_valid_causal_coalitions[-c(1, .N), shapley_weight_norm := shapley_weight / sum(shapley_weight)] # Convert the coalitions to strings. Needed when sampling the coalitions in `sample_coalition_table()`. - internal$objects$dt_valid_causal_coalitions[, coalitions_tmp := sapply(coalitions, paste, collapse = " ")] + internal$objects$dt_valid_causal_coalitions[, coalitions_str := sapply(coalitions, paste, collapse = " ")] return(internal) } @@ -898,36 +898,36 @@ adjust_max_n_coalitions <- function(internal) { } } else { # group wise # Set max_n_coalitions to upper bound - if (is.null(max_n_coalitions) || max_n_coalitions > 2^n_groups) { - max_n_coalitions <- 2^n_groups + if (is.null(max_n_coalitions) || max_n_coalitions > 2^n_shapley_values) { + max_n_coalitions <- 2^n_shapley_values message( paste0( "Success with message:\n", - "max_n_coalitions is NULL or larger than or 2^n_groups = ", 2^n_groups, ", \n", - "and is therefore set to 2^n_groups = ", 2^n_groups, ".\n" + "max_n_coalitions is NULL or larger than or 2^n_groups = ", 2^n_shapley_values, ", \n", + "and is therefore set to 2^n_groups = ", 2^n_shapley_values, ".\n" ) ) } # Set max_n_coalitions to lower bound - if (isFALSE(is.null(max_n_coalitions)) && max_n_coalitions < min(10, n_groups + 1)) { - if (n_groups <= 3) { - max_n_coalitions <- 2^n_groups + if (isFALSE(is.null(max_n_coalitions)) && max_n_coalitions < min(10, n_shapley_values + 1)) { + if (n_shapley_values <= 3) { + max_n_coalitions <- 2^n_shapley_values message( paste0( "Success with message:\n", - "n_groups is smaller than or equal to 3, meaning there are so few unique coalitions (", 2^n_groups, ") ", - "that we should use all to get reliable results.\n", - "max_n_coalitions is therefore set to 2^n_groups = ", 2^n_groups, ".\n" + "n_groups is smaller than or equal to 3, meaning there are so few unique coalitions (", + 2^n_shapley_values, ") that we should use all to get reliable results.\n", + "max_n_coalitions is therefore set to 2^n_groups = ", 2^n_shapley_values, ".\n" ) ) } else { - max_n_coalitions <- min(10, n_groups + 1) + max_n_coalitions <- min(10, n_shapley_values + 1) message( paste0( "Success with message:\n", - "max_n_coalitions is smaller than max(10, n_groups + 1 = ", n_groups + 1, "),", + "max_n_coalitions is smaller than max(10, n_groups + 1 = ", n_shapley_values + 1, "),", "which will result in unreliable results.\n", - "It is therefore set to ", max(10, n_groups + 1), ".\n" + "It is therefore set to ", max(10, n_shapley_values + 1), ".\n" ) ) } @@ -943,6 +943,7 @@ check_max_n_coalitions_fc <- function(internal) { max_n_coalitions <- internal$parameters$max_n_coalitions n_features <- internal$parameters$n_features n_groups <- internal$parameters$n_groups + n_shapley_values <- internal$parameters$n_shapley_values type <- internal$parameters$type @@ -953,7 +954,7 @@ check_max_n_coalitions_fc <- function(internal) { xreg <- internal$data$xreg if (!is_groupwise) { - if (max_n_coalitions <= n_features) { + if (max_n_coalitions <= n_shapley_values) { stop(paste0( "`max_n_coalitions` (", max_n_coalitions, ") has to be greater than the number of ", "components to decompose the forecast onto:\n", @@ -962,7 +963,7 @@ check_max_n_coalitions_fc <- function(internal) { )) } } else { - if (max_n_coalitions <= n_groups) { + if (max_n_coalitions <= n_shapley_values) { stop(paste0( "`max_n_coalitions` (", max_n_coalitions, ") has to be greater than the number of ", "components to decompose the forecast onto:\n", @@ -1168,9 +1169,7 @@ check_and_set_iterative <- function(internal) { set_exact <- function(internal) { max_n_coalitions <- internal$parameters$max_n_coalitions - n_features <- internal$parameters$n_features - n_groups <- internal$parameters$n_groups - is_groupwise <- internal$parameters$is_groupwise + n_shapley_values <- internal$parameters$n_shapley_values iterative <- internal$parameters$iterative asymmetric <- internal$parameters$asymmetric max_n_coalitions_causal <- internal$parameters$max_n_coalitions_causal @@ -1178,8 +1177,7 @@ set_exact <- function(internal) { if (isFALSE(iterative) && ( (isTRUE(asymmetric) && max_n_coalitions == max_n_coalitions_causal) || - (isFALSE(is_groupwise) && max_n_coalitions == 2^n_features) || - (isTRUE(is_groupwise) && max_n_coalitions == 2^n_groups) + (max_n_coalitions == 2^n_shapley_values) ) ) { exact <- TRUE @@ -1455,6 +1453,11 @@ set_iterative_parameters <- function(internal, prev_iter_list = NULL) { iterative_args$initial_n_coalitions <- iterative_args$max_n_coalitions } + # If paired_shap_sampling is TRUE, we need the number of coalitions to be even + if (internal$parameters$paired_shap_sampling) { + iterative_args$initial_n_coalitions <- ceiling(iterative_args$initial_n_coalitions * 0.5) * 2 + } + check_iterative_args(iterative_args) # Translate any null input @@ -1644,7 +1647,8 @@ get_iterative_args_default <- function(internal, 5, internal$parameters$n_features, (2^internal$parameters$n_features) / 10 - ) + ), + internal$parameters$max_n_coalitions ) ), fixed_n_coalitions_per_iter = NULL, diff --git a/R/shapley_setup.R b/R/shapley_setup.R index c35a29f8c..9c69f69d1 100644 --- a/R/shapley_setup.R +++ b/R/shapley_setup.R @@ -26,13 +26,12 @@ shapley_setup <- function(internal) { n_coalitions <- internal$iter_list[[iter]]$n_coalitions exact <- internal$iter_list[[iter]]$exact prev_coal_samples <- internal$iter_list[[iter]]$prev_coal_samples + prev_coal_samples_n_unique <- internal$iter_list[[iter]]$prev_coal_samples_n_unique if ("progress" %in% verbose) { cli::cli_progress_step("Sampling coalitions") } - - # dt_valid_causal_coalitions is only relevant for asymmetric Shapley values X <- create_coalition_table( m = n_shapley_values, exact = exact, @@ -40,18 +39,16 @@ shapley_setup <- function(internal) { weight_zero_m = 10^6, paired_shap_sampling = paired_shap_sampling, prev_coal_samples = prev_coal_samples, + prev_coal_samples_n_unique = prev_coal_samples_n_unique, coal_feature_list = coal_feature_list, approach0 = approach, kernelSHAP_reweighting = kernelSHAP_reweighting, dt_valid_causal_coalitions = dt_valid_causal_coalitions ) + coalition_map <- X[, .(id_coalition, coalitions_str)] - coalition_map <- X[, .(id_coalition, - coalitions_str = sapply(coalitions, paste, collapse = " ") - )] - # Get weighted matrix ---------------- W <- weight_matrix( @@ -75,8 +72,11 @@ shapley_setup <- function(internal) { internal$parameters$exact <- TRUE # Since this means that all coalitions have been sampled } - # Updating n_coalitions in the end based on what is actually used. I don't think this is necessary now. TODO: Check. + # Updating n_coalitions in the end based on what is actually used. internal$iter_list[[iter]]$n_coalitions <- nrow(S) + # The number of sampled coalitions to be used for convergence detection only (exclude the zero and full prediction) + internal$iter_list[[iter]]$n_sampled_coalitions <- internal$iter_list[[iter]]$n_coalitions - 2 + # This will be obsolete later internal$parameters$group_num <- NULL # TODO: Checking whether I could just do this processing where needed @@ -84,23 +84,7 @@ shapley_setup <- function(internal) { if (isFALSE(exact)) { - # Storing the feature samples - repetitions <- X[-c(1, .N), sample_freq] - - unique_coal_samples <- X[-c(1, .N), coalitions] - - coal_samples <- unlist( - lapply( - seq_along(unique_coal_samples), - function(i) { - rep( - list(unique_coal_samples[[i]]), - repetitions[i] - ) - } - ), - recursive = FALSE - ) + coal_samples <- rep(X[-c(1, .N), coalitions_str], X[-c(1, .N), sample_freq]) } else { coal_samples <- NA } @@ -111,6 +95,7 @@ shapley_setup <- function(internal) { internal$iter_list[[iter]]$coalition_map <- coalition_map internal$iter_list[[iter]]$S_batch <- create_S_batch(internal) internal$iter_list[[iter]]$coal_samples <- coal_samples + internal$iter_list[[iter]]$coal_samples_n_unique <- nrow(X) - 2 # Subtract empty and grand coalition # If we are doing causal Shapley values, then get the step-wise data generating process for each coalition if (causal_sampling) { @@ -151,10 +136,20 @@ shapley_setup <- function(internal) { #' The value to use as a replacement for infinite coalition weights when doing numerical operations. #' @param paired_shap_sampling Logical. #' Whether to do paired sampling of coalitions. -#' @param prev_coal_samples List. -#' A list of previously sampled coalitions. +#' @param prev_coal_samples Character vector. +#' A vector of previously sampled coalitions as characters. +#' Each string contains a coalition and the feature indices in the coalition is separated by a space. +#' For example, "1 5 8" is a coalition with features 1, 5, and 8. +#' @param prev_coal_samples_n_unique Positive integer. +#' The number of unique coalitions in `prev_coal_samples`. +#' This is a separate argument to avoid recomputing the number unnecessarily. +#' @param n_samps_scale Positive integer. +#' Integer that scales the number of coalitions `n_coalitions` to sample as sampling is cheap, +#' while checking for `n_coalitions` unique coalitions is expensive, thus we over sample the +#' number of coalitions by a factor of `n_samps_scale` and determine when we have `n_coalitions` unique +#' coalitions and only use the coalitions up to this point and throw away the remaining coalitions. #' @param approach0 Character vector. -#' Contains the approach to be used for eastimation of each coalition size. Same as `approach` in `explain()`. +#' Contains the approach to be used for estimation of each coalition size. Same as `approach` in `explain()`. #' @param coal_feature_list List. #' A list mapping each coalition to the features it contains. #' @param dt_valid_causal_coalitions data.table. Only applicable for asymmetric Shapley @@ -165,7 +160,7 @@ shapley_setup <- function(internal) { #' #' @export #' -#' @author Nikolai Sellereite, Martin Jullum +#' @author Nikolai Sellereite, Martin Jullum, Lars Henry Berge Olsen #' #' @examples #' # All coalitions @@ -180,6 +175,8 @@ create_coalition_table <- function(m, weight_zero_m = 10^6, paired_shap_sampling = TRUE, prev_coal_samples = NULL, + prev_coal_samples_n_unique = NULL, + n_samps_scale = 10, coal_feature_list = as.list(seq_len(m)), approach0 = "gaussian", kernelSHAP_reweighting = "none", @@ -197,6 +194,8 @@ create_coalition_table <- function(m, weight_zero_m = weight_zero_m, paired_shap_sampling = paired_shap_sampling, prev_coal_samples = prev_coal_samples, + prev_coal_samples_n_unique = prev_coal_samples_n_unique, + n_samps_scale = n_samps_scale, kernelSHAP_reweighting = kernelSHAP_reweighting, dt_valid_causal_coalitions = dt_valid_causal_coalitions ) @@ -214,7 +213,7 @@ create_coalition_table <- function(m, if (length(approach0) > 1) { dt[!(coalition_size %in% c(0, m)), approach := approach0[coalition_size]] } else { - dt[, approach := approach0] + dt[, approach := approach0] # TODO: add that we only add approach to these rows: !(coalition_size %in% c(0, m)) } return(dt) @@ -280,6 +279,7 @@ exact_coalition_table <- function(m, dt_valid_causal_coalitions = NULL, weight_z dt <- data.table::data.table(id_coalition = seq_along(coalitions0)) dt[, coalitions := coalitions0] + dt[, coalitions_str := sapply(coalitions, paste, collapse = " ")] dt[, coalition_size := length(coalitions[[1]]), id_coalition] dt[, N := .N, coalition_size] dt[, shapley_weight := shapley_weights(m = m, N = N, n_components = coalition_size, weight_zero_m)] @@ -287,14 +287,16 @@ exact_coalition_table <- function(m, dt_valid_causal_coalitions = NULL, weight_z return(dt) } + #' @keywords internal sample_coalition_table <- function(m, n_coalitions = 200, weight_zero_m = 10^6, paired_shap_sampling = TRUE, prev_coal_samples = NULL, + prev_coal_samples_n_unique = NULL, kernelSHAP_reweighting, - valid_causal_coalitions = NULL, + n_samps_scale = 10, dt_valid_causal_coalitions = NULL) { # Setup coal_samp_vec <- seq(m - 1) @@ -302,131 +304,99 @@ sample_coalition_table <- function(m, w <- shapley_weights(m = m, N = n, coal_samp_vec) * n p <- w / sum(w) + # Check if we are to do asymmetric or symmetric/regular Shapley values + asymmetric <- !is.null(dt_valid_causal_coalitions) + if (!is.null(prev_coal_samples)) { + # Compute prev_coal_samples_n_unique if not provided + if (is.null(prev_coal_samples_n_unique)) prev_coal_samples_n_unique <- length(unique(prev_coal_samples)) coal_sample_all <- prev_coal_samples - unique_samples <- length(unique(prev_coal_samples)) + unique_samples <- prev_coal_samples_n_unique n_coalitions <- min(2^m, n_coalitions) # Adjusts for the the unique samples, zero and m samples } else { - coal_sample_all <- list() + coal_sample_all <- c() unique_samples <- 0 } - # Split in whether we do asymmetric or symmetric/regular Shapley values - if (!is.null(dt_valid_causal_coalitions)) { - # Asymmetric Shapley values - while (unique_samples < n_coalitions - 2) { # Sample until we have the right number of unique coalitions + # Loop until we have drawn enough unique samples + while (unique_samples < n_coalitions - 2) { + # Get the number of samples to draw + n_samps <- as.integer(n_coalitions * n_samps_scale / ifelse(paired_shap_sampling, 2, 1)) - # Get the number of causal coalitions to sample - n_samps <- n_coalitions - unique_samples - 2 # Sample -2 as we add zero and m samples below + # Sample the coalition sizes + coal_size_sample <- sample(x = coal_samp_vec, size = n_samps, replace = TRUE, prob = p) + # Sample the coalitions based on if we are computing regular/symmetric or asymmetric Shapley values + if (asymmetric) { # Sample the causal coalitions from the valid causal coalitions with the Shapley weight as the probability # The weights of each coalition size is split evenly among the members of each coalition size, such that - # all.equal(p, dt_valid_causal_coalitions[-c(1,.N), sum(shapley_weight), by = coalition_size][, V1]) - coal_sample <- - dt_valid_causal_coalitions[-c(1, .N)][sample(.N, n_samps, replace = TRUE, prob = shapley_weight), coalitions] - - # Add the samples - coal_sample_all <- c(coal_sample_all, coal_sample) - - # Find the number of unique samples - unique_samples <- length(unique(coal_sample_all)) + # all.equal(p, dt_valid_causal_coalitions[-c(1,.N), sum(shapley_weight_norm), by = coalition_size][, V1]) + coalitions <- + dt_valid_causal_coalitions[-c(1, .N)][ + sample(.N, n_samps, replace = TRUE, prob = shapley_weight), coalitions_str + ] + } else { + # Sample the (paired) coalitions as strings + coalitions <- sample_features_cpp_str_paired(m, coal_size_sample, paired_shap_sampling) } - } else { - # Symmetric/regular Shapley values - while (unique_samples < n_coalitions - 2) { # Sample until we have the right number of unique coalitions - if (paired_shap_sampling == TRUE) { - n_samps <- ceiling((n_coalitions - unique_samples - 2) / 2) # Sample -2 as we add zero and m samples below - } else { - n_samps <- n_coalitions - unique_samples - 2 # Sample -2 as we add zero and m samples below - } - # Sample the coalition size ---------- - coal_size_sample <- sample( - x = coal_samp_vec, - size = n_samps, - replace = TRUE, - prob = p - ) - - # Sample specific coalitions ------- - coal_sample <- sample_features_cpp(m, coal_size_sample) - if (paired_shap_sampling == TRUE) { - coal_sample_paired <- lapply(coal_sample, function(x) seq(m)[-x]) - coal_sample_all <- c(coal_sample_all, coal_sample, coal_sample_paired) - } else { - coal_sample_all <- c(coal_sample_all, coal_sample) - } - unique_samples <- length(unique(coal_sample_all)) - } - } + # Add the new coalitions to the previously sampled coalitions + coal_sample_all <- c(coal_sample_all, coalitions) - # Add zero and full prediction - coal_sample_all <- c(list(integer(0)), coal_sample_all, list(c(1:m))) - X <- data.table(coalition_size = sapply(coal_sample_all, length)) - X[, coalition_size := as.integer(coalition_size)] - - # Get number of occurences and duplicated rows------- - is_duplicate <- NULL # due to NSE notes in R CMD check - r <- helper_feature(m, coal_sample_all) - X[, is_duplicate := r[["is_duplicate"]]] - - # When we sample coalitions the Shapley weight is equal - # to the frequency of the given coalition - X[, sample_freq := r[["sample_frequence"]]] # We keep an unscaled version of the sampling frequency for bootstrapping - X[, shapley_weight := as.numeric(sample_freq)] # Convert to double for later calculations - - # Populate table and remove duplicated rows ------- - X[, coalitions := coal_sample_all] - if (any(X[["is_duplicate"]])) { - X <- X[is_duplicate == FALSE] - } - X[, is_duplicate := NULL] - data.table::setkeyv(X, "coalition_size") + # Get the cumulative number of unique coalitions for each coalition in coal_sample_all + dt_cumsum <- data.table(coalitions = coal_sample_all, N_S = cumsum(!duplicated(coal_sample_all)))[, L := .I] + # Extract rows where the N_S value increases (i.e., where we sample a new unique coalition) + dt_N_S_and_L <- dt_cumsum[N_S != data.table::shift(N_S, type = "lag", fill = 0)] - #### TODO: Check if this could be removed: #### - ### Start of possible removal ### - # Make feature list into character - X[, coalitions_tmp := sapply(coalitions, paste, collapse = " ")] - - # Aggregate weights by how many samples of a coalition we observe - X <- X[, .( - coalition_size = data.table::first(coalition_size), - shapley_weight = sum(shapley_weight), - sample_freq = sum(sample_freq), - coalitions = coalitions[1] - ), coalitions_tmp] - - #### End of possible removal #### - - data.table::setorder(X, coalition_size) - - # Add shapley weight and number of coalitions - X[c(1, .N), shapley_weight := weight_zero_m] - X[, N := 1] - ind <- X[, .I[data.table::between(coalition_size, 1, m - 1)]] - X[ind, p := p[coalition_size]] - - if (!is.null(dt_valid_causal_coalitions)) { - # Asymmetric Shapley values - # Get the number of coalitions of each coalition size from the `dt_valid_causal_coalitions` data table - X[dt_valid_causal_coalitions, on = "coalitions_tmp", N := i.N] - } else { - # Symmetric/regular Shapley values - X[ind, N := n[coalition_size]] + # Get the number of unique coalitions + unique_samples <- dt_N_S_and_L[.N, N_S] } - X[, coalitions_tmp := NULL] + # Post processing: keep only the coalitions until n_coalitions - 2 + coal_sample_all <- coal_sample_all[seq(dt_N_S_and_L[N_S == n_coalitions - 2, L])] + + ## Create the X data table for the sampled coalitions + X <- data.table(coalitions_str = coal_sample_all)[, .(sample_freq = .N), by = coalitions_str] + X[, shapley_weight := as.numeric(sample_freq)] + + # Convert coalition strings to vector of integers as in old setup. + X[, coalitions := lapply(strsplit(coalitions_str, " "), as.integer)] + X[, coalition_size := as.integer(sapply(coalitions, length))] # as.integer to match old format + X[, N := as.integer(n[coalition_size])] # use as.integer to match the format in the old code + X[, p := p[coalition_size]] + + # Add the empty and grand coalitions to X + X_empty_coalition <- data.table( + coalitions_str = NA_character_, # list(character(0)) makes column into a list instead of character vector + sample_freq = 1L, + shapley_weight = weight_zero_m, + coalitions = list(integer(0)), # empty coalition. Need to be list for this to be a data.table of one row + coalition_size = 0L, + N = 1L, + p = NA + ) + X_full_coalition <- data.table( + coalitions_str = paste(seq(m), collapse = " "), + sample_freq = 1L, + shapley_weight = weight_zero_m, + coalitions = list(seq(m)), + coalition_size = as.integer(m), + N = 1L, + p = NA + ) + X <- data.table::rbindlist(list(X_empty_coalition, X, X_full_coalition), use.names = TRUE) - # Set column order and key table + # Add id column and order the data table data.table::setkeyv(X, "coalition_size") + data.table::setorder(X, "coalition_size") X[, id_coalition := .I] - X[, N := as.integer(N)] - nms <- c("id_coalition", "coalitions", "coalition_size", "N", "shapley_weight", "p", "sample_freq") - data.table::setcolorder(X, nms) + colorder <- c("id_coalition", "coalitions", "coalitions_str", "coalition_size", "N", "shapley_weight", "p") + data.table::setcolorder(X, colorder) - kernelSHAP_reweighting(X, reweight = kernelSHAP_reweighting) # Reweights the shapley weights in X by reference + # Reweight the Shapley weights in X by reference + kernelSHAP_reweighting(X, reweight = kernelSHAP_reweighting) return(X) } @@ -676,7 +646,12 @@ shapley_setup_forecast <- function(internal) { n_coalitions <- internal$iter_list[[iter]]$n_coalitions exact <- internal$iter_list[[iter]]$exact - prev_coal_samples <- internal$iter_list[[iter]]$prev_coal_samples + + prev_coal_samples <- internal$iter_list[[iter]]$prev_coal_samples # A list of length length(horizon_features) + prev_coal_samples_n_unique <- internal$iter_list[[iter]]$prev_coal_samples_n_unique # Same as in the previous line + + # Lists to store the sampled coalitions for each horizon and the number of unique coalitions + coal_samples <- coal_samples_n_unique <- list() X_list <- W_list <- list() @@ -704,7 +679,8 @@ shapley_setup_forecast <- function(internal) { n_coalitions = n_coalitions_here, weight_zero_m = 10^6, paired_shap_sampling = paired_shap_sampling, - prev_coal_samples = prev_coal_samples, + prev_coal_samples = prev_coal_samples[[i]], + prev_coal_samples_n_unique = prev_coal_samples_n_unique[[i]], coal_feature_list = this_coal_feature_list, approach0 = approach, kernelSHAP_reweighting = kernelSHAP_reweighting @@ -714,6 +690,17 @@ shapley_setup_forecast <- function(internal) { X = X_list[[i]], normalize_W_weights = TRUE ) + + ### Store the coalitions for this horizon for the next iteration + # Getting the sampled coalitions for each horizon. We do not store this if exact, as then all is used. + if (isFALSE(exact)) { + coal_samples[[i]] <- rep(X_list[[i]][-c(1, .N), coalitions_str], X_list[[i]][-c(1, .N), sample_freq]) + } else { + coal_samples[[i]] <- NA + } + + # Extract the number of unique coalitions from the previous iteration + coal_samples_n_unique[[i]] <- nrow(X_list[[i]]) - 2 # Subtract empty and grand coalition } # Merge the coalition data.table to single one to use for computing conditional expectations later on @@ -737,6 +724,8 @@ shapley_setup_forecast <- function(internal) { W <- NULL # Included for consistency. Necessary weights are in W_list instead + # Note: it is correct to use features here and not coalitions as we do for normal shapley_setup(). + # This is because, here, for forecast, the features are a function of both coalitions and horizon. coalition_map <- X[, .(id_coalition, coalitions_str = sapply(features, paste, collapse = " ") )] @@ -758,6 +747,10 @@ shapley_setup_forecast <- function(internal) { internal$iter_list[[iter]]$n_coalitions <- nrow(S) # Updating this parameter in the end based on what is used. + # The number of sampled coalitions *per horizon* to be used for convergence detection only + # Exclude the zero and full prediction + internal$iter_list[[iter]]$n_sampled_coalitions <- length(unique(id_coalition_mapper_dt$horizon_id_coalition)) - 2 + # This will be obsolete later internal$parameters$group_num <- NULL # TODO: Checking whether I could just do this processing where needed # instead of storing it @@ -769,6 +762,8 @@ shapley_setup_forecast <- function(internal) { internal$iter_list[[iter]]$X_list <- X_list internal$iter_list[[iter]]$coalition_map <- coalition_map internal$iter_list[[iter]]$S_batch <- create_S_batch(internal) + internal$iter_list[[iter]]$coal_samples <- coal_samples + internal$iter_list[[iter]]$coal_samples_n_unique <- coal_samples_n_unique internal$objects$cols_per_horizon <- cols_per_horizon internal$objects$W_list <- W_list diff --git a/R/timing.R b/R/timing.R index 2b3188a28..cb1f6c4b3 100644 --- a/R/timing.R +++ b/R/timing.R @@ -27,8 +27,8 @@ compute_time <- function(internal) { units = "secs" )) } - iter_timing_secs_dt <- data.table::rbindlist(iter_timing_secs_list) - iter_timing_secs_dt[, total := rowSums(.SD)] + iter_timing_secs_dt <- data.table::rbindlist(iter_timing_secs_list, fill = TRUE) + iter_timing_secs_dt[, total := rowSums(.SD, na.rm = TRUE)] iter_timing_secs_dt[, iter := .I] data.table::setcolorder(iter_timing_secs_dt, "iter") diff --git a/R/zzz.R b/R/zzz.R index a1458be87..6e027e6c0 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -122,7 +122,6 @@ "total", "coalitions", "coalition_size", - "coalitions_tmp", "initial_n_coalitions", "max_n_coalitions", "fixed_n_coalitions_per_iter", @@ -152,7 +151,9 @@ "relevant_features", "i.N", "prob", - "shapley_weight_norm" + "shapley_weight_norm", + "L", + "N_S" ) ) diff --git a/inst/scripts/devel/Rcpp_paired_string_coalition_sampling.R b/inst/scripts/devel/Rcpp_paired_string_coalition_sampling.R new file mode 100644 index 000000000..685c5405e --- /dev/null +++ b/inst/scripts/devel/Rcpp_paired_string_coalition_sampling.R @@ -0,0 +1,217 @@ +# Below we include other versions of the C++ function that we have tried. +# However, they were slower than the new version. + + +# #include +# #include +# #include +# #include +# using namespace Rcpp; +# // [[Rcpp::export]] +# IntegerVector get_complement(int m, IntegerVector k) { +# // Create a set with all integers from 1 to m +# std::set all_numbers; +# for (int i = 1; i <= m; ++i) { +# all_numbers.insert(i); +# } +# +# // Erase elements that are present in k +# for (int i = 0; i < k.size(); ++i) { +# all_numbers.erase(k[i]); +# } +# +# // Convert the set to an IntegerVector +# IntegerVector complement(all_numbers.begin(), all_numbers.end()); +# +# return complement; +# } +# +# //' @keywords internal +# // [[Rcpp::export]] +# CharacterVector sample_features_cpp_str_paired1(int m, IntegerVector n_features, bool paired_shap_sampling = true) { +# +# int n = n_features.length(); +# int result_size = paired_shap_sampling ? 2 * n : n; +# CharacterVector result(result_size); +# +# for (int i = 0; i < n; i++) { +# +# int s = n_features[i]; +# IntegerVector k = sample(m, s); +# std::sort(k.begin(), k.end()); +# +# // Convert sampled features to a comma-separated string +# std::stringstream ss; +# for (int j = 0; j < s; j++) { +# if (j != 0) { +# ss << ","; +# } +# ss << k[j]; +# } +# result[i * (paired_shap_sampling ? 2 : 1)] = ss.str(); +# +# if (paired_shap_sampling) { +# // Get complement and convert to string +# IntegerVector complement = get_complement(m, k); +# std::stringstream paired_ss; +# for (int j = 0; j < complement.size(); j++) { +# if (j != 0) { +# paired_ss << ","; +# } +# paired_ss << complement[j]; +# } +# result[i * 2 + 1] = paired_ss.str(); +# } +# } +# +# return result; +# } +# +# +# //' @keywords internal +# // [[Rcpp::export]] +# CharacterVector sample_features_cpp_str_paired2(int m, IntegerVector n_features, bool paired_shap_sampling = true) { +# +# int n = n_features.length(); +# int result_size = paired_shap_sampling ? 2 * n : n; +# CharacterVector result(result_size); +# +# for (int i = 0; i < n; i++) { +# +# int s = n_features[i]; +# IntegerVector k = sample(m, s); +# std::sort(k.begin(), k.end()); +# +# // Convert sampled features to a comma-separated string +# std::stringstream ss; +# for (int j = 0; j < s; j++) { +# if (j != 0) { +# ss << ","; +# } +# ss << k[j]; +# } +# result[i * (paired_shap_sampling ? 2 : 1)] = ss.str(); +# +# if (paired_shap_sampling) { +# // Collect integers from 1 to m not in k +# std::stringstream paired_ss; +# for (int j = 1; j <= m; j++) { +# if (std::find(k.begin(), k.end(), j) == k.end()) { +# if (paired_ss.tellp() > 0) { +# paired_ss << ","; +# } +# paired_ss << j; +# } +# } +# result[i * 2 + 1] = paired_ss.str(); +# } +# } +# +# return result; +# } +# +# +# //' @keywords internal +# // [[Rcpp::export]] +# CharacterVector sample_features_cpp_str_paired3(int m, IntegerVector n_features, bool paired_shap_sampling = true) { +# +# int n = n_features.size(); +# int result_size = paired_shap_sampling ? 2 * n : n; +# CharacterVector result(result_size); +# +# for (int i = 0; i < n; i++) { +# +# int s = n_features[i]; +# IntegerVector k = sample(m, s); +# std::sort(k.begin(), k.end()); +# +# // Convert sampled features to a comma-separated string +# std::stringstream ss; +# for (int j = 0; j < s; j++) { +# if (j != 0) { +# ss << ","; +# } +# ss << k[j]; +# } +# result[i * (paired_shap_sampling ? 2 : 1)] = ss.str(); +# +# if (paired_shap_sampling) { +# // Use a boolean vector to mark presence of elements in k +# std::vector present(m + 1, false); +# for (int idx = 0; idx < s; idx++) { +# present[k[idx]] = true; +# } +# +# // Build the complement string +# std::stringstream paired_ss; +# for (int j = 1; j <= m; j++) { +# if (!present[j]) { +# if (paired_ss.tellp() > 0) { +# paired_ss << ","; +# } +# paired_ss << j; +# } +# } +# result[i * 2 + 1] = paired_ss.str(); +# } +# } +# +# return result; +# } +# +# +# +# +# //' @keywords internal +# // [[Rcpp::export]] +# CharacterVector sample_features_cpp_str_paired4(int m, IntegerVector n_features, bool paired_shap_sampling = true) { +# +# int n = n_features.size(); +# int result_size = paired_shap_sampling ? 2 * n : n; +# CharacterVector result(result_size); +# +# for (int i = 0; i < n; i++) { +# +# int s = n_features[i]; +# IntegerVector k = sample(m, s); +# std::sort(k.begin(), k.end()); +# +# // Use a boolean vector to mark presence of elements in k +# std::vector present(m + 1, false); +# for (int idx = 0; idx < s; idx++) { +# present[k[idx]] = true; +# } +# +# // Generate both the ss and paired_ss strings in a single pass +# std::stringstream ss; +# std::stringstream paired_ss; +# bool first_ss = true; +# bool first_paired_ss = true; +# +# for (int j = 1; j <= m; j++) { +# if (present[j]) { +# if (!first_ss) { +# ss << ","; +# } else { +# first_ss = false; +# } +# ss << j; +# } else if (paired_shap_sampling) { +# if (!first_paired_ss) { +# paired_ss << ","; +# } else { +# first_paired_ss = false; +# } +# paired_ss << j; +# } +# } +# +# result[i * (paired_shap_sampling ? 2 : 1)] = ss.str(); +# +# if (paired_shap_sampling) { +# result[i * 2 + 1] = paired_ss.str(); +# } +# } +# +# return result; +# } diff --git a/man/create_coalition_table.Rd b/man/create_coalition_table.Rd index 1b340f207..d57bac3cf 100644 --- a/man/create_coalition_table.Rd +++ b/man/create_coalition_table.Rd @@ -11,6 +11,8 @@ create_coalition_table( weight_zero_m = 10^6, paired_shap_sampling = TRUE, prev_coal_samples = NULL, + prev_coal_samples_n_unique = NULL, + n_samps_scale = 10, coal_feature_list = as.list(seq_len(m)), approach0 = "gaussian", kernelSHAP_reweighting = "none", @@ -33,14 +35,26 @@ The value to use as a replacement for infinite coalition weights when doing nume \item{paired_shap_sampling}{Logical. Whether to do paired sampling of coalitions.} -\item{prev_coal_samples}{List. -A list of previously sampled coalitions.} +\item{prev_coal_samples}{Character vector. +A vector of previously sampled coalitions as characters. +Each string contains a coalition and the feature indices in the coalition is separated by a space. +For example, "1 5 8" is a coalition with features 1, 5, and 8.} + +\item{prev_coal_samples_n_unique}{Positive integer. +The number of unique coalitions in \code{prev_coal_samples}. +This is a separate argument to avoid recomputing the number unnecessarily.} + +\item{n_samps_scale}{Positive integer. +Integer that scales the number of coalitions \code{n_coalitions} to sample as sampling is cheap, +while checking for \code{n_coalitions} unique coalitions is expensive, thus we over sample the +number of coalitions by a factor of \code{n_samps_scale} and determine when we have \code{n_coalitions} unique +coalitions and only use the coalitions up to this point and throw away the remaining coalitions.} \item{coal_feature_list}{List. A list mapping each coalition to the features it contains.} \item{approach0}{Character vector. -Contains the approach to be used for eastimation of each coalition size. Same as \code{approach} in \code{explain()}.} +Contains the approach to be used for estimation of each coalition size. Same as \code{approach} in \code{explain()}.} \item{kernelSHAP_reweighting}{String. How to reweight the sampling frequency weights in the kernelSHAP solution after sampling, with the aim of reducing @@ -74,5 +88,5 @@ nrow(x) # Equals 2^3 = 8 x <- create_coalition_table(exact = FALSE, m = 10, n_coalitions = 1e2) } \author{ -Nikolai Sellereite, Martin Jullum +Nikolai Sellereite, Martin Jullum, Lars Henry Berge Olsen } diff --git a/man/get_iterative_args_default.Rd b/man/get_iterative_args_default.Rd index ca995d454..8c670801a 100644 --- a/man/get_iterative_args_default.Rd +++ b/man/get_iterative_args_default.Rd @@ -7,7 +7,7 @@ get_iterative_args_default( internal, initial_n_coalitions = ceiling(min(200, max(5, internal$parameters$n_features, - (2^internal$parameters$n_features)/10))), + (2^internal$parameters$n_features)/10), internal$parameters$max_n_coalitions)), fixed_n_coalitions_per_iter = NULL, max_iter = 20, convergence_tol = 0.02, diff --git a/man/sample_features_cpp_str_paired.Rd b/man/sample_features_cpp_str_paired.Rd new file mode 100644 index 000000000..93f33ba10 --- /dev/null +++ b/man/sample_features_cpp_str_paired.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/RcppExports.R +\name{sample_features_cpp_str_paired} +\alias{sample_features_cpp_str_paired} +\title{We here return a vector of strings/characters, i.e., a CharacterVector, +where each string is a space-separated list of integers.} +\usage{ +sample_features_cpp_str_paired(m, n_features, paired_shap_sampling = TRUE) +} +\arguments{ +\item{m}{Integer The number of elements to sample from, i.e., the number of features.} + +\item{n_features}{IntegerVector The number of features to sample for each feature combination.} + +\item{paired_shap_sampling}{Logical Should we return both the sampled coalition S and its complement Sbar.} +} +\description{ +We here return a vector of strings/characters, i.e., a CharacterVector, +where each string is a space-separated list of integers. +} +\keyword{internal} diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 3ed8157eb..dd8c04d25 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -195,6 +195,19 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// sample_features_cpp_str_paired +CharacterVector sample_features_cpp_str_paired(int m, IntegerVector n_features, bool paired_shap_sampling); +RcppExport SEXP _shapr_sample_features_cpp_str_paired(SEXP mSEXP, SEXP n_featuresSEXP, SEXP paired_shap_samplingSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< int >::type m(mSEXP); + Rcpp::traits::input_parameter< IntegerVector >::type n_features(n_featuresSEXP); + Rcpp::traits::input_parameter< bool >::type paired_shap_sampling(paired_shap_samplingSEXP); + rcpp_result_gen = Rcpp::wrap(sample_features_cpp_str_paired(m, n_features, paired_shap_sampling)); + return rcpp_result_gen; +END_RCPP +} // observation_impute_cpp NumericMatrix observation_impute_cpp(IntegerVector index_xtrain, IntegerVector index_s, NumericMatrix xtrain, NumericMatrix xtest, IntegerMatrix S); RcppExport SEXP _shapr_observation_impute_cpp(SEXP index_xtrainSEXP, SEXP index_sSEXP, SEXP xtrainSEXP, SEXP xtestSEXP, SEXP SSEXP) { @@ -251,6 +264,7 @@ static const R_CallMethodDef CallEntries[] = { {"_shapr_prepare_data_gaussian_cpp_caus", (DL_FUNC) &_shapr_prepare_data_gaussian_cpp_caus, 5}, {"_shapr_mahalanobis_distance_cpp", (DL_FUNC) &_shapr_mahalanobis_distance_cpp, 5}, {"_shapr_sample_features_cpp", (DL_FUNC) &_shapr_sample_features_cpp, 2}, + {"_shapr_sample_features_cpp_str_paired", (DL_FUNC) &_shapr_sample_features_cpp_str_paired, 3}, {"_shapr_observation_impute_cpp", (DL_FUNC) &_shapr_observation_impute_cpp, 5}, {"_shapr_weight_matrix_cpp", (DL_FUNC) &_shapr_weight_matrix_cpp, 4}, {"_shapr_coalition_matrix_cpp", (DL_FUNC) &_shapr_coalition_matrix_cpp, 2}, diff --git a/src/features.cpp b/src/features.cpp index f4d2e6749..65dcf77c1 100644 --- a/src/features.cpp +++ b/src/features.cpp @@ -19,3 +19,61 @@ List sample_features_cpp(int m, IntegerVector n_features) { return l; } + +//' We here return a vector of strings/characters, i.e., a CharacterVector, +//' where each string is a space-separated list of integers. +//' @param m Integer The number of elements to sample from, i.e., the number of features. +//' @param n_features IntegerVector The number of features to sample for each feature combination. +//' @param paired_shap_sampling Logical Should we return both the sampled coalition S and its complement Sbar. +//' @keywords internal +// [[Rcpp::export]] +CharacterVector sample_features_cpp_str_paired(int m, IntegerVector n_features, bool paired_shap_sampling = true) { + + int n = n_features.size(); + CharacterVector result(paired_shap_sampling ? 2 * n : n); + + for (int i = 0; i < n; i++) { + + int s = n_features[i]; + IntegerVector k = sample(m, s); + std::sort(k.begin(), k.end()); + + // Boolean vector to mark presence of elements in k + std::vector present(m + 1, false); + for (int idx = 0; idx < s; idx++) { + present[k[idx]] = true; + } + + // Generate both the ss and paired_ss strings in a single pass + std::stringstream ss; + std::stringstream paired_ss; + bool first_ss = true; + bool first_paired_ss = true; + + for (int j = 1; j <= m; j++) { + if (present[j]) { + if (!first_ss) { + ss << " "; + } else { + first_ss = false; + } + ss << j; + } else if (paired_shap_sampling) { + if (!first_paired_ss) { + paired_ss << " "; + } else { + first_paired_ss = false; + } + paired_ss << j; + } + } + + result[i * (paired_shap_sampling ? 2 : 1)] = ss.str(); + + if (paired_shap_sampling) { + result[i * 2 + 1] = paired_ss.str(); + } + } + + return result; +} diff --git a/tests/testthat/_snaps/asymmetric-causal-output.md b/tests/testthat/_snaps/asymmetric-causal-output.md index 0177b8b4d..09923a0cf 100644 --- a/tests/testthat/_snaps/asymmetric-causal-output.md +++ b/tests/testthat/_snaps/asymmetric-causal-output.md @@ -79,9 +79,9 @@ Output explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -11.352 15.017 14.540 -2.658 -2.945 - 2: 2 42.44 5.552 -6.256 -4.526 -6.666 -1.984 - 3: 3 42.44 9.720 -32.556 7.270 -3.377 1.374 + 1: 1 42.44 -11.446 14.923 14.754 -2.671 -2.958 + 2: 2 42.44 5.593 -6.215 -4.578 -6.680 -1.999 + 3: 3 42.44 9.719 -32.557 7.272 -3.376 1.375 # output_symmetric_conditional @@ -264,11 +264,11 @@ i Using 6 of 6 coalitions. Output - explain_id none Solar.R Wind Temp Month Day - - 1: 1 42.44 -17.410 26.305 13.958 -7.146 -3.105 - 2: 2 42.44 -2.592 5.563 -3.561 -11.136 -2.154 - 3: 3 42.44 21.260 -43.085 10.992 -8.054 1.319 + explain_id none Solar.R Wind Temp Month Day + + 1: 1 42.44 -25.73 21.4308 21.4308 -1.140 -3.3927 + 2: 2 42.44 -7.98 0.8414 0.8414 -5.149 -2.4328 + 3: 3 42.44 8.03 -12.3436 -12.3436 -1.848 0.9372 # output_asym_caus_conf_mix_empirical @@ -477,11 +477,11 @@ v Converged after 6 coalitions: Convergence tolerance reached! Output - explain_id none A B C - - 1: 1 42.44 -17.921 39.86 -9.334 - 2: 2 42.44 -2.802 -5.92 -5.157 - 3: 3 42.44 -2.233 -20.16 4.828 + explain_id none A B C + + 1: 1 42.44 -5.082 32.51 -14.823 + 2: 2 42.44 10.059 -29.61 5.675 + 3: 3 42.44 11.355 -23.68 -5.247 # output_mixed_sym_caus_conf_TRUE @@ -530,7 +530,7 @@ -- iterative computation started -- -- Iteration 1 ----------------------------------------------------------------- - i Using 5 of 32 coalitions, 5 new. + i Using 6 of 32 coalitions, 6 new. -- Iteration 2 ----------------------------------------------------------------- i Using 10 of 32 coalitions, 4 new. @@ -553,11 +553,11 @@ -- Iteration 8 ----------------------------------------------------------------- i Using 30 of 32 coalitions, 2 new. Output - explain_id none Solar.R Wind Temp Day Month_factor - - 1: 1 42.44 -2.13189 8.867 9.390 -1.137 -4.404 - 2: 2 42.44 0.07794 -7.916 -3.340 -1.378 -2.828 - 3: 3 42.44 -2.32289 -13.512 4.116 -1.343 2.462 + explain_id none Solar.R Wind Temp Day Month_factor + + 1: 1 42.44 -2.421 11.79 8.6450 -4.5647 -2.870 + 2: 2 42.44 3.042 -6.71 -4.2354 -4.0375 -3.442 + 3: 3 42.44 2.905 -18.44 -0.2186 0.2627 4.892 # output_mixed_asym_caus_conf_mixed @@ -642,9 +642,9 @@ Output explain_id none Solar.R Wind Temp Day Month_factor - 1: 1 42.44 -11.300 15.085 14.281 -2.2816 -5.201 - 2: 2 42.44 5.495 -6.312 -4.640 -1.6405 -8.286 - 3: 3 42.44 9.635 -32.764 7.451 0.8945 4.184 + 1: 1 42.44 -11.397 14.988 14.418 -2.2531 -5.172 + 2: 2 42.44 5.535 -6.273 -4.731 -1.6342 -8.280 + 3: 3 42.44 9.633 -32.766 7.516 0.8637 4.153 # output_categorical_asym_causal_mixed_cat @@ -694,7 +694,7 @@ -- iterative computation started -- -- Iteration 1 ----------------------------------------------------------------- - i Using 5 of 16 coalitions, 5 new. + i Using 6 of 16 coalitions, 6 new. -- Iteration 2 ----------------------------------------------------------------- i Using 8 of 16 coalitions, 2 new. @@ -710,9 +710,9 @@ Output explain_id none Month_factor Ozone_sub30_factor Solar.R_factor Wind_factor - 1: 1 42.44 -3.774 8.585 -10.6692 5.35 - 2: 2 42.44 -1.083 -14.855 19.0929 -17.99 - 3: 3 42.44 15.582 -17.251 -0.1388 -16.56 + 1: 1 42.44 -0.8228 14.26 -10.99 -2.961 + 2: 2 42.44 3.2689 -13.45 14.43 -19.089 + 3: 3 42.44 8.4092 -19.04 11.81 -19.535 # output_categorical_asym_causal_mixed_ctree diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_FALSE.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_FALSE.rds index 2c86f3888..2a08cc06c 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_FALSE.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_FALSE.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_TRUE.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_TRUE.rds index 7efc59830..fa4821384 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_TRUE.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_TRUE.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix.rds index 2f53b0bb0..c901ebb50 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_ctree.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_ctree.rds index 317c795b6..85a553a27 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_ctree.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_ctree.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_empirical.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_empirical.rds index 7ff35f3b1..43c946e9a 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_empirical.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_empirical.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_n_coal.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_n_coal.rds index 0d5093ecb..6d95508e0 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_n_coal.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_caus_conf_mix_n_coal.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_cond_reg.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_cond_reg.rds index 90492aadc..dc2689a6e 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_cond_reg.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_cond_reg.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_cond_reg_iterative.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_cond_reg_iterative.rds index d83b9f0cc..9465a84ad 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_asym_cond_reg_iterative.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_asym_cond_reg_iterative.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_asymmetric_conditional.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_asymmetric_conditional.rds index b14832cea..732f4e269 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_asymmetric_conditional.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_asymmetric_conditional.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_cat_asym_causal_mixed_cat_ad.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_cat_asym_causal_mixed_cat_ad.rds index 0430f2d08..11abc347f 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_cat_asym_causal_mixed_cat_ad.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_cat_asym_causal_mixed_cat_ad.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_categorical_asym_causal_mixed_cat.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_categorical_asym_causal_mixed_cat.rds index 9382e91c4..fe0207192 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_categorical_asym_causal_mixed_cat.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_categorical_asym_causal_mixed_cat.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_categorical_asym_causal_mixed_ctree.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_categorical_asym_causal_mixed_ctree.rds index dfa242805..08dd25982 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_categorical_asym_causal_mixed_ctree.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_categorical_asym_causal_mixed_ctree.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_asym_cond_reg.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_asym_cond_reg.rds index 19f4a5439..540fd7e3a 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_asym_cond_reg.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_asym_cond_reg.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_TRUE.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_TRUE.rds index acc0b0c51..a6fb285d9 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_TRUE.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_TRUE.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_TRUE_iterative.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_TRUE_iterative.rds index f57d561a5..680802d76 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_TRUE_iterative.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_TRUE_iterative.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_mixed.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_mixed.rds index 013be31f6..d32095646 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_mixed.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_mixed.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_mixed_2.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_mixed_2.rds index 728271154..c5dbcd54a 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_mixed_2.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_mixed_sym_caus_conf_mixed_2.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_FALSE.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_FALSE.rds index eb3acdebb..af7b297fe 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_FALSE.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_FALSE.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_TRUE.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_TRUE.rds index 254104338..2e2c2ef5a 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_TRUE.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_TRUE.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_TRUE_group.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_TRUE_group.rds index 113a728b3..e24c6f9c7 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_TRUE_group.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_TRUE_group.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix.rds index 6af3b48ce..bd07936bf 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix_group.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix_group.rds index 4b1707ef5..cec4e6798 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix_group.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix_group.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix_group_iterative.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix_group_iterative.rds index 8cf775a0e..eacb839b4 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix_group_iterative.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_sym_caus_conf_mix_group_iterative.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_conditional.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_conditional.rds index 17d3b04e1..59960450e 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_conditional.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_conditional.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_marginal_gaussian.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_marginal_gaussian.rds index 39833ddba..c4e191c6f 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_marginal_gaussian.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_marginal_gaussian.rds differ diff --git a/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_marginal_independence.rds b/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_marginal_independence.rds index 4f2cb1c49..055c60e32 100644 Binary files a/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_marginal_independence.rds and b/tests/testthat/_snaps/asymmetric-causal-output/output_symmetric_marginal_independence.rds differ diff --git a/tests/testthat/_snaps/forecast-output.md b/tests/testthat/_snaps/forecast-output.md index e2fae1c19..90e37175a 100644 --- a/tests/testthat/_snaps/forecast-output.md +++ b/tests/testthat/_snaps/forecast-output.md @@ -88,27 +88,30 @@ i Using 10 of 512 coalitions, 10 new. -- Iteration 2 ----------------------------------------------------------------- - i Using 30 of 512 coalitions, 4 new. + i Using 46 of 512 coalitions, 36 new. -- Iteration 3 ----------------------------------------------------------------- - i Using 78 of 512 coalitions, 6 new. + i Using 94 of 512 coalitions, 48 new. + + -- Iteration 4 ----------------------------------------------------------------- + i Using 150 of 512 coalitions, 56 new. Output - explain_idx horizon none Temp.1 Temp.2 Temp.3 Wind.1 Wind.2 Wind.3 - - 1: 149 1 77.88 -2.795 -4.5597 -1.114 1.564 -1.8995 0.2087 - 2: 150 1 77.88 4.024 -0.5774 -4.589 -2.234 0.1985 -2.2827 - 3: 149 2 77.88 -3.701 -4.2427 -1.326 1.465 -1.9227 0.7060 - 4: 150 2 77.88 3.460 -0.9158 -5.264 -2.452 0.7709 -1.7864 - 5: 149 3 77.88 -4.721 -3.4208 -1.503 1.172 -0.4564 -0.6058 - 6: 150 3 77.88 2.811 0.4206 -5.361 -1.388 0.0752 -0.2130 - Wind.F1 Wind.F2 Wind.F3 - - 1: -1.9118 NA NA - 2: -0.1747 NA NA - 3: -1.1883 -0.6744 NA - 4: 0.7128 1.9982 NA - 5: -1.5436 -0.5418 2.8952 - 6: -0.6202 -0.8545 0.4549 + explain_idx horizon none Temp.1 Temp.2 Temp.3 Wind.1 Wind.2 Wind.3 + + 1: 149 1 77.88 -3.327 -4.2474 -1.499 1.7231 -1.6078 0.31502 + 2: 150 1 77.88 3.781 -0.4774 -4.727 -2.0583 0.7566 -2.46020 + 3: 149 2 77.88 -3.475 -3.2166 -1.508 1.2872 -1.9965 0.02242 + 4: 150 2 77.88 3.491 -1.2376 -5.132 -1.8843 0.4237 -1.22244 + 5: 149 3 77.88 -4.394 -4.4730 -2.371 1.8591 -0.8661 0.55908 + 6: 150 3 77.88 3.131 -1.4060 -5.881 -0.8523 0.6045 -1.06403 + Wind.F1 Wind.F2 Wind.F3 + + 1: -1.8643 NA NA + 2: -0.4508 NA NA + 3: -1.5325 -0.4656 NA + 4: 0.7020 1.3828 NA + 5: -1.1902 0.5009 1.64924 + 6: 0.1562 0.6957 -0.06019 # forecast_output_arima_numeric_iterative_groups @@ -118,31 +121,35 @@ Note: Feature names extracted from the model contains NA. Consistency checks between model and data is therefore disabled. + Success with message: + max_n_coalitions is NULL or larger than or 2^n_groups = 16, + and is therefore set to 2^n_groups = 16. + * Model class: * Approach: empirical * Iterative estimation: TRUE - * Number of group-wise Shapley values: 10 + * Number of group-wise Shapley values: 4 * Number of observations to explain: 2 -- iterative computation started -- -- Iteration 1 ----------------------------------------------------------------- - i Using 10 of 1024 coalitions, 10 new. + i Using 10 of 16 coalitions, 10 new. -- Iteration 2 ----------------------------------------------------------------- - i Using 28 of 1024 coalitions, 2 new. + i Using 12 of 16 coalitions, 2 new. -- Iteration 3 ----------------------------------------------------------------- - i Using 56 of 1024 coalitions, 12 new. + i Using 14 of 16 coalitions, 2 new. Output - explain_idx horizon none Temp Wind Solar.R Ozone - - 1: 149 1 77.88 -4.680 -3.6712 0.3230 -1.253 - 2: 150 1 77.88 -2.487 -3.6317 1.8415 -0.891 - 3: 149 2 77.88 -6.032 -4.1973 2.5973 -2.402 - 4: 150 2 77.88 -3.124 0.1986 0.8258 -2.245 - 5: 149 3 77.88 -7.777 1.1382 0.6962 -3.267 - 6: 150 3 77.88 -3.142 -1.6674 2.9047 -2.024 + explain_idx horizon none Temp Wind Solar.R Ozone + + 1: 149 1 77.88 -5.219 -4.05598 -0.2082 0.2019 + 2: 150 1 77.88 -2.384 -3.44580 1.9219 -1.2607 + 3: 149 2 77.88 -5.807 -4.26464 2.1290 -2.0917 + 4: 150 2 77.88 -2.771 0.02034 0.5277 -2.1210 + 5: 149 3 77.88 -7.566 0.92425 0.9333 -3.5013 + 6: 150 3 77.88 -2.914 -1.92467 3.1653 -2.2555 # forecast_output_arima_numeric_no_xreg @@ -184,18 +191,18 @@ Consistency checks between model and data is therefore disabled. Success with message: - max_n_coalitions is NULL or larger than or 2^n_groups = 16, - and is therefore set to 2^n_groups = 16. + max_n_coalitions is NULL or larger than or 2^n_groups = 4, + and is therefore set to 2^n_groups = 4. * Model class: * Approach: empirical * Iterative estimation: FALSE - * Number of group-wise Shapley values: 4 + * Number of group-wise Shapley values: 2 * Number of observations to explain: 2 -- Main computation started -- - i Using 16 of 16 coalitions. + i Using 4 of 4 coalitions. Output explain_idx horizon none Temp Wind diff --git a/tests/testthat/_snaps/forecast-output/forecast_output_ar_numeric.rds b/tests/testthat/_snaps/forecast-output/forecast_output_ar_numeric.rds index f7ed98834..e9bf57118 100644 Binary files a/tests/testthat/_snaps/forecast-output/forecast_output_ar_numeric.rds and b/tests/testthat/_snaps/forecast-output/forecast_output_ar_numeric.rds differ diff --git a/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric.rds b/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric.rds index 3b42ce6c3..0a471368b 100644 Binary files a/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric.rds and b/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric.rds differ diff --git a/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_iterative.rds b/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_iterative.rds index 6a691f19b..2abc11892 100644 Binary files a/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_iterative.rds and b/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_iterative.rds differ diff --git a/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_iterative_groups.rds b/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_iterative_groups.rds index 0061a2ab8..facaff536 100644 Binary files a/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_iterative_groups.rds and b/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_iterative_groups.rds differ diff --git a/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_no_lags.rds b/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_no_lags.rds index c51ff8268..5780707a4 100644 Binary files a/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_no_lags.rds and b/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_no_lags.rds differ diff --git a/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_no_xreg.rds b/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_no_xreg.rds index 08001992a..a21e86828 100644 Binary files a/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_no_xreg.rds and b/tests/testthat/_snaps/forecast-output/forecast_output_arima_numeric_no_xreg.rds differ diff --git a/tests/testthat/_snaps/forecast-output/forecast_output_forecast_ARIMA_group_numeric.rds b/tests/testthat/_snaps/forecast-output/forecast_output_forecast_ARIMA_group_numeric.rds index 1ab8c99a1..b81a14aae 100644 Binary files a/tests/testthat/_snaps/forecast-output/forecast_output_forecast_ARIMA_group_numeric.rds and b/tests/testthat/_snaps/forecast-output/forecast_output_forecast_ARIMA_group_numeric.rds differ diff --git a/tests/testthat/_snaps/forecast-setup.md b/tests/testthat/_snaps/forecast-setup.md index fdf2616a9..44d81d43f 100644 --- a/tests/testthat/_snaps/forecast-setup.md +++ b/tests/testthat/_snaps/forecast-setup.md @@ -12,8 +12,8 @@ Consistency checks between model and data is therefore disabled. Success with message: - max_n_coalitions is NULL or larger than or 2^n_groups = 16, - and is therefore set to 2^n_groups = 16. + max_n_coalitions is NULL or larger than or 2^n_groups = 4, + and is therefore set to 2^n_groups = 4. Condition Error in `get_predict_model()`: @@ -94,7 +94,7 @@ "Temp"], xreg = data_arima[, "Wind"], train_idx = 2:148, explain_idx = 149:150, explain_y_lags = explain_y_lags, explain_xreg_lags = explain_xreg_lags, horizon = horizon, approach = "independence", phi0 = p0_ar, max_n_coalitions = n_coalitions, - group_lags = FALSE) + group_lags = FALSE, iterative_args = list(initial_n_coalitions = 20)) Message Note: Feature names extracted from the model contains NA. Consistency checks between model and data is therefore disabled. @@ -124,18 +124,18 @@ Consistency checks between model and data is therefore disabled. Success with message: - max_n_coalitions is smaller than max(10, n_groups + 1 = 5),which will result in unreliable results. - It is therefore set to 10. + n_groups is smaller than or equal to 3, meaning there are so few unique coalitions (4) that we should use all to get reliable results. + max_n_coalitions is therefore set to 2^n_groups = 4. * Model class: * Approach: independence * Iterative estimation: FALSE - * Number of group-wise Shapley values: 4 + * Number of group-wise Shapley values: 2 * Number of observations to explain: 2 -- Main computation started -- - i Using 5 of 16 coalitions. + i Using 4 of 4 coalitions. Output explain_idx horizon none Temp Wind diff --git a/tests/testthat/_snaps/iterative-output.md b/tests/testthat/_snaps/iterative-output.md index c3c2d8622..355e5249b 100644 --- a/tests/testthat/_snaps/iterative-output.md +++ b/tests/testthat/_snaps/iterative-output.md @@ -16,11 +16,11 @@ -- iterative computation started -- -- Iteration 1 ----------------------------------------------------------------- - i Using 5 of 32 coalitions, 5 new. + i Using 6 of 32 coalitions, 6 new. -- Convergence info i Not converged after 6 coalitions: - Current convergence measure: 0.31 [needs 0.02] + Current convergence measure: 0.3 [needs 0.02] Estimated remaining coalitions: 24 (Concervatively) adding 10% of that (4 coalitions) in the next iteration. @@ -28,14 +28,14 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) 0.258 (2.14) 0.258 (2.14) 17.463 (5.62) -5.635 (1.84) - 2: 42.444 (0.00) -0.986 (0.56) -0.986 (0.56) -5.286 (1.40) -5.635 (1.45) - 3: 42.444 (0.00) -4.493 (0.33) -4.493 (0.33) -1.495 (0.98) -2.595 (0.59) + 1: 42.444 (0.00) -0.580 (2.02) -0.580 (2.02) 17.463 (5.72) -0.580 (2.02) + 2: 42.444 (0.00) -2.189 (0.33) -2.189 (0.33) -5.286 (0.98) -2.189 (0.33) + 3: 42.444 (0.00) -5.778 (0.77) -5.778 (0.77) -1.495 (1.36) -5.778 (0.77) Day - 1: 0.258 (2.14) - 2: -0.986 (0.56) - 3: -4.493 (0.33) + 1: -3.121 (0.85) + 2: -2.025 (0.05) + 3: 1.261 (2.36) Message -- Iteration 2 ----------------------------------------------------------------- @@ -43,7 +43,7 @@ -- Convergence info i Not converged after 10 coalitions: - Current convergence measure: 0.18 [needs 0.02] + Current convergence measure: 0.17 [needs 0.02] Estimated remaining coalitions: 20 (Concervatively) adding 10% of that (2 coalitions) in the next iteration. @@ -51,14 +51,14 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.411 (3.37) 8.305 (3.82) 17.463 (3.50) -5.635 (0.19) - 2: 42.444 (0.00) 2.376 (1.47) -3.309 (1.07) -5.286 (1.24) -5.635 (1.02) - 3: 42.444 (0.00) 3.834 (3.22) -18.574 (5.10) -1.495 (2.37) -2.595 (0.83) + 1: 42.444 (0.00) -5.006 (2.08) 8.243 (2.94) 17.492 (3.64) -5.006 (2.08) + 2: 42.444 (0.00) -1.613 (0.31) -3.371 (0.43) -5.258 (0.61) -1.613 (0.31) + 3: 42.444 (0.00) 0.636 (1.88) -18.636 (4.36) -1.466 (2.25) 0.636 (1.88) Day - 1: -3.121 (3.24) - 2: -2.025 (1.13) - 3: 1.261 (4.44) + 1: -3.121 (0.65) + 2: -2.025 (0.13) + 3: 1.261 (0.55) Message -- Iteration 3 ----------------------------------------------------------------- @@ -66,7 +66,7 @@ -- Convergence info i Not converged after 12 coalitions: - Current convergence measure: 0.079 [needs 0.02] + Current convergence measure: 0.12 [needs 0.02] Estimated remaining coalitions: 18 (Concervatively) adding 20% of that (4 coalitions) in the next iteration. @@ -74,40 +74,63 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.467 (0.21) 8.284 (0.98) 17.485 (0.01) -5.635 (0.12) - 2: 42.444 (0.00) 2.320 (0.75) -3.331 (0.11) -5.264 (0.01) -5.635 (0.39) - 3: 42.444 (0.00) 3.778 (0.47) -18.596 (1.70) -1.473 (0.01) -2.595 (0.34) + 1: 42.444 (0.00) -5.021 (1.34) 8.258 (1.16) 17.485 (2.64) -5.021 (1.34) + 2: 42.444 (0.00) -1.627 (0.21) -3.357 (0.18) -5.265 (0.43) -1.627 (0.21) + 3: 42.444 (0.00) 0.622 (0.48) -18.622 (1.88) -1.473 (1.23) 0.622 (0.48) Day - 1: -3.065 (1.02) - 2: -1.969 (0.67) - 3: 1.317 (1.77) + 1: -3.099 (0.36) + 2: -2.004 (0.07) + 3: 1.283 (0.54) Message -- Iteration 4 ----------------------------------------------------------------- i Using 16 of 32 coalitions, 4 new. -- Convergence info - v Converged after 16 coalitions: + i Not converged after 16 coalitions: + Current convergence measure: 0.048 [needs 0.02] + Estimated remaining coalitions: 14 + (Concervatively) adding 30% of that (6 coalitions) in the next iteration. + + -- Current estimated Shapley values (sd) + Output + none Solar.R Wind Temp Month + + 1: 42.444 (0.00) -4.575 (0.10) 8.263 (0.68) 17.479 (0.01) -5.461 (0.70) + 2: 42.444 (0.00) 2.212 (0.84) -3.351 (0.10) -5.270 (0.01) -5.461 (0.86) + 3: 42.444 (0.00) 3.670 (0.67) -18.616 (0.81) -1.478 (0.01) -2.421 (1.08) + Day + + 1: -3.105 (0.12) + 2: -2.009 (0.17) + 3: 1.277 (0.18) + Message + + -- Iteration 5 ----------------------------------------------------------------- + i Using 22 of 32 coalitions, 6 new. + + -- Convergence info + v Converged after 22 coalitions: Convergence tolerance reached! -- Final estimated Shapley values (sd) Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.541 (0.05) 8.330 (0.80) 17.491 (0.02) -5.585 (0.02) - 2: 42.444 (0.00) 2.246 (0.05) -3.285 (0.10) -5.258 (0.02) -5.585 (0.02) - 3: 42.444 (0.00) 3.704 (0.05) -18.549 (1.40) -1.467 (0.02) -2.545 (0.02) + 1: 42.444 (0.00) -4.556 (0.02) 8.252 (0.01) 17.512 (0.01) -5.535 (0.02) + 2: 42.444 (0.00) 2.231 (0.02) -3.363 (0.01) -5.238 (0.01) -5.535 (0.02) + 3: 42.444 (0.00) 3.689 (0.02) -18.628 (0.01) -1.446 (0.01) -2.495 (0.02) Day - 1: -3.093 (0.80) - 2: -1.997 (0.10) - 3: 1.289 (1.40) + 1: -3.070 (0.01) + 2: -1.975 (0.01) + 3: 1.312 (0.01) explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -4.541 8.330 17.491 -5.585 -3.093 - 2: 2 42.44 2.246 -3.285 -5.258 -5.585 -1.997 - 3: 3 42.44 3.704 -18.549 -1.467 -2.545 1.289 + 1: 1 42.44 -4.556 8.252 17.512 -5.535 -3.070 + 2: 2 42.44 2.231 -3.363 -5.238 -5.535 -1.975 + 3: 3 42.44 3.689 -18.628 -1.446 -2.495 1.312 # output_lm_numeric_independence_converges_tol @@ -123,91 +146,69 @@ -- Convergence info i Not converged after 10 coalitions: - Current convergence measure: 0.19 [needs 0.1] - Estimated remaining coalitions: 20 + Current convergence measure: 0.16 [needs 0.1] + Estimated remaining coalitions: 8 (Concervatively) adding 10% of that (2 coalitions) in the next iteration. -- Current estimated Shapley values (sd) Output - none Solar.R Wind Temp Month - - 1: 42.444 (0.00) -4.591 (2.23) 8.215 (3.14) 17.463 (5.65) -5.545 (3.30) - 2: 42.444 (0.00) 2.196 (1.45) -3.399 (0.45) -5.286 (1.14) -5.545 (1.04) - 3: 42.444 (0.00) 3.654 (0.94) -18.664 (4.32) -1.495 (1.14) -2.505 (3.75) + none Solar.R Wind Temp Month + + 1: 42.444 (0.00) 1.919 (1.56) 1.919 (1.56) 17.492 (3.79) -5.607 (3.04) + 2: 42.444 (0.00) -0.495 (0.47) -0.495 (0.47) -5.258 (0.77) -5.607 (0.59) + 3: 42.444 (0.00) -7.398 (1.37) -7.398 (1.37) -1.466 (0.89) -2.567 (0.50) Day - 1: -2.940 (4.17) - 2: -1.845 (1.51) - 3: 1.442 (2.14) + 1: -3.121 (1.68) + 2: -2.025 (0.47) + 3: 1.261 (2.69) Message -- Iteration 2 ----------------------------------------------------------------- -- Convergence info i Not converged after 12 coalitions: - Current convergence measure: 0.14 [needs 0.1] - Estimated remaining coalitions: 8 + Current convergence measure: 0.2 [needs 0.1] + Estimated remaining coalitions: 14 (Concervatively) adding 10% of that (2 coalitions) in the next iteration. -- Current estimated Shapley values (sd) Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.591 (0.76) 8.215 (2.20) 17.463 (4.64) -5.545 (2.14) - 2: 42.444 (0.00) 2.196 (0.98) -3.399 (0.47) -5.286 (0.76) -5.545 (0.98) - 3: 42.444 (0.00) 3.654 (1.12) -18.664 (3.06) -1.495 (0.82) -2.505 (2.55) + 1: 42.444 (0.00) -4.467 (3.07) 8.305 (3.28) 17.491 (3.69) -5.607 (3.27) + 2: 42.444 (0.00) 2.320 (1.58) -3.309 (1.14) -5.258 (0.55) -5.607 (0.78) + 3: 42.444 (0.00) 3.778 (4.80) -18.574 (5.68) -1.467 (0.52) -2.567 (0.64) Day - 1: -2.940 (4.54) - 2: -1.845 (1.11) - 3: 1.442 (1.96) + 1: -3.121 (2.44) + 2: -2.025 (0.40) + 3: 1.261 (4.23) Message -- Iteration 3 ----------------------------------------------------------------- -- Convergence info - i Not converged after 14 coalitions: - Current convergence measure: 0.14 [needs 0.1] - Estimated remaining coalitions: 10 - (Concervatively) adding 20% of that (2 coalitions) in the next iteration. - - -- Current estimated Shapley values (sd) - Output - none Solar.R Wind Temp Month - - 1: 42.444 (0.00) -4.570 (0.87) 8.236 (1.92) 17.463 (4.97) -5.593 (1.32) - 2: 42.444 (0.00) 2.217 (0.66) -3.378 (0.33) -5.286 (0.86) -5.593 (0.26) - 3: 42.444 (0.00) 3.675 (0.52) -18.643 (3.19) -1.495 (0.72) -2.553 (1.19) - Day - - 1: -2.934 (4.68) - 2: -1.839 (1.06) - 3: 1.448 (3.00) - Message - - -- Iteration 4 ----------------------------------------------------------------- - - -- Convergence info - v Converged after 16 coalitions: + v Converged after 14 coalitions: Convergence tolerance reached! -- Final estimated Shapley values (sd) Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.538 (1.90) 8.268 (0.56) 17.523 (3.29) -5.589 (0.04) - 2: 42.444 (0.00) 2.249 (0.66) -3.347 (0.09) -5.227 (0.77) -5.589 (0.04) - 3: 42.444 (0.00) 3.707 (0.45) -18.611 (1.01) -1.435 (0.58) -2.549 (0.04) + 1: 42.444 (0.00) -4.425 (2.17) 8.241 (2.30) 17.490 (0.02) -5.609 (0.06) + 2: 42.444 (0.00) 2.362 (1.10) -3.373 (0.99) -5.260 (0.02) -5.609 (0.40) + 3: 42.444 (0.00) 3.820 (3.85) -18.638 (4.09) -1.468 (0.02) -2.569 (0.32) Day - 1: -3.061 (2.86) - 2: -1.966 (0.50) - 3: 1.321 (1.06) + 1: -3.094 (0.67) + 2: -1.999 (0.33) + 3: 1.288 (1.16) explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -4.538 8.268 17.523 -5.589 -3.061 - 2: 2 42.44 2.249 -3.347 -5.227 -5.589 -1.966 - 3: 3 42.44 3.707 -18.611 -1.435 -2.549 1.321 + 1: 1 42.44 -4.425 8.241 17.490 -5.609 -3.094 + 2: 2 42.44 2.362 -3.373 -5.260 -5.609 -1.999 + 3: 3 42.44 3.820 -18.638 -1.468 -2.569 1.288 # output_lm_numeric_independence_converges_maxit @@ -223,29 +224,29 @@ -- Convergence info i Not converged after 10 coalitions: - Current convergence measure: 0.19 [needs 0.001] + Current convergence measure: 0.16 [needs 0.001] Estimated remaining coalitions: 20 (Concervatively) adding 0.001% of that (2 coalitions) in the next iteration. -- Current estimated Shapley values (sd) Output - none Solar.R Wind Temp Month - - 1: 42.444 (0.00) -4.591 (2.23) 8.215 (3.14) 17.463 (5.65) -5.545 (3.30) - 2: 42.444 (0.00) 2.196 (1.45) -3.399 (0.45) -5.286 (1.14) -5.545 (1.04) - 3: 42.444 (0.00) 3.654 (0.94) -18.664 (4.32) -1.495 (1.14) -2.505 (3.75) + none Solar.R Wind Temp Month + + 1: 42.444 (0.00) 1.919 (1.56) 1.919 (1.56) 17.492 (3.79) -5.607 (3.04) + 2: 42.444 (0.00) -0.495 (0.47) -0.495 (0.47) -5.258 (0.77) -5.607 (0.59) + 3: 42.444 (0.00) -7.398 (1.37) -7.398 (1.37) -1.466 (0.89) -2.567 (0.50) Day - 1: -2.940 (4.17) - 2: -1.845 (1.51) - 3: 1.442 (2.14) + 1: -3.121 (1.68) + 2: -2.025 (0.47) + 3: 1.261 (2.69) Message -- Iteration 2 ----------------------------------------------------------------- -- Convergence info i Not converged after 12 coalitions: - Current convergence measure: 0.14 [needs 0.001] + Current convergence measure: 0.2 [needs 0.001] Estimated remaining coalitions: 18 (Concervatively) adding 0.001% of that (2 coalitions) in the next iteration. @@ -253,14 +254,14 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.591 (0.76) 8.215 (2.20) 17.463 (4.64) -5.545 (2.14) - 2: 42.444 (0.00) 2.196 (0.98) -3.399 (0.47) -5.286 (0.76) -5.545 (0.98) - 3: 42.444 (0.00) 3.654 (1.12) -18.664 (3.06) -1.495 (0.82) -2.505 (2.55) + 1: 42.444 (0.00) -4.467 (3.07) 8.305 (3.28) 17.491 (3.69) -5.607 (3.27) + 2: 42.444 (0.00) 2.320 (1.58) -3.309 (1.14) -5.258 (0.55) -5.607 (0.78) + 3: 42.444 (0.00) 3.778 (4.80) -18.574 (5.68) -1.467 (0.52) -2.567 (0.64) Day - 1: -2.940 (4.54) - 2: -1.845 (1.11) - 3: 1.442 (1.96) + 1: -3.121 (2.44) + 2: -2.025 (0.40) + 3: 1.261 (4.23) Message -- Iteration 3 ----------------------------------------------------------------- @@ -275,21 +276,21 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.570 (0.87) 8.236 (1.92) 17.463 (4.97) -5.593 (1.32) - 2: 42.444 (0.00) 2.217 (0.66) -3.378 (0.33) -5.286 (0.86) -5.593 (0.26) - 3: 42.444 (0.00) 3.675 (0.52) -18.643 (3.19) -1.495 (0.72) -2.553 (1.19) + 1: 42.444 (0.00) -4.425 (2.17) 8.241 (2.30) 17.490 (0.02) -5.609 (0.06) + 2: 42.444 (0.00) 2.362 (1.10) -3.373 (0.99) -5.260 (0.02) -5.609 (0.40) + 3: 42.444 (0.00) 3.820 (3.85) -18.638 (4.09) -1.468 (0.02) -2.569 (0.32) Day - 1: -2.934 (4.68) - 2: -1.839 (1.06) - 3: 1.448 (3.00) + 1: -3.094 (0.67) + 2: -1.999 (0.33) + 3: 1.288 (1.16) Message -- Iteration 4 ----------------------------------------------------------------- -- Convergence info i Not converged after 16 coalitions: - Current convergence measure: 0.099 [needs 0.001] + Current convergence measure: 0.056 [needs 0.001] Estimated remaining coalitions: 14 (Concervatively) adding 0.001% of that (2 coalitions) in the next iteration. @@ -297,21 +298,21 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.538 (1.90) 8.268 (0.56) 17.523 (3.29) -5.589 (0.04) - 2: 42.444 (0.00) 2.249 (0.66) -3.347 (0.09) -5.227 (0.77) -5.589 (0.04) - 3: 42.444 (0.00) 3.707 (0.45) -18.611 (1.01) -1.435 (0.58) -2.549 (0.04) + 1: 42.444 (0.00) -4.464 (1.27) 8.264 (0.63) 17.503 (1.10) -5.596 (0.11) + 2: 42.444 (0.00) 2.323 (0.84) -3.351 (0.29) -5.247 (0.38) -5.596 (0.68) + 3: 42.444 (0.00) 3.781 (1.26) -18.616 (1.12) -1.455 (0.27) -2.556 (0.55) Day - 1: -3.061 (2.86) - 2: -1.966 (0.50) - 3: 1.321 (1.06) + 1: -3.105 (0.07) + 2: -2.009 (0.22) + 3: 1.277 (0.13) Message -- Iteration 5 ----------------------------------------------------------------- -- Convergence info i Not converged after 18 coalitions: - Current convergence measure: 0.06 [needs 0.001] + Current convergence measure: 0.0021 [needs 0.001] Estimated remaining coalitions: 12 (Concervatively) adding 0.001% of that (2 coalitions) in the next iteration. @@ -319,39 +320,84 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.536 (1.11) 8.270 (0.03) 17.519 (2.34) -5.592 (1.16) - 2: 42.444 (0.00) 2.251 (0.47) -3.344 (0.03) -5.231 (0.47) -5.592 (0.03) - 3: 42.444 (0.00) 3.709 (0.30) -18.609 (0.03) -1.439 (0.36) -2.552 (0.06) + 1: 42.444 (0.00) -4.534 (0.05) 8.272 (0.02) 17.518 (0.03) -5.581 (0.05) + 2: 42.444 (0.00) 2.253 (0.05) -3.343 (0.02) -5.232 (0.03) -5.581 (0.05) + 3: 42.444 (0.00) 3.711 (0.05) -18.607 (0.02) -1.440 (0.03) -2.541 (0.05) Day - 1: -3.059 (1.77) - 2: -1.964 (0.42) - 3: 1.323 (0.30) + 1: -3.073 (0.02) + 2: -1.977 (0.02) + 3: 1.309 (0.02) Message -- Iteration 6 ----------------------------------------------------------------- -- Convergence info - v Converged after 20 coalitions: + i Not converged after 20 coalitions: + Current convergence measure: 0.014 [needs 0.001] + Estimated remaining coalitions: 10 + (Concervatively) adding 0.001% of that (2 coalitions) in the next iteration. + + -- Current estimated Shapley values (sd) + Output + none Solar.R Wind Temp Month + + 1: 42.444 (0.00) -4.538 (0.06) 8.273 (0.02) 17.522 (0.02) -5.585 (0.06) + 2: 42.444 (0.00) 2.249 (0.39) -3.341 (0.02) -5.228 (0.02) -5.585 (0.39) + 3: 42.444 (0.00) 3.707 (0.31) -18.606 (0.02) -1.436 (0.02) -2.545 (0.32) + Day + + 1: -3.070 (0.02) + 2: -1.975 (0.02) + 3: 1.312 (0.02) + Message + + -- Iteration 7 ----------------------------------------------------------------- + + -- Convergence info + i Not converged after 22 coalitions: + Current convergence measure: 0.0012 [needs 0.001] + Estimated remaining coalitions: 6 + (Concervatively) adding 0.001% of that (2 coalitions) in the next iteration. + + -- Current estimated Shapley values (sd) + Output + none Solar.R Wind Temp Month + + 1: 42.444 (0.00) -4.536 (0.03) 8.276 (0.02) 17.518 (0.01) -5.583 (0.02) + 2: 42.444 (0.00) 2.251 (0.03) -3.338 (0.02) -5.231 (0.01) -5.583 (0.02) + 3: 42.444 (0.00) 3.709 (0.03) -18.603 (0.02) -1.440 (0.01) -2.543 (0.02) + Day + + 1: -3.073 (0.02) + 2: -1.978 (0.02) + 3: 1.309 (0.02) + Message + + -- Iteration 8 ----------------------------------------------------------------- + + -- Convergence info + v Converged after 24 coalitions: Convergence tolerance reached! + Maximum number of iterations reached! -- Final estimated Shapley values (sd) Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.534 (0.01) 8.272 (0.01) 17.520 (0.01) -5.592 (0.01) - 2: 42.444 (0.00) 2.253 (0.01) -3.342 (0.01) -5.229 (0.01) -5.592 (0.01) - 3: 42.444 (0.00) 3.711 (0.01) -18.607 (0.01) -1.438 (0.01) -2.553 (0.01) + 1: 42.444 (0.00) -4.535 (0.02) 8.277 (0.01) 17.520 (0.01) -5.585 (0.01) + 2: 42.444 (0.00) 2.252 (0.02) -3.338 (0.01) -5.230 (0.01) -5.585 (0.01) + 3: 42.444 (0.00) 3.710 (0.02) -18.602 (0.01) -1.438 (0.01) -2.545 (0.01) Day - 1: -3.064 (0.01) - 2: -1.968 (0.01) - 3: 1.318 (0.01) + 1: -3.075 (0.01) + 2: -1.979 (0.01) + 3: 1.307 (0.01) explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -4.534 8.272 17.520 -5.592 -3.064 - 2: 2 42.44 2.253 -3.342 -5.229 -5.592 -1.968 - 3: 3 42.44 3.711 -18.607 -1.438 -2.553 1.318 + 1: 1 42.44 -4.535 8.277 17.520 -5.585 -3.075 + 2: 2 42.44 2.252 -3.338 -5.230 -5.585 -1.979 + 3: 3 42.44 3.710 -18.602 -1.438 -2.545 1.307 # output_lm_numeric_indep_conv_max_n_coalitions @@ -363,7 +409,7 @@ -- Convergence info i Not converged after 6 coalitions: - Current convergence measure: 0.31 [needs 0.02] + Current convergence measure: 0.3 [needs 0.02] Estimated remaining coalitions: 24 (Concervatively) adding 10% of that (4 coalitions) in the next iteration. @@ -371,21 +417,21 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) 0.258 (2.14) 0.258 (2.14) 17.463 (5.62) -5.635 (1.84) - 2: 42.444 (0.00) -0.986 (0.56) -0.986 (0.56) -5.286 (1.40) -5.635 (1.45) - 3: 42.444 (0.00) -4.493 (0.33) -4.493 (0.33) -1.495 (0.98) -2.595 (0.59) + 1: 42.444 (0.00) -0.580 (2.02) -0.580 (2.02) 17.463 (5.72) -0.580 (2.02) + 2: 42.444 (0.00) -2.189 (0.33) -2.189 (0.33) -5.286 (0.98) -2.189 (0.33) + 3: 42.444 (0.00) -5.778 (0.77) -5.778 (0.77) -1.495 (1.36) -5.778 (0.77) Day - 1: 0.258 (2.14) - 2: -0.986 (0.56) - 3: -4.493 (0.33) + 1: -3.121 (0.85) + 2: -2.025 (0.05) + 3: 1.261 (2.36) Message -- Iteration 2 ----------------------------------------------------------------- -- Convergence info i Not converged after 10 coalitions: - Current convergence measure: 0.18 [needs 0.02] + Current convergence measure: 0.17 [needs 0.02] Estimated remaining coalitions: 20 (Concervatively) adding 10% of that (2 coalitions) in the next iteration. @@ -393,21 +439,21 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.411 (3.37) 8.305 (3.82) 17.463 (3.50) -5.635 (0.19) - 2: 42.444 (0.00) 2.376 (1.47) -3.309 (1.07) -5.286 (1.24) -5.635 (1.02) - 3: 42.444 (0.00) 3.834 (3.22) -18.574 (5.10) -1.495 (2.37) -2.595 (0.83) + 1: 42.444 (0.00) -5.006 (2.08) 8.243 (2.94) 17.492 (3.64) -5.006 (2.08) + 2: 42.444 (0.00) -1.613 (0.31) -3.371 (0.43) -5.258 (0.61) -1.613 (0.31) + 3: 42.444 (0.00) 0.636 (1.88) -18.636 (4.36) -1.466 (2.25) 0.636 (1.88) Day - 1: -3.121 (3.24) - 2: -2.025 (1.13) - 3: 1.261 (4.44) + 1: -3.121 (0.65) + 2: -2.025 (0.13) + 3: 1.261 (0.55) Message -- Iteration 3 ----------------------------------------------------------------- -- Convergence info i Not converged after 12 coalitions: - Current convergence measure: 0.079 [needs 0.02] + Current convergence measure: 0.12 [needs 0.02] Estimated remaining coalitions: 18 (Concervatively) adding 20% of that (4 coalitions) in the next iteration. @@ -415,39 +461,62 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.467 (0.21) 8.284 (0.98) 17.485 (0.01) -5.635 (0.12) - 2: 42.444 (0.00) 2.320 (0.75) -3.331 (0.11) -5.264 (0.01) -5.635 (0.39) - 3: 42.444 (0.00) 3.778 (0.47) -18.596 (1.70) -1.473 (0.01) -2.595 (0.34) + 1: 42.444 (0.00) -5.021 (1.34) 8.258 (1.16) 17.485 (2.64) -5.021 (1.34) + 2: 42.444 (0.00) -1.627 (0.21) -3.357 (0.18) -5.265 (0.43) -1.627 (0.21) + 3: 42.444 (0.00) 0.622 (0.48) -18.622 (1.88) -1.473 (1.23) 0.622 (0.48) Day - 1: -3.065 (1.02) - 2: -1.969 (0.67) - 3: 1.317 (1.77) + 1: -3.099 (0.36) + 2: -2.004 (0.07) + 3: 1.283 (0.54) Message -- Iteration 4 ----------------------------------------------------------------- -- Convergence info - v Converged after 16 coalitions: + i Not converged after 16 coalitions: + Current convergence measure: 0.048 [needs 0.02] + Estimated remaining coalitions: 14 + (Concervatively) adding 30% of that (4 coalitions) in the next iteration. + + -- Current estimated Shapley values (sd) + Output + none Solar.R Wind Temp Month + + 1: 42.444 (0.00) -4.575 (0.10) 8.263 (0.68) 17.479 (0.01) -5.461 (0.70) + 2: 42.444 (0.00) 2.212 (0.84) -3.351 (0.10) -5.270 (0.01) -5.461 (0.86) + 3: 42.444 (0.00) 3.670 (0.67) -18.616 (0.81) -1.478 (0.01) -2.421 (1.08) + Day + + 1: -3.105 (0.12) + 2: -2.009 (0.17) + 3: 1.277 (0.18) + Message + + -- Iteration 5 ----------------------------------------------------------------- + + -- Convergence info + v Converged after 20 coalitions: Convergence tolerance reached! + Maximum number of coalitions reached! -- Final estimated Shapley values (sd) Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.541 (0.05) 8.330 (0.80) 17.491 (0.02) -5.585 (0.02) - 2: 42.444 (0.00) 2.246 (0.05) -3.285 (0.10) -5.258 (0.02) -5.585 (0.02) - 3: 42.444 (0.00) 3.704 (0.05) -18.549 (1.40) -1.467 (0.02) -2.545 (0.02) + 1: 42.444 (0.00) -4.568 (0.01) 8.261 (0.01) 17.506 (0.01) -5.511 (0.03) + 2: 42.444 (0.00) 2.219 (0.01) -3.353 (0.01) -5.243 (0.01) -5.511 (0.03) + 3: 42.444 (0.00) 3.677 (0.01) -18.618 (0.01) -1.452 (0.01) -2.471 (0.03) Day - 1: -3.093 (0.80) - 2: -1.997 (0.10) - 3: 1.289 (1.40) + 1: -3.086 (0.01) + 2: -1.991 (0.01) + 3: 1.296 (0.01) explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -4.541 8.330 17.491 -5.585 -3.093 - 2: 2 42.44 2.246 -3.285 -5.258 -5.585 -1.997 - 3: 3 42.44 3.704 -18.549 -1.467 -2.545 1.289 + 1: 1 42.44 -4.568 8.261 17.506 -5.511 -3.086 + 2: 2 42.44 2.219 -3.353 -5.243 -5.511 -1.991 + 3: 3 42.44 3.677 -18.618 -1.452 -2.471 1.296 # output_lm_numeric_gaussian_group_converges_tol @@ -469,14 +538,14 @@ Output none A B C - 1: 42.444 (0.00) 0.772 (2.66) 13.337 (3.49) -1.507 (3.31) - 2: 42.444 (0.00) 0.601 (2.97) -13.440 (3.32) -1.040 (2.77) - 3: 42.444 (0.00) -18.368 (3.91) 0.127 (3.95) 0.673 (0.12) + 1: 42.444 (0.00) 1.037 (2.52) 12.949 (3.35) -1.385 (3.20) + 2: 42.444 (0.00) 0.866 (3.11) -13.828 (3.46) -0.917 (2.88) + 3: 42.444 (0.00) -18.102 (3.77) -0.261 (3.86) 0.795 (0.24) explain_id none A B C - 1: 1 42.44 0.7716 13.3373 -1.5069 - 2: 2 42.44 0.6006 -13.4404 -1.0396 - 3: 3 42.44 -18.3678 0.1268 0.6728 + 1: 1 42.44 1.0372 12.9494 -1.3845 + 2: 2 42.44 0.8661 -13.8283 -0.9173 + 3: 3 42.44 -18.1023 -0.2611 0.7951 # output_lm_numeric_independence_converges_tol_paired @@ -492,91 +561,69 @@ -- Convergence info i Not converged after 10 coalitions: - Current convergence measure: 0.19 [needs 0.1] - Estimated remaining coalitions: 20 + Current convergence measure: 0.16 [needs 0.1] + Estimated remaining coalitions: 8 (Concervatively) adding 10% of that (2 coalitions) in the next iteration. -- Current estimated Shapley values (sd) Output - none Solar.R Wind Temp Month - - 1: 42.444 (0.00) -4.591 (2.23) 8.215 (3.14) 17.463 (5.65) -5.545 (3.30) - 2: 42.444 (0.00) 2.196 (1.45) -3.399 (0.45) -5.286 (1.14) -5.545 (1.04) - 3: 42.444 (0.00) 3.654 (0.94) -18.664 (4.32) -1.495 (1.14) -2.505 (3.75) + none Solar.R Wind Temp Month + + 1: 42.444 (0.00) 1.919 (1.56) 1.919 (1.56) 17.492 (3.79) -5.607 (3.04) + 2: 42.444 (0.00) -0.495 (0.47) -0.495 (0.47) -5.258 (0.77) -5.607 (0.59) + 3: 42.444 (0.00) -7.398 (1.37) -7.398 (1.37) -1.466 (0.89) -2.567 (0.50) Day - 1: -2.940 (4.17) - 2: -1.845 (1.51) - 3: 1.442 (2.14) + 1: -3.121 (1.68) + 2: -2.025 (0.47) + 3: 1.261 (2.69) Message -- Iteration 2 ----------------------------------------------------------------- -- Convergence info i Not converged after 12 coalitions: - Current convergence measure: 0.14 [needs 0.1] - Estimated remaining coalitions: 8 + Current convergence measure: 0.2 [needs 0.1] + Estimated remaining coalitions: 14 (Concervatively) adding 10% of that (2 coalitions) in the next iteration. -- Current estimated Shapley values (sd) Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.591 (0.76) 8.215 (2.20) 17.463 (4.64) -5.545 (2.14) - 2: 42.444 (0.00) 2.196 (0.98) -3.399 (0.47) -5.286 (0.76) -5.545 (0.98) - 3: 42.444 (0.00) 3.654 (1.12) -18.664 (3.06) -1.495 (0.82) -2.505 (2.55) + 1: 42.444 (0.00) -4.467 (3.07) 8.305 (3.28) 17.491 (3.69) -5.607 (3.27) + 2: 42.444 (0.00) 2.320 (1.58) -3.309 (1.14) -5.258 (0.55) -5.607 (0.78) + 3: 42.444 (0.00) 3.778 (4.80) -18.574 (5.68) -1.467 (0.52) -2.567 (0.64) Day - 1: -2.940 (4.54) - 2: -1.845 (1.11) - 3: 1.442 (1.96) + 1: -3.121 (2.44) + 2: -2.025 (0.40) + 3: 1.261 (4.23) Message -- Iteration 3 ----------------------------------------------------------------- -- Convergence info - i Not converged after 14 coalitions: - Current convergence measure: 0.14 [needs 0.1] - Estimated remaining coalitions: 10 - (Concervatively) adding 20% of that (2 coalitions) in the next iteration. - - -- Current estimated Shapley values (sd) - Output - none Solar.R Wind Temp Month - - 1: 42.444 (0.00) -4.570 (0.87) 8.236 (1.92) 17.463 (4.97) -5.593 (1.32) - 2: 42.444 (0.00) 2.217 (0.66) -3.378 (0.33) -5.286 (0.86) -5.593 (0.26) - 3: 42.444 (0.00) 3.675 (0.52) -18.643 (3.19) -1.495 (0.72) -2.553 (1.19) - Day - - 1: -2.934 (4.68) - 2: -1.839 (1.06) - 3: 1.448 (3.00) - Message - - -- Iteration 4 ----------------------------------------------------------------- - - -- Convergence info - v Converged after 16 coalitions: + v Converged after 14 coalitions: Convergence tolerance reached! -- Final estimated Shapley values (sd) Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -4.538 (1.90) 8.268 (0.56) 17.523 (3.29) -5.589 (0.04) - 2: 42.444 (0.00) 2.249 (0.66) -3.347 (0.09) -5.227 (0.77) -5.589 (0.04) - 3: 42.444 (0.00) 3.707 (0.45) -18.611 (1.01) -1.435 (0.58) -2.549 (0.04) + 1: 42.444 (0.00) -4.425 (2.17) 8.241 (2.30) 17.490 (0.02) -5.609 (0.06) + 2: 42.444 (0.00) 2.362 (1.10) -3.373 (0.99) -5.260 (0.02) -5.609 (0.40) + 3: 42.444 (0.00) 3.820 (3.85) -18.638 (4.09) -1.468 (0.02) -2.569 (0.32) Day - 1: -3.061 (2.86) - 2: -1.966 (0.50) - 3: 1.321 (1.06) + 1: -3.094 (0.67) + 2: -1.999 (0.33) + 3: 1.288 (1.16) explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -4.538 8.268 17.523 -5.589 -3.061 - 2: 2 42.44 2.249 -3.347 -5.227 -5.589 -1.966 - 3: 3 42.44 3.707 -18.611 -1.435 -2.549 1.321 + 1: 1 42.44 -4.425 8.241 17.490 -5.609 -3.094 + 2: 2 42.44 2.362 -3.373 -5.260 -5.609 -1.999 + 3: 3 42.44 3.820 -18.638 -1.468 -2.569 1.288 # output_lm_numeric_independence_saving_and_cont_est @@ -590,9 +637,9 @@ Output explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -4.531 8.202 17.504 -5.549 -3.024 - 2: 2 42.44 2.256 -3.412 -5.246 -5.549 -1.928 - 3: 3 42.44 3.714 -18.677 -1.454 -2.509 1.358 + 1: 1 42.44 -4.553 8.201 17.513 -5.460 -3.098 + 2: 2 42.44 2.234 -3.413 -5.237 -5.460 -2.003 + 3: 3 42.44 3.692 -18.678 -1.445 -2.421 1.284 --- @@ -606,9 +653,9 @@ Output explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -4.531 8.202 17.504 -5.549 -3.024 - 2: 2 42.44 2.256 -3.412 -5.246 -5.549 -1.928 - 3: 3 42.44 3.714 -18.677 -1.454 -2.509 1.358 + 1: 1 42.44 -4.553 8.201 17.513 -5.460 -3.098 + 2: 2 42.44 2.234 -3.413 -5.237 -5.460 -2.003 + 3: 3 42.44 3.692 -18.678 -1.445 -2.421 1.284 # output_verbose_1 @@ -628,7 +675,7 @@ -- iterative computation started -- -- Iteration 1 ----------------------------------------------------------------- - i Using 5 of 32 coalitions, 5 new. + i Using 6 of 32 coalitions, 6 new. -- Iteration 2 ----------------------------------------------------------------- i Using 10 of 32 coalitions, 4 new. @@ -642,11 +689,11 @@ -- Iteration 5 ----------------------------------------------------------------- i Using 22 of 32 coalitions, 6 new. Output - explain_id none Solar.R Wind Temp Month Day - - 1: 1 42.44 -8.534 7.868 14.3146 0.8504 -1.8969 - 2: 2 42.44 4.919 -4.878 -11.9086 -0.8405 -1.1714 - 3: 3 42.44 7.447 -25.748 0.0324 -0.1976 0.8978 + explain_id none Solar.R Wind Temp Month Day + + 1: 1 42.44 -8.303 8.184 14.50884 -0.05722 -1.7302 + 2: 2 42.44 5.018 -4.584 -11.88356 -1.34032 -1.0897 + 3: 3 42.44 7.246 -25.606 0.04728 -0.22558 0.9699 # output_verbose_1_3 @@ -666,11 +713,11 @@ -- iterative computation started -- -- Iteration 1 ----------------------------------------------------------------- - i Using 5 of 32 coalitions, 5 new. + i Using 6 of 32 coalitions, 6 new. -- Convergence info i Not converged after 6 coalitions: - Current convergence measure: 0.33 [needs 0.02] + Current convergence measure: 0.32 [needs 0.02] Estimated remaining coalitions: 24 (Concervatively) adding 10% of that (4 coalitions) in the next iteration. @@ -679,7 +726,7 @@ -- Convergence info i Not converged after 10 coalitions: - Current convergence measure: 0.2 [needs 0.02] + Current convergence measure: 0.19 [needs 0.02] Estimated remaining coalitions: 20 (Concervatively) adding 10% of that (2 coalitions) in the next iteration. @@ -688,7 +735,7 @@ -- Convergence info i Not converged after 12 coalitions: - Current convergence measure: 0.077 [needs 0.02] + Current convergence measure: 0.12 [needs 0.02] Estimated remaining coalitions: 18 (Concervatively) adding 20% of that (4 coalitions) in the next iteration. @@ -697,7 +744,7 @@ -- Convergence info i Not converged after 16 coalitions: - Current convergence measure: 0.046 [needs 0.02] + Current convergence measure: 0.051 [needs 0.02] Estimated remaining coalitions: 14 (Concervatively) adding 30% of that (6 coalitions) in the next iteration. @@ -708,11 +755,11 @@ v Converged after 22 coalitions: Convergence tolerance reached! Output - explain_id none Solar.R Wind Temp Month Day - - 1: 1 42.44 -8.534 7.868 14.3146 0.8504 -1.8969 - 2: 2 42.44 4.919 -4.878 -11.9086 -0.8405 -1.1714 - 3: 3 42.44 7.447 -25.748 0.0324 -0.1976 0.8978 + explain_id none Solar.R Wind Temp Month Day + + 1: 1 42.44 -8.303 8.184 14.50884 -0.05722 -1.7302 + 2: 2 42.44 5.018 -4.584 -11.88356 -1.34032 -1.0897 + 3: 3 42.44 7.246 -25.606 0.04728 -0.22558 0.9699 # output_verbose_1_3_4 @@ -732,11 +779,11 @@ -- iterative computation started -- -- Iteration 1 ----------------------------------------------------------------- - i Using 5 of 32 coalitions, 5 new. + i Using 6 of 32 coalitions, 6 new. -- Convergence info i Not converged after 6 coalitions: - Current convergence measure: 0.33 [needs 0.02] + Current convergence measure: 0.32 [needs 0.02] Estimated remaining coalitions: 24 (Concervatively) adding 10% of that (4 coalitions) in the next iteration. @@ -744,14 +791,14 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -1.428 (1.74) -1.428 (1.74) 15.197 (5.43) 1.688 (0.97) - 2: 42.444 (0.00) -0.914 (1.10) -0.914 (1.10) -10.815 (3.23) -0.321 (0.19) - 3: 42.444 (0.00) -5.807 (0.72) -5.807 (0.72) 0.168 (1.95) -0.316 (1.71) + 1: 42.444 (0.00) -0.478 (1.70) -0.478 (1.70) 15.306 (5.01) -0.478 (1.70) + 2: 42.444 (0.00) -0.790 (1.05) -0.790 (1.05) -10.706 (3.15) -0.790 (1.05) + 3: 42.444 (0.00) -6.251 (0.86) -6.251 (0.86) 0.277 (2.07) -6.251 (0.86) Day - 1: -1.428 (1.74) - 2: -0.914 (1.10) - 3: -5.807 (0.72) + 1: -1.271 (0.27) + 2: -0.804 (0.00) + 3: 0.909 (2.40) Message -- Iteration 2 ----------------------------------------------------------------- @@ -759,22 +806,22 @@ -- Convergence info i Not converged after 10 coalitions: - Current convergence measure: 0.2 [needs 0.02] + Current convergence measure: 0.19 [needs 0.02] Estimated remaining coalitions: 20 (Concervatively) adding 10% of that (2 coalitions) in the next iteration. -- Current estimated Shapley values (sd) Output - none Solar.R Wind Temp - - 1: 42.444 (0.00) -10.984 (4.19) 6.696 (3.77) 15.197 (4.21) - 2: 42.444 (0.00) 2.151 (2.02) -6.851 (2.61) -10.815 (2.04) - 3: 42.444 (0.00) 6.820 (4.76) -26.009 (7.25) 0.168 (3.47) - Month Day - - 1: 1.688 (1.57) 0.006 (3.61) - 2: -0.321 (0.33) 1.957 (2.22) - 3: -0.316 (0.90) 1.769 (6.40) + none Solar.R Wind Temp Month + + 1: 42.444 (0.00) -4.343 (1.71) 8.000 (2.76) 14.560 (3.18) -4.343 (1.71) + 2: 42.444 (0.00) 1.717 (1.44) -4.647 (2.04) -11.863 (2.58) 1.717 (1.44) + 3: 42.444 (0.00) 3.561 (2.80) -25.486 (6.46) -0.112 (3.42) 3.561 (2.80) + Day + + 1: -1.271 (0.96) + 2: -0.804 (0.90) + 3: 0.909 (1.07) Message -- Iteration 3 ----------------------------------------------------------------- @@ -782,7 +829,7 @@ -- Convergence info i Not converged after 12 coalitions: - Current convergence measure: 0.077 [needs 0.02] + Current convergence measure: 0.12 [needs 0.02] Estimated remaining coalitions: 18 (Concervatively) adding 20% of that (4 coalitions) in the next iteration. @@ -790,14 +837,14 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -9.803 (1.62) 7.155 (0.72) 14.738 (0.31) 1.688 (0.48) - 2: 42.444 (0.00) 4.188 (1.34) -6.060 (0.82) -11.606 (0.54) -0.321 (0.16) - 3: 42.444 (0.00) 7.531 (1.13) -25.733 (2.34) -0.109 (0.19) -0.316 (0.31) + 1: 42.444 (0.00) -4.281 (1.19) 7.937 (1.20) 14.603 (2.35) -4.281 (1.19) + 2: 42.444 (0.00) 1.637 (1.09) -4.568 (1.34) -11.876 (2.07) 1.637 (1.09) + 3: 42.444 (0.00) 3.541 (0.88) -25.466 (2.74) -0.114 (1.92) 3.541 (0.88) Day - 1: -1.175 (1.69) - 2: -0.080 (1.41) - 3: 1.057 (2.57) + 1: -1.376 (0.70) + 2: -0.710 (0.87) + 3: 0.930 (0.73) Message -- Iteration 4 ----------------------------------------------------------------- @@ -805,7 +852,7 @@ -- Convergence info i Not converged after 16 coalitions: - Current convergence measure: 0.046 [needs 0.02] + Current convergence measure: 0.051 [needs 0.02] Estimated remaining coalitions: 14 (Concervatively) adding 30% of that (6 coalitions) in the next iteration. @@ -813,14 +860,14 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -8.850 (0.50) 7.165 (0.77) 14.627 (0.34) 1.200 (0.24) - 2: 42.444 (0.00) 4.909 (0.49) -5.670 (0.76) -11.676 (0.54) -0.592 (0.19) - 3: 42.444 (0.00) 7.453 (0.17) -25.529 (1.87) -0.083 (0.18) -0.223 (0.09) + 1: 42.444 (0.00) -8.277 (0.94) 8.261 (0.58) 14.582 (0.54) -0.479 (1.16) + 2: 42.444 (0.00) 4.877 (0.80) -4.441 (0.44) -11.753 (0.77) -1.790 (1.16) + 3: 42.444 (0.00) 6.997 (0.78) -25.432 (1.26) -0.069 (0.25) 0.022 (1.54) Day - 1: -1.541 (0.65) - 2: -0.851 (0.60) - 3: 0.814 (1.89) + 1: -1.484 (0.30) + 2: -0.773 (0.20) + 3: 0.914 (0.08) Message -- Iteration 5 ----------------------------------------------------------------- @@ -834,19 +881,19 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -8.534 (0.45) 7.868 (0.36) 14.315 (0.27) 0.850 (0.37) - 2: 42.444 (0.00) 4.919 (0.36) -4.878 (0.53) -11.909 (0.38) -0.841 (0.23) - 3: 42.444 (0.00) 7.447 (0.16) -25.748 (0.16) 0.032 (0.13) -0.198 (0.07) - Day - - 1: -1.897 (0.19) - 2: -1.171 (0.25) - 3: 0.898 (0.12) - explain_id none Solar.R Wind Temp Month Day - - 1: 1 42.44 -8.534 7.868 14.3146 0.8504 -1.8969 - 2: 2 42.44 4.919 -4.878 -11.9086 -0.8405 -1.1714 - 3: 3 42.44 7.447 -25.748 0.0324 -0.1976 0.8978 + 1: 42.444 (0.00) -8.303 (0.29) 8.184 (0.26) 14.509 (0.30) -0.057 (0.42) + 2: 42.444 (0.00) 5.018 (0.24) -4.584 (0.34) -11.884 (0.40) -1.340 (0.60) + 3: 42.444 (0.00) 7.246 (0.22) -25.606 (0.16) 0.047 (0.20) -0.226 (0.36) + Day + + 1: -1.73 (0.23) + 2: -1.09 (0.27) + 3: 0.97 (0.14) + explain_id none Solar.R Wind Temp Month Day + + 1: 1 42.44 -8.303 8.184 14.50884 -0.05722 -1.7302 + 2: 2 42.44 5.018 -4.584 -11.88356 -1.34032 -1.0897 + 3: 3 42.44 7.246 -25.606 0.04728 -0.22558 0.9699 # output_verbose_1_3_4_5 @@ -866,11 +913,11 @@ -- iterative computation started -- -- Iteration 1 ----------------------------------------------------------------- - i Using 5 of 32 coalitions, 5 new. + i Using 6 of 32 coalitions, 6 new. -- Convergence info i Not converged after 6 coalitions: - Current convergence measure: 0.33 [needs 0.02] + Current convergence measure: 0.32 [needs 0.02] Estimated remaining coalitions: 24 (Concervatively) adding 10% of that (4 coalitions) in the next iteration. @@ -878,14 +925,14 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -1.428 (1.74) -1.428 (1.74) 15.197 (5.43) 1.688 (0.97) - 2: 42.444 (0.00) -0.914 (1.10) -0.914 (1.10) -10.815 (3.23) -0.321 (0.19) - 3: 42.444 (0.00) -5.807 (0.72) -5.807 (0.72) 0.168 (1.95) -0.316 (1.71) + 1: 42.444 (0.00) -0.478 (1.70) -0.478 (1.70) 15.306 (5.01) -0.478 (1.70) + 2: 42.444 (0.00) -0.790 (1.05) -0.790 (1.05) -10.706 (3.15) -0.790 (1.05) + 3: 42.444 (0.00) -6.251 (0.86) -6.251 (0.86) 0.277 (2.07) -6.251 (0.86) Day - 1: -1.428 (1.74) - 2: -0.914 (1.10) - 3: -5.807 (0.72) + 1: -1.271 (0.27) + 2: -0.804 (0.00) + 3: 0.909 (2.40) Message -- Iteration 2 ----------------------------------------------------------------- @@ -893,22 +940,22 @@ -- Convergence info i Not converged after 10 coalitions: - Current convergence measure: 0.2 [needs 0.02] + Current convergence measure: 0.19 [needs 0.02] Estimated remaining coalitions: 20 (Concervatively) adding 10% of that (2 coalitions) in the next iteration. -- Current estimated Shapley values (sd) Output - none Solar.R Wind Temp - - 1: 42.444 (0.00) -10.984 (4.19) 6.696 (3.77) 15.197 (4.21) - 2: 42.444 (0.00) 2.151 (2.02) -6.851 (2.61) -10.815 (2.04) - 3: 42.444 (0.00) 6.820 (4.76) -26.009 (7.25) 0.168 (3.47) - Month Day - - 1: 1.688 (1.57) 0.006 (3.61) - 2: -0.321 (0.33) 1.957 (2.22) - 3: -0.316 (0.90) 1.769 (6.40) + none Solar.R Wind Temp Month + + 1: 42.444 (0.00) -4.343 (1.71) 8.000 (2.76) 14.560 (3.18) -4.343 (1.71) + 2: 42.444 (0.00) 1.717 (1.44) -4.647 (2.04) -11.863 (2.58) 1.717 (1.44) + 3: 42.444 (0.00) 3.561 (2.80) -25.486 (6.46) -0.112 (3.42) 3.561 (2.80) + Day + + 1: -1.271 (0.96) + 2: -0.804 (0.90) + 3: 0.909 (1.07) Message -- Iteration 3 ----------------------------------------------------------------- @@ -916,7 +963,7 @@ -- Convergence info i Not converged after 12 coalitions: - Current convergence measure: 0.077 [needs 0.02] + Current convergence measure: 0.12 [needs 0.02] Estimated remaining coalitions: 18 (Concervatively) adding 20% of that (4 coalitions) in the next iteration. @@ -924,14 +971,14 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -9.803 (1.62) 7.155 (0.72) 14.738 (0.31) 1.688 (0.48) - 2: 42.444 (0.00) 4.188 (1.34) -6.060 (0.82) -11.606 (0.54) -0.321 (0.16) - 3: 42.444 (0.00) 7.531 (1.13) -25.733 (2.34) -0.109 (0.19) -0.316 (0.31) + 1: 42.444 (0.00) -4.281 (1.19) 7.937 (1.20) 14.603 (2.35) -4.281 (1.19) + 2: 42.444 (0.00) 1.637 (1.09) -4.568 (1.34) -11.876 (2.07) 1.637 (1.09) + 3: 42.444 (0.00) 3.541 (0.88) -25.466 (2.74) -0.114 (1.92) 3.541 (0.88) Day - 1: -1.175 (1.69) - 2: -0.080 (1.41) - 3: 1.057 (2.57) + 1: -1.376 (0.70) + 2: -0.710 (0.87) + 3: 0.930 (0.73) Message -- Iteration 4 ----------------------------------------------------------------- @@ -939,7 +986,7 @@ -- Convergence info i Not converged after 16 coalitions: - Current convergence measure: 0.046 [needs 0.02] + Current convergence measure: 0.051 [needs 0.02] Estimated remaining coalitions: 14 (Concervatively) adding 30% of that (6 coalitions) in the next iteration. @@ -947,14 +994,14 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -8.850 (0.50) 7.165 (0.77) 14.627 (0.34) 1.200 (0.24) - 2: 42.444 (0.00) 4.909 (0.49) -5.670 (0.76) -11.676 (0.54) -0.592 (0.19) - 3: 42.444 (0.00) 7.453 (0.17) -25.529 (1.87) -0.083 (0.18) -0.223 (0.09) + 1: 42.444 (0.00) -8.277 (0.94) 8.261 (0.58) 14.582 (0.54) -0.479 (1.16) + 2: 42.444 (0.00) 4.877 (0.80) -4.441 (0.44) -11.753 (0.77) -1.790 (1.16) + 3: 42.444 (0.00) 6.997 (0.78) -25.432 (1.26) -0.069 (0.25) 0.022 (1.54) Day - 1: -1.541 (0.65) - 2: -0.851 (0.60) - 3: 0.814 (1.89) + 1: -1.484 (0.30) + 2: -0.773 (0.20) + 3: 0.914 (0.08) Message -- Iteration 5 ----------------------------------------------------------------- @@ -968,19 +1015,19 @@ Output none Solar.R Wind Temp Month - 1: 42.444 (0.00) -8.534 (0.45) 7.868 (0.36) 14.315 (0.27) 0.850 (0.37) - 2: 42.444 (0.00) 4.919 (0.36) -4.878 (0.53) -11.909 (0.38) -0.841 (0.23) - 3: 42.444 (0.00) 7.447 (0.16) -25.748 (0.16) 0.032 (0.13) -0.198 (0.07) - Day - - 1: -1.897 (0.19) - 2: -1.171 (0.25) - 3: 0.898 (0.12) - explain_id none Solar.R Wind Temp Month Day - - 1: 1 42.44 -8.534 7.868 14.3146 0.8504 -1.8969 - 2: 2 42.44 4.919 -4.878 -11.9086 -0.8405 -1.1714 - 3: 3 42.44 7.447 -25.748 0.0324 -0.1976 0.8978 + 1: 42.444 (0.00) -8.303 (0.29) 8.184 (0.26) 14.509 (0.30) -0.057 (0.42) + 2: 42.444 (0.00) 5.018 (0.24) -4.584 (0.34) -11.884 (0.40) -1.340 (0.60) + 3: 42.444 (0.00) 7.246 (0.22) -25.606 (0.16) 0.047 (0.20) -0.226 (0.36) + Day + + 1: -1.73 (0.23) + 2: -1.09 (0.27) + 3: 0.97 (0.14) + explain_id none Solar.R Wind Temp Month Day + + 1: 1 42.44 -8.303 8.184 14.50884 -0.05722 -1.7302 + 2: 2 42.44 5.018 -4.584 -11.88356 -1.34032 -1.0897 + 3: 3 42.44 7.246 -25.606 0.04728 -0.22558 0.9699 # output_lm_numeric_independence_keep_samp_for_vS @@ -1000,7 +1047,7 @@ -- iterative computation started -- -- Iteration 1 ----------------------------------------------------------------- - i Using 5 of 32 coalitions, 5 new. + i Using 6 of 32 coalitions, 6 new. -- Iteration 2 ----------------------------------------------------------------- i Using 10 of 32 coalitions, 4 new. @@ -1010,10 +1057,13 @@ -- Iteration 4 ----------------------------------------------------------------- i Using 16 of 32 coalitions, 4 new. + + -- Iteration 5 ----------------------------------------------------------------- + i Using 22 of 32 coalitions, 6 new. Output explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -4.541 8.330 17.491 -5.585 -3.093 - 2: 2 42.44 2.246 -3.285 -5.258 -5.585 -1.997 - 3: 3 42.44 3.704 -18.549 -1.467 -2.545 1.289 + 1: 1 42.44 -4.556 8.252 17.512 -5.535 -3.070 + 2: 2 42.44 2.231 -3.363 -5.238 -5.535 -1.975 + 3: 3 42.44 3.689 -18.628 -1.446 -2.495 1.312 diff --git a/tests/testthat/_snaps/iterative-output/output_lm_numeric_gaussian_group_converges_tol.rds b/tests/testthat/_snaps/iterative-output/output_lm_numeric_gaussian_group_converges_tol.rds index 07003dc0c..7e6e3c1d3 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_lm_numeric_gaussian_group_converges_tol.rds and b/tests/testthat/_snaps/iterative-output/output_lm_numeric_gaussian_group_converges_tol.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_lm_numeric_indep_conv_max_n_coalitions.rds b/tests/testthat/_snaps/iterative-output/output_lm_numeric_indep_conv_max_n_coalitions.rds index e7ba91106..b0f649922 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_lm_numeric_indep_conv_max_n_coalitions.rds and b/tests/testthat/_snaps/iterative-output/output_lm_numeric_indep_conv_max_n_coalitions.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_cont_est_object.rds b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_cont_est_object.rds index 446552c2c..1ce0ba94e 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_cont_est_object.rds and b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_cont_est_object.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_cont_est_path.rds b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_cont_est_path.rds index 446552c2c..1ce0ba94e 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_cont_est_path.rds and b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_cont_est_path.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_maxit.rds b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_maxit.rds index 6f0d11cd9..04e35ad8c 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_maxit.rds and b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_maxit.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_tol.rds b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_tol.rds index 63ad73065..e7c00a0a2 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_tol.rds and b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_tol.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_tol_paired.rds b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_tol_paired.rds index 63ad73065..e7c00a0a2 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_tol_paired.rds and b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_converges_tol_paired.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_keep_samp_for_vS.rds b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_keep_samp_for_vS.rds index 6d8f2e912..9507092e5 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_keep_samp_for_vS.rds and b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_keep_samp_for_vS.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_reach_exact.rds b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_reach_exact.rds index 56ef76740..133f2daf9 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_reach_exact.rds and b/tests/testthat/_snaps/iterative-output/output_lm_numeric_independence_reach_exact.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_verbose_1.rds b/tests/testthat/_snaps/iterative-output/output_verbose_1.rds index ed049c2a0..b0eeef24c 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_verbose_1.rds and b/tests/testthat/_snaps/iterative-output/output_verbose_1.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_verbose_1_3.rds b/tests/testthat/_snaps/iterative-output/output_verbose_1_3.rds index 964fcc670..0b050fb2d 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_verbose_1_3.rds and b/tests/testthat/_snaps/iterative-output/output_verbose_1_3.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_verbose_1_3_4.rds b/tests/testthat/_snaps/iterative-output/output_verbose_1_3_4.rds index b6fef86c3..aecfc18c2 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_verbose_1_3_4.rds and b/tests/testthat/_snaps/iterative-output/output_verbose_1_3_4.rds differ diff --git a/tests/testthat/_snaps/iterative-output/output_verbose_1_3_4_5.rds b/tests/testthat/_snaps/iterative-output/output_verbose_1_3_4_5.rds index ef7ad93c4..e1a05c996 100644 Binary files a/tests/testthat/_snaps/iterative-output/output_verbose_1_3_4_5.rds and b/tests/testthat/_snaps/iterative-output/output_verbose_1_3_4_5.rds differ diff --git a/tests/testthat/_snaps/regression-output.md b/tests/testthat/_snaps/regression-output.md index 73230c664..9fc55eab9 100644 --- a/tests/testthat/_snaps/regression-output.md +++ b/tests/testthat/_snaps/regression-output.md @@ -16,7 +16,7 @@ -- iterative computation started -- -- Iteration 1 ----------------------------------------------------------------- - i Using 5 of 32 coalitions, 5 new. + i Using 6 of 32 coalitions, 6 new. -- Iteration 2 ----------------------------------------------------------------- i Using 10 of 32 coalitions, 4 new. @@ -32,9 +32,9 @@ Output explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -8.727 8.110 14.4650 0.7756 -2.0211 - 2: 2 42.44 4.725 -4.636 -11.7582 -0.9153 -1.2956 - 3: 3 42.44 7.253 -25.505 0.1828 -0.2723 0.7736 + 1: 1 42.44 -8.171 8.192 14.7097 -0.2248 -1.9036 + 2: 2 42.44 5.149 -4.575 -11.6827 -1.5079 -1.2630 + 3: 3 42.44 7.378 -25.598 0.2482 -0.3932 0.7966 # output_lm_numeric_lm_separate @@ -76,11 +76,11 @@ i Using 10 of 32 coalitions. Output - explain_id none Solar.R Wind Temp Month Day - - 1: 1 42.44 -8.593 8.491 15.3573 -0.9151 -1.739 - 2: 2 42.44 4.948 -3.745 -10.6547 -2.8369 -1.591 - 3: 3 42.44 7.129 -25.351 0.3282 -1.3110 1.637 + explain_id none Solar.R Wind Temp Month Day + + 1: 1 42.44 -0.4556 -0.4556 14.4174 0.6856 -1.5898 + 2: 2 42.44 -0.2281 -0.2281 -11.2859 -1.0148 -1.1226 + 3: 3 42.44 -8.9589 -8.9589 0.2329 -0.4732 0.5898 # output_lm_categorical_lm_separate @@ -299,13 +299,13 @@ -- Main computation started -- - i Using 10 of 32 coalitions. + i Using 12 of 32 coalitions. Output - explain_id none Solar.R Wind Temp Month Day - - 1: 1 42.44 -9.946 9.182 16.2078 -2.630 -0.2120 - 2: 2 42.44 2.239 -6.194 -7.0743 -2.630 -0.2199 - 3: 3 42.44 8.127 -24.230 0.4572 -1.188 -0.7344 + explain_id none Solar.R Wind Temp Month Day + + 1: 1 42.44 -4.908 10.750 15.7404 -3.9824 -4.998 + 2: 2 42.44 4.111 -4.283 -7.0067 -3.2881 -3.412 + 3: 3 42.44 4.649 -24.040 -0.4918 0.2164 2.098 # output_lm_numeric_lm_surrogate_reg_surr_n_comb @@ -320,13 +320,13 @@ -- Main computation started -- - i Using 10 of 32 coalitions. + i Using 12 of 32 coalitions. Output - explain_id none Solar.R Wind Temp Month Day - - 1: 1 42.44 -9.946 9.182 16.2078 -2.630 -0.2120 - 2: 2 42.44 2.239 -6.194 -7.0743 -2.630 -0.2199 - 3: 3 42.44 8.127 -24.230 0.4572 -1.188 -0.7344 + explain_id none Solar.R Wind Temp Month Day + + 1: 1 42.44 -4.460 10.394 16.1653 -4.1613 -5.337 + 2: 2 42.44 4.921 -4.735 -6.6623 -3.5602 -3.843 + 3: 3 42.44 5.508 -24.619 -0.1181 -0.1746 1.835 # output_lm_categorical_lm_surrogate diff --git a/tests/testthat/_snaps/regression-output/output_lm_categorical_lm_separate.rds b/tests/testthat/_snaps/regression-output/output_lm_categorical_lm_separate.rds index d5bc1b7ef..c68a9d4ad 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_categorical_lm_separate.rds and b/tests/testthat/_snaps/regression-output/output_lm_categorical_lm_separate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_categorical_lm_surrogate.rds b/tests/testthat/_snaps/regression-output/output_lm_categorical_lm_surrogate.rds index 5287a9c1f..44cf52a19 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_categorical_lm_surrogate.rds and b/tests/testthat/_snaps/regression-output/output_lm_categorical_lm_surrogate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_separate.rds b/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_separate.rds index 374301c6f..dab220941 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_separate.rds and b/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_separate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_separate_parallel.rds b/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_separate_parallel.rds index f0b5651a3..5e9c77eae 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_separate_parallel.rds and b/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_separate_parallel.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_surrogate.rds b/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_surrogate.rds index f3e2341ec..783b6e955 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_surrogate.rds and b/tests/testthat/_snaps/regression-output/output_lm_mixed_decision_tree_cv_surrogate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_mixed_lm_separate.rds b/tests/testthat/_snaps/regression-output/output_lm_mixed_lm_separate.rds index afd7c3d30..3288f6dfa 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_mixed_lm_separate.rds and b/tests/testthat/_snaps/regression-output/output_lm_mixed_lm_separate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_mixed_lm_surrogate.rds b/tests/testthat/_snaps/regression-output/output_lm_mixed_lm_surrogate.rds index 33203d03a..46df1ed0b 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_mixed_lm_surrogate.rds and b/tests/testthat/_snaps/regression-output/output_lm_mixed_lm_surrogate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_mixed_splines_separate.rds b/tests/testthat/_snaps/regression-output/output_lm_mixed_splines_separate.rds index 77bedf0ad..6e8878732 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_mixed_splines_separate.rds and b/tests/testthat/_snaps/regression-output/output_lm_mixed_splines_separate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_mixed_xgboost_separate.rds b/tests/testthat/_snaps/regression-output/output_lm_mixed_xgboost_separate.rds index 6582ba9bf..d5c8874d1 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_mixed_xgboost_separate.rds and b/tests/testthat/_snaps/regression-output/output_lm_mixed_xgboost_separate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_mixed_xgboost_surrogate.rds b/tests/testthat/_snaps/regression-output/output_lm_mixed_xgboost_surrogate.rds index 194dea761..b929424fe 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_mixed_xgboost_surrogate.rds and b/tests/testthat/_snaps/regression-output/output_lm_mixed_xgboost_surrogate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate.rds b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate.rds index dc65779ef..4fd799063 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate.rds and b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate_iterative.rds b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate_iterative.rds index abe999492..ccad20507 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate_iterative.rds and b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate_iterative.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate_n_comb.rds b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate_n_comb.rds index e15da382d..f4689748b 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate_n_comb.rds and b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_separate_n_comb.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate.rds b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate.rds index 0e18b9b3e..1d8c77bab 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate.rds and b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_iterative.rds b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_iterative.rds index 0e18b9b3e..1d8c77bab 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_iterative.rds and b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_iterative.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_n_comb.rds b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_n_comb.rds index 653929021..128a352fc 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_n_comb.rds and b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_n_comb.rds differ diff --git a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_reg_surr_n_comb.rds b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_reg_surr_n_comb.rds index 114fa6707..10a153264 100644 Binary files a/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_reg_surr_n_comb.rds and b/tests/testthat/_snaps/regression-output/output_lm_numeric_lm_surrogate_reg_surr_n_comb.rds differ diff --git a/tests/testthat/_snaps/regular-output.md b/tests/testthat/_snaps/regular-output.md index 632383c8f..e1a740233 100644 --- a/tests/testthat/_snaps/regular-output.md +++ b/tests/testthat/_snaps/regular-output.md @@ -90,9 +90,9 @@ Output explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -14.030 18.711 9.718 -6.1533 4.356 - 2: 2 42.44 3.015 -3.442 -7.095 -7.8174 1.459 - 3: 3 42.44 8.566 -24.310 3.208 0.6956 -5.728 + 1: 1 42.44 -13.150 16.592 13.644 -6.3603 1.876 + 2: 2 42.44 3.059 -4.523 -8.921 -6.1190 2.624 + 3: 3 42.44 5.627 -23.400 4.227 -0.8489 -3.174 # output_lm_numeric_empirical_independence @@ -169,11 +169,11 @@ i Using 8 of 32 coalitions. Output - explain_id none Solar.R Wind Temp Month Day - - 1: 1 42.44 -9.778 9.084 5.4596 5.4596 2.37679 - 2: 2 42.44 6.833 -4.912 -7.9095 -7.9095 0.01837 - 3: 3 42.44 6.895 -21.308 0.6281 0.6281 -4.41122 + explain_id none Solar.R Wind Temp Month Day + + 1: 1 42.44 -9.778 1.983 16.038 1.983 2.37679 + 2: 2 42.44 6.833 -5.547 -9.636 -5.547 0.01837 + 3: 3 42.44 6.895 -11.847 3.643 -11.847 -4.41122 # output_lm_numeric_empirical_AICc_full @@ -190,11 +190,11 @@ i Using 8 of 32 coalitions. Output - explain_id none Solar.R Wind Temp Month Day - - 1: 1 42.44 -9.778 9.084 5.4596 5.4596 2.37679 - 2: 2 42.44 6.833 -4.912 -7.9095 -7.9095 0.01837 - 3: 3 42.44 6.895 -21.308 0.6281 0.6281 -4.41122 + explain_id none Solar.R Wind Temp Month Day + + 1: 1 42.44 -9.778 1.983 16.038 1.983 2.37679 + 2: 2 42.44 6.833 -5.547 -9.636 -5.547 0.01837 + 3: 3 42.44 6.895 -11.847 3.643 -11.847 -4.41122 # output_lm_numeric_gaussian diff --git a/tests/testthat/_snaps/regular-output/output_custom_lm_numeric_independence_1.rds b/tests/testthat/_snaps/regular-output/output_custom_lm_numeric_independence_1.rds index 5485560c0..c74a51a75 100644 Binary files a/tests/testthat/_snaps/regular-output/output_custom_lm_numeric_independence_1.rds and b/tests/testthat/_snaps/regular-output/output_custom_lm_numeric_independence_1.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_custom_lm_numeric_independence_2.rds b/tests/testthat/_snaps/regular-output/output_custom_lm_numeric_independence_2.rds index 5485560c0..c74a51a75 100644 Binary files a/tests/testthat/_snaps/regular-output/output_custom_lm_numeric_independence_2.rds and b/tests/testthat/_snaps/regular-output/output_custom_lm_numeric_independence_2.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_custom_xgboost_mixed_dummy_ctree.rds b/tests/testthat/_snaps/regular-output/output_custom_xgboost_mixed_dummy_ctree.rds index 2f103a3d3..cd8d9bc6b 100644 Binary files a/tests/testthat/_snaps/regular-output/output_custom_xgboost_mixed_dummy_ctree.rds and b/tests/testthat/_snaps/regular-output/output_custom_xgboost_mixed_dummy_ctree.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_categorical_ctree.rds b/tests/testthat/_snaps/regular-output/output_lm_categorical_ctree.rds index 59124c1b9..75ea751cc 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_categorical_ctree.rds and b/tests/testthat/_snaps/regular-output/output_lm_categorical_ctree.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_categorical_independence.rds b/tests/testthat/_snaps/regular-output/output_lm_categorical_independence.rds index 4ea1ead8f..8553299af 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_categorical_independence.rds and b/tests/testthat/_snaps/regular-output/output_lm_categorical_independence.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_categorical_method.rds b/tests/testthat/_snaps/regular-output/output_lm_categorical_method.rds index cde306c3f..4f4dd7aeb 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_categorical_method.rds and b/tests/testthat/_snaps/regular-output/output_lm_categorical_method.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_categorical_vaeac.rds b/tests/testthat/_snaps/regular-output/output_lm_categorical_vaeac.rds index 95aaddf73..7ddaf5289 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_categorical_vaeac.rds and b/tests/testthat/_snaps/regular-output/output_lm_categorical_vaeac.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_mixed_comb.rds b/tests/testthat/_snaps/regular-output/output_lm_mixed_comb.rds index 3e7b804e0..024c91877 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_mixed_comb.rds and b/tests/testthat/_snaps/regular-output/output_lm_mixed_comb.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_mixed_ctree.rds b/tests/testthat/_snaps/regular-output/output_lm_mixed_ctree.rds index 5f3070172..42777079f 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_mixed_ctree.rds and b/tests/testthat/_snaps/regular-output/output_lm_mixed_ctree.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_mixed_independence.rds b/tests/testthat/_snaps/regular-output/output_lm_mixed_independence.rds index b18091acc..8c001ef5f 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_mixed_independence.rds and b/tests/testthat/_snaps/regular-output/output_lm_mixed_independence.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_mixed_vaeac.rds b/tests/testthat/_snaps/regular-output/output_lm_mixed_vaeac.rds index 846bbb00f..923c685e5 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_mixed_vaeac.rds and b/tests/testthat/_snaps/regular-output/output_lm_mixed_vaeac.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_comb1.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_comb1.rds index fc58e7f79..a9f9fa9db 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_comb1.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_comb1.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_comb2.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_comb2.rds index 382deb5fe..32bd738b7 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_comb2.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_comb2.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_comb3.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_comb3.rds index c256b378b..87142e3b0 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_comb3.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_comb3.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_copula.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_copula.rds index 30842c349..0ecfef00c 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_copula.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_copula.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_ctree.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_ctree.rds index accea429f..3fc0b1082 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_ctree.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_ctree.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_ctree_parallelized.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_ctree_parallelized.rds index accea429f..8654a4132 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_ctree_parallelized.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_ctree_parallelized.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical.rds index aaf9e052f..fb86442bc 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_AICc_each.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_AICc_each.rds index 0b11904ba..4c0da6d13 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_AICc_each.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_AICc_each.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_AICc_full.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_AICc_full.rds index 57fed3dad..3eb8084cc 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_AICc_full.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_AICc_full.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_independence.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_independence.rds index c21420f31..71e3db547 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_independence.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_independence.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_n_coalitions.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_n_coalitions.rds index 4b240bd44..14378155c 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_n_coalitions.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_n_coalitions.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_progress.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_progress.rds index aaf9e052f..f0a3f5de6 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_progress.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_empirical_progress.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_gaussian.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_gaussian.rds index 9a197ced8..8b730ed05 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_gaussian.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_gaussian.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_independence.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_independence.rds index b23b244eb..10b546ada 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_independence.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_independence.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_independence_MSEv_Shapley_weights.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_independence_MSEv_Shapley_weights.rds index 379359169..5cc6a1438 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_independence_MSEv_Shapley_weights.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_independence_MSEv_Shapley_weights.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_independence_keep_samp_for_vS.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_independence_keep_samp_for_vS.rds index f9f4575a1..22b4139d3 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_independence_keep_samp_for_vS.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_independence_keep_samp_for_vS.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_interaction.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_interaction.rds index e7a21d736..0c5f63a54 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_interaction.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_interaction.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_numeric_vaeac.rds b/tests/testthat/_snaps/regular-output/output_lm_numeric_vaeac.rds index edea23233..450051955 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_numeric_vaeac.rds and b/tests/testthat/_snaps/regular-output/output_lm_numeric_vaeac.rds differ diff --git a/tests/testthat/_snaps/regular-output/output_lm_timeseries_method.rds b/tests/testthat/_snaps/regular-output/output_lm_timeseries_method.rds index 5aa38d8f8..3d961bd58 100644 Binary files a/tests/testthat/_snaps/regular-output/output_lm_timeseries_method.rds and b/tests/testthat/_snaps/regular-output/output_lm_timeseries_method.rds differ diff --git a/tests/testthat/_snaps/regular-setup.md b/tests/testthat/_snaps/regular-setup.md index 12ca26adf..0293c1cef 100644 --- a/tests/testthat/_snaps/regular-setup.md +++ b/tests/testthat/_snaps/regular-setup.md @@ -386,9 +386,9 @@ Output explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 -1.4276 -1.4276 15.1967 1.6879 -1.4276 - 2: 2 42.44 -0.9143 -0.9143 -10.8152 -0.3212 -0.9143 - 3: 3 42.44 -5.8068 -5.8068 0.1677 -0.3155 -5.8068 + 1: 1 42.44 -0.4778 -0.4778 15.3062 -0.4778 -1.2708 + 2: 2 42.44 -0.7900 -0.7900 -10.7058 -0.7900 -0.8036 + 3: 3 42.44 -6.2514 -6.2514 0.2771 -6.2514 0.9088 --- @@ -923,9 +923,9 @@ Output explain_id none Solar.R Wind Temp Month Day - 1: 1 42.44 2.3585 2.3585 5.900 -0.3739 2.3585 - 2: 2 42.44 -1.5323 -1.5323 -8.909 -0.3739 -1.5323 - 3: 3 42.44 -0.7635 -0.7635 -6.441 -8.8373 -0.7635 + 1: 1 42.44 1.6821 1.6821 5.891 1.6821 1.665 + 2: 2 42.44 -1.1944 -1.1944 -8.918 -1.1944 -1.378 + 3: 3 42.44 -0.2038 -0.2038 -6.450 -0.2038 -10.507 --- diff --git a/tests/testthat/test-asymmetric-causal-output.R b/tests/testthat/test-asymmetric-causal-output.R index bc8f0f017..957065e16 100644 --- a/tests/testthat/test-asymmetric-causal-output.R +++ b/tests/testthat/test-asymmetric-causal-output.R @@ -1,3 +1,16 @@ +# Comment --------------------------------------------------------------------------------------------------------- +# Note that throughout this test file, the number of +# Monte Carlo samples is set to 5 for speed. However, +# this also means that the outputted Shapley values +# are not stable and vary greatly with the seed. +# I.e., if changes are made to e.g. the sampling +# procedure of the coalitions, then we will see a great +# difference in the output due to this effect the very +# limited number of MC samples. For a better comparison +# when changing, e.g., the sampling procedure, one should +# increase the number of MC samples. This also applied to +# modifications to the MC approaches. + # Continuous data ------------------------------------------------------------------------------------------------- test_that("output_asymmetric_conditional", { expect_snapshot_rds( diff --git a/tests/testthat/test-forecast-setup.R b/tests/testthat/test-forecast-setup.R index cd211d392..4d9f9f469 100644 --- a/tests/testthat/test-forecast-setup.R +++ b/tests/testthat/test-forecast-setup.R @@ -173,7 +173,8 @@ test_that("erroneous input: `max_n_coalitions`", { approach = "independence", phi0 = p0_ar, max_n_coalitions = n_coalitions, - group_lags = FALSE + group_lags = FALSE, + iterative_args = list("initial_n_coalitions" = 20) ) }, error = TRUE diff --git a/tests/testthat/test-regression-output.R b/tests/testthat/test-regression-output.R index d43acc701..e1b8c6dfd 100644 --- a/tests/testthat/test-regression-output.R +++ b/tests/testthat/test-regression-output.R @@ -200,7 +200,7 @@ test_that("output_lm_numeric_lm_surrogate_n_comb", { x_train = x_train_numeric, approach = "regression_surrogate", phi0 = p0, - max_n_coalitions = 10, + max_n_coalitions = 12, regression.model = parsnip::linear_reg(), iterative = FALSE ), @@ -217,7 +217,7 @@ test_that("output_lm_numeric_lm_surrogate_reg_surr_n_comb", { x_train = x_train_numeric, approach = "regression_surrogate", phi0 = p0, - max_n_coalitions = 10, + max_n_coalitions = 12, regression.model = parsnip::linear_reg(), regression.surrogate_n_comb = 8, iterative = FALSE