mllm_shap.shap.neyman package#
Submodules#
mllm_shap.shap.neyman.limited module#
Limited Neyman approximation SHAP explainer implementation.
- class mllm_shap.shap.neyman.limited.LimitedComplementaryNeymanShapExplainer(*args: Any, initial_num_samples: int | None = None, initial_fraction: float | None = None, **kwargs: Any)[source]#
Bases:
BaseComplementaryNeymanShapExplainerLimited Neyman SHAP implementation.
- allow_mask_duplicates#
Whether to allow duplicate masks during generation.
- embedding_reducer#
The embedding reduction strategy to use.
- fraction#
Fraction of total possible masks to generate if num_samples is None.
- include_minimal_masks = True#
Whether to include minimal masks (single-feature and empty masks) in the sampling.
- initial_fraction#
Initial fraction of samples to draw in the first step.
- initial_num_samples#
Initial number of samples to draw in the first step.
- initial_steps#
Number of initial steps performed in last call.
- last_observability_sink = None#
Sink used for the most recent call (if observability was enabled).
- mode#
The SHAP mode, either STATIC or CONTEXTUAL. Used if no
embedding_modelis provided.
- normalizer#
The SHAP value normalizer to use.
- num_samples#
Number of random masks to generate. If None, uses fraction. -1 stands for minimal number of samples (only single-feature masks and empty mask).
- similarity_measure#
The embedding similarity measure to use.
- total_n_calls = 0#
Total number of MLLM calls made for last explanation.
- use_standard_method = False#
Whether to use the standard method for initial sampling. Default is False, which uses the modified method with pre-defined members.
mllm_shap.shap.neyman.standard module#
Standard Neyman approximation SHAP explainer implementation.
- class mllm_shap.shap.neyman.standard.StandardComplementaryNeymanShapExplainer(*args: Any, initial_num_samples: int | None = None, initial_fraction: float | None = None, **kwargs: Any)[source]#
Bases:
BaseComplementaryNeymanShapExplainerStandard Neyman SHAP Explainer.
- allow_mask_duplicates#
Whether to allow duplicate masks during generation.
- embedding_reducer#
The embedding reduction strategy to use.
- fraction#
Fraction of total possible masks to generate if num_samples is None.
- include_minimal_masks = True#
Whether to include minimal masks (single-feature and empty masks) in the sampling.
- initial_fraction#
Initial fraction of samples to draw in the first step.
- initial_num_samples#
Initial number of samples to draw in the first step.
- initial_steps#
Number of initial steps performed in last call.
- last_observability_sink = None#
Sink used for the most recent call (if observability was enabled).
- mode#
The SHAP mode, either STATIC or CONTEXTUAL. Used if no
embedding_modelis provided.
- normalizer#
The SHAP value normalizer to use.
- num_samples#
Number of random masks to generate. If None, uses fraction. -1 stands for minimal number of samples (only single-feature masks and empty mask).
- similarity_measure#
The embedding similarity measure to use.
- total_n_calls = 0#
Total number of MLLM calls made for last explanation.
- use_standard_method: bool = True#
Whether to use the standard method for initial sampling. Default is False, which uses the modified method with pre-defined members.
Module contents#
Neyman SHAP explainers module.
LimitedComplementaryNeymanShapExplainerimplements a limited Neyman samplingthat samples initial masks of given size with pre-defined member.
StandardComplementaryNeymanShapExplainerdoes standard Neyman samplingthat samples initial masks of given size randomly.
- class mllm_shap.shap.neyman.LimitedComplementaryNeymanShapExplainer(*args: Any, initial_num_samples: int | None = None, initial_fraction: float | None = None, **kwargs: Any)[source]#
Bases:
BaseComplementaryNeymanShapExplainerLimited Neyman SHAP implementation.
- allow_mask_duplicates#
Whether to allow duplicate masks during generation.
- embedding_reducer#
The embedding reduction strategy to use.
- fraction#
Fraction of total possible masks to generate if num_samples is None.
- include_minimal_masks = True#
Whether to include minimal masks (single-feature and empty masks) in the sampling.
- initial_fraction#
Initial fraction of samples to draw in the first step.
- initial_num_samples#
Initial number of samples to draw in the first step.
- initial_steps#
Number of initial steps performed in last call.
- last_observability_sink = None#
Sink used for the most recent call (if observability was enabled).
- mode#
The SHAP mode, either STATIC or CONTEXTUAL. Used if no
embedding_modelis provided.
- normalizer#
The SHAP value normalizer to use.
- num_samples#
Number of random masks to generate. If None, uses fraction. -1 stands for minimal number of samples (only single-feature masks and empty mask).
- similarity_measure#
The embedding similarity measure to use.
- total_n_calls = 0#
Total number of MLLM calls made for last explanation.
- use_standard_method = False#
Whether to use the standard method for initial sampling. Default is False, which uses the modified method with pre-defined members.
- class mllm_shap.shap.neyman.StandardComplementaryNeymanShapExplainer(*args: Any, initial_num_samples: int | None = None, initial_fraction: float | None = None, **kwargs: Any)[source]#
Bases:
BaseComplementaryNeymanShapExplainerStandard Neyman SHAP Explainer.
- allow_mask_duplicates#
Whether to allow duplicate masks during generation.
- embedding_reducer#
The embedding reduction strategy to use.
- fraction#
Fraction of total possible masks to generate if num_samples is None.
- include_minimal_masks = True#
Whether to include minimal masks (single-feature and empty masks) in the sampling.
- initial_fraction#
Initial fraction of samples to draw in the first step.
- initial_num_samples#
Initial number of samples to draw in the first step.
- initial_steps#
Number of initial steps performed in last call.
- last_observability_sink = None#
Sink used for the most recent call (if observability was enabled).
- mode#
The SHAP mode, either STATIC or CONTEXTUAL. Used if no
embedding_modelis provided.
- normalizer#
The SHAP value normalizer to use.
- num_samples#
Number of random masks to generate. If None, uses fraction. -1 stands for minimal number of samples (only single-feature masks and empty mask).
- similarity_measure#
The embedding similarity measure to use.
- total_n_calls = 0#
Total number of MLLM calls made for last explanation.
- use_standard_method: bool = True#
Whether to use the standard method for initial sampling. Default is False, which uses the modified method with pre-defined members.