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: BaseComplementaryNeymanShapExplainer

Limited Neyman SHAP implementation.

allow_mask_duplicates: bool#

Whether to allow duplicate masks during generation.

embedding_model: BaseExternalEmbedding | None#

The external embedding model to use. If provided, overrides mode.

embedding_reducer: BaseEmbeddingReducer#

The embedding reduction strategy to use.

fraction: float | None#

Fraction of total possible masks to generate if num_samples is None.

include_minimal_masks: bool = True#

Whether to include minimal masks (single-feature and empty masks) in the sampling.

initial_fraction: float | None#

Initial fraction of samples to draw in the first step.

initial_num_samples: int | None#

Initial number of samples to draw in the first step.

initial_steps: int | None#

Number of initial steps performed in last call.

mode: Mode#

The SHAP mode, either STATIC or CONTEXTUAL. Used if no embedding_model is provided.

normalizer: BaseNormalizer#

The SHAP value normalizer to use.

num_samples: int | None#

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: BaseEmbeddingSimilarity#

The embedding similarity measure to use.

total_n_calls: int = 0#

Total number of MLLM calls made for last explanation.

use_standard_method: bool = 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: BaseComplementaryNeymanShapExplainer

Standard Neyman SHAP Explainer.

allow_mask_duplicates: bool#

Whether to allow duplicate masks during generation.

embedding_model: BaseExternalEmbedding | None#

The external embedding model to use. If provided, overrides mode.

embedding_reducer: BaseEmbeddingReducer#

The embedding reduction strategy to use.

fraction: float | None#

Fraction of total possible masks to generate if num_samples is None.

include_minimal_masks: bool = True#

Whether to include minimal masks (single-feature and empty masks) in the sampling.

initial_fraction: float | None#

Initial fraction of samples to draw in the first step.

initial_num_samples: int | None#

Initial number of samples to draw in the first step.

initial_steps: int | None#

Number of initial steps performed in last call.

mode: Mode#

The SHAP mode, either STATIC or CONTEXTUAL. Used if no embedding_model is provided.

normalizer: BaseNormalizer#

The SHAP value normalizer to use.

num_samples: int | None#

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: BaseEmbeddingSimilarity#

The embedding similarity measure to use.

total_n_calls: int = 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.

class mllm_shap.shap.neyman.LimitedComplementaryNeymanShapExplainer(*args: Any, initial_num_samples: int | None = None, initial_fraction: float | None = None, **kwargs: Any)[source]#

Bases: BaseComplementaryNeymanShapExplainer

Limited Neyman SHAP implementation.

allow_mask_duplicates: bool#

Whether to allow duplicate masks during generation.

embedding_model: BaseExternalEmbedding | None#

The external embedding model to use. If provided, overrides mode.

embedding_reducer: BaseEmbeddingReducer#

The embedding reduction strategy to use.

fraction: float | None#

Fraction of total possible masks to generate if num_samples is None.

include_minimal_masks: bool = True#

Whether to include minimal masks (single-feature and empty masks) in the sampling.

initial_fraction: float | None#

Initial fraction of samples to draw in the first step.

initial_num_samples: int | None#

Initial number of samples to draw in the first step.

initial_steps: int | None#

Number of initial steps performed in last call.

mode: Mode#

The SHAP mode, either STATIC or CONTEXTUAL. Used if no embedding_model is provided.

normalizer: BaseNormalizer#

The SHAP value normalizer to use.

num_samples: int | None#

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: BaseEmbeddingSimilarity#

The embedding similarity measure to use.

total_n_calls: int = 0#

Total number of MLLM calls made for last explanation.

use_standard_method: bool = 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: BaseComplementaryNeymanShapExplainer

Standard Neyman SHAP Explainer.

allow_mask_duplicates: bool#

Whether to allow duplicate masks during generation.

embedding_model: BaseExternalEmbedding | None#

The external embedding model to use. If provided, overrides mode.

embedding_reducer: BaseEmbeddingReducer#

The embedding reduction strategy to use.

fraction: float | None#

Fraction of total possible masks to generate if num_samples is None.

include_minimal_masks: bool = True#

Whether to include minimal masks (single-feature and empty masks) in the sampling.

initial_fraction: float | None#

Initial fraction of samples to draw in the first step.

initial_num_samples: int | None#

Initial number of samples to draw in the first step.

initial_steps: int | None#

Number of initial steps performed in last call.

mode: Mode#

The SHAP mode, either STATIC or CONTEXTUAL. Used if no embedding_model is provided.

normalizer: BaseNormalizer#

The SHAP value normalizer to use.

num_samples: int | None#

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: BaseEmbeddingSimilarity#

The embedding similarity measure to use.

total_n_calls: int = 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.