shapley | R Documentation |
Calculate the Shapley value
shapley(characteristic_func, method = "exact", n_rep = 10000, n_players = 0)
characteristic_func |
The valued function defined on the subsets of the number of players. |
method |
Method used to calculate the Shapley value. Valid methods are:
|
n_rep |
Only used if |
n_players |
Only used if |
The Shapley value for each player.
n <- 10
v <- function(coalition) {
if (length(coalition) > n/2) {
return(1)
} else {
return(0)
}
}
shapley(v, method = "appro", n_rep = 4000, n_players = n)
n <- 3
v <- c(1,1,2,1,2,2,2)
shapley(v, method = "exact")
shapley(v, method = "appro", n_rep = 4000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.