Take contributions
This function fills up the combination_space with the game you define (objective function). There is an important point to keep in mind, Shapley values are the added contributions of elements while in MSA we calculate them by perturbation so although it's intuitive to think the combination in combination space is the element that will be lesioned, it is not the case, it will be everything else but the coalition, i.e., the target coalition are the only intact elements. This function takes care of this by passing the complement of each coalition to the game while assigning the results to the target coalition, just keep the logic in mind.
A second point is that this function returns a filled combination_space, it is not filling it in-place for the sake of purity.
Note on returns: Contributions and lesion effects are virtually the same thing it's just about how you're looking at them. For example, you might want to use lesion effects by conditioning elements' length and see the effect of single lesions, dual, triple,... so, for contributions we have a value contributed by the intact coalition, the same result can be compared to the intact system to see how big was the impact of lesioning the complements. "Same same, but different, but still same!" - James Franco
Parameters:
Name | Type | Description | Default |
---|---|---|---|
elements |
list
|
List of the players. Obviously, should be the same passed to make_permutation. |
required |
complement_space |
OrderedSet
|
The actual targets for lesioning. Shapley values are the added contributions of elements while in MSA we calculate them by perturbation so although it's intuitive to think the combination in combination space is the element that will be lesioned, it is not the case, it will be everything else but the coalition, i.e., the target coalition are the only intact elements. |
required |
combination_space |
OrderedSet
|
The template, will be copied, filled by the objective_function, and returned. |
required |
objective_function |
Callable
|
The game, it should get the complement set and return one numeric value either int or float. This function is just calling it as: objective_function(complement, **objective_function_params) so design accordingly. An example using networkx with some tips: (you sometimes need to specify what should happen during edge-cases like an all-lesioned network) def local_efficiency(complements, graph): if len(complements) < 0: # the network is intact so: return nx.local_efficiency(graph)
|
required |
objective_function_params |
Optional[Dict]
|
Kwargs for the objective_function. |
None
|
Returns:
Type | Description |
---|---|
Dict
|
A dictionary of combinations:results |
Source code in msapy/msa.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|