-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved sampling efficiency and conversion of coalitions to strings #426
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…l hurdles that we did not think about. Created new cpp function that returns the sampled coalitions as a character vector. Need to check how / if it works with adaptive and asymmetric.
…ault version for sampling coalitions
…` is always a part of X.
…exact data table.
…same form as the symmetric Shapley values and refactored the code to only have a single while loop. Having an if-else inside it will not be expensive, as this while loop will often only do one/a few iterations.
…e when they are NA. Got some issues when I ran explain( testing = TRUE, model = model_lm_numeric, x_explain = x_explain_numeric, x_train = x_train_numeric, approach = "gaussian", phi0 = p0, asymmetric = FALSE, causal_ordering = list(1, 2, 3), confounding = c(TRUE, TRUE, FALSE), group = list("A" = c("Solar.R"), B = c("Wind", "Temp"), C = c("Month", "Day")), n_MC_samples = 5, # Just for speed, verbose = c("basic", "progress", "convergence", "vS_details", "shapley"), iterative = TRUE, iterative_args = list(initial_n_coalitions = 4, convergence_tol = NULL, fixed_n_coalitions_per_iter = 1) )
explain( model = model, x_train = x_train, x_explain = x_explain, approach = "gaussian", phi0 = phi0, asymmetric = TRUE, causal_ordering = causal_ordering_group, confounding = confounding, paired_shap_sampling = FALSE, n_MC_samples = 1000, group = group_list, iterative = TRUE, ) where the initial_n_coalitions where larger than the max_n_coalitions.
…l hurdles that we did not think about. Created new cpp function that returns the sampled coalitions as a character vector. Need to check how / if it works with adaptive and asymmetric.
…ault version for sampling coalitions
…` is always a part of X.
…exact data table.
…same form as the symmetric Shapley values and refactored the code to only have a single while loop. Having an if-else inside it will not be expensive, as this while loop will often only do one/a few iterations.
…/shapr into Lars/String_coalitions
…/shapr into Lars/String_coalitions
…/shapr into Lars/String_coalitions
…from the previous iteration in the current interation. Previousely, this was not done and we resampled coalitions for each iter.
martinju
approved these changes
Dec 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR, we improve the sampling efficiency, and we convert from working with the sampled coalitions as a list of integer vectors to a vector of strings, where each string is a coalition with the groups/features being separated by a white space. I.e., the coalition S = {1, 5, 10} is stored as "1 5 10".
There are two main reasons for doing these changes:
In the new version, we sample and excess number of coalitions, as this is an inexpensive step, then compute the number of unique coalitions and when they were sampled for the first time, and remove the redundant coalitions sampled after having obtained the desired number of unique coalitions.
Also fixed bug in forecast such that we remember the sampled coalitions from the previous iteration in the current iteration. Previously, this was not done and we resampled coalitions for each iter.