NorskRegnesentral / shapr

Explaining the output of machine learning models with more accurately estimated Shapley values
https://norskregnesentral.github.io/shapr/
Other
141 stars 33 forks source link

Fixed bug. All messages says "n_combinations is larger than or equal … #360

Closed LHBO closed 1 year ago

LHBO commented 1 year ago

…to 2^m", but all the test only tested for "larger than". I.e., if the user specified n_combinations = 2^m in the call to shapr::explain, the function would not treat it as exact.

In the example below (the other stuff are the models and data from the vignette), we see that Shapley weights are sampled and that we are not using the exact version even though we use all of the coalitions.

> explanation <- explain(
+     model = model,
+     x_explain = x_explain,
+     x_train = x_train,
+     approach = "gaussian",
+     prediction_zero = p0,
+     n_combinations = 16
+ )
Note: Feature classes extracted from the model contains NA.
Assuming feature classes from the data are correct.

Setting parameter 'n_batches' to 10 as a fair trade-off between memory consumption and computation time.
Reducing 'n_batches' typically reduces the computation time at the cost of increased memory consumption.

> explanation$internal$objects$X$shapley_weight
 [1] 1000000       4       4       2       3       3       5       1       3       1       1       7       4       4       6 1000000
LHBO commented 1 year ago

The check failed due to the cyclomatic complexity, it seems like. But I have not really changed much, so I don't understand why it fails now and not before.

LHBO commented 1 year ago

Working on adding script illustrating bug and test...

LHBO commented 1 year ago

Now several of the checks get cancelled. I am not sure why.