Skip to content

shap 0.51.0

Version history | Download JSON

  • PyPI https://pypi.org/project/shap/
    Repository https://github.com/shap/shap

  • py.typed

  • Coverage


    %%{init: {"pie": {"textPosition": 0.85}, "theme": "neutral", "themeVariables": {"pieStrokeWidth": "1px"}}}%%
    pie title
        "Typed" : 570
        "Any" : 139
        "Untyped" : 665
    • 51.6% coverage
    • 41.5% coverage (strict)
    • 1374 typable
      • 570 typed
      • 665 untyped
      • 139 Any
  • Typables


    %%{init: {"pie": {"textPosition": 0.85}, "theme": "neutral", "themeVariables": {"pieStrokeWidth": "1px"}}}%%
    pie title
        "functions" : 373
        "classes" : 769
        "other" : 14
    • 68 functions (+1 overloads)
      • 305 parameters
    • 42 classes
      • 207 methods (+1 overloads)
        • 531 parameters
      • 21 properties
    • 62 modules
      • 14 attrs

Modules

Module Coverage Coverage (strict) Typables Ignores
shap 0.0% 0.0% 0 1
shap._explanation 74.8% 72.1% 111 3
shap.actions._action 0.0% 0.0% 8 0
shap.actions._optimizer 25.0% 25.0% 8 0
shap.datasets 100.0% 100.0% 33 0
shap.explainers._additive 96.7% 56.7% 30 0
shap.explainers._coalition 97.8% 71.1% 45 0
shap.explainers._deep 21.4% 21.4% 14 1
shap.explainers._exact 100.0% 73.3% 30 1
shap.explainers._explainer 100.0% 66.7% 45 0
shap.explainers._gpu_tree 0.0% 0.0% 11 1
shap.explainers._gradient 100.0% 77.8% 18 1
shap.explainers._kernel 100.0% 82.0% 61 0
shap.explainers._linear 100.0% 69.4% 36 0
shap.explainers._partition 98.2% 77.2% 57 1
shap.explainers._permutation 97.1% 62.9% 35 0
shap.explainers._sampling 100.0% 64.7% 17 0
shap.explainers._tree 100.0% 80.8% 52 1
shap.explainers.other._coefficient 0.0% 0.0% 5 0
shap.explainers.other._lime 0.0% 0.0% 14 0
shap.explainers.other._maple 0.0% 0.0% 24 0
shap.explainers.other._random 0.0% 0.0% 19 0
shap.explainers.other._treegain 0.0% 0.0% 5 0
shap.explainers.pytree 0.0% 0.0% 88 0
shap.explainers.tf_utils 0.0% 0.0% 0 0
shap.links 100.0% 100.0% 4 2
shap.maskers._composite 94.1% 64.7% 17 1
shap.maskers._fixed 100.0% 62.5% 8 1
shap.maskers._fixed_composite 0.0% 0.0% 11 0
shap.maskers._image 0.0% 0.0% 25 0
shap.maskers._masker 100.0% 62.5% 8 0
shap.maskers._output_composite 0.0% 0.0% 13 0
shap.maskers._tabular 0.0% 0.0% 14 0
shap.maskers._text 0.0% 0.0% 41 0
shap.models._model 90.9% 63.6% 11 0
shap.models._teacher_forcing 7.1% 7.1% 42 0
shap.models._text_generation 3.7% 3.7% 27 0
shap.models._topk_lm 2.7% 2.7% 37 0
shap.models._transformers_pipeline 0.0% 0.0% 10 0
shap.plots._bar 0.0% 0.0% 9 0
shap.plots._beeswarm 64.7% 64.7% 17 1
shap.plots._benchmark 0.0% 0.0% 3 0
shap.plots._decision 17.4% 17.4% 23 0
shap.plots._embedding 0.0% 0.0% 7 0
shap.plots._force 0.0% 0.0% 16 0
shap.plots._group_difference 0.0% 0.0% 11 0
shap.plots._heatmap 10.0% 10.0% 10 0
shap.plots._image 78.6% 78.6% 14 0
shap.plots._monitoring 0.0% 0.0% 6 0
shap.plots._partial_dependence 0.0% 0.0% 20 0
shap.plots._scatter 77.8% 77.8% 18 0
shap.plots._text 0.0% 0.0% 9 0
shap.plots._violin 0.0% 0.0% 23 1
shap.plots._waterfall 0.0% 0.0% 4 0
shap.plots.colors._colors 0.0% 0.0% 13 0
shap.utils._clustering 100.0% 100.0% 21 5
shap.utils._general 100.0% 80.9% 47 0
shap.utils._legacy 0.0% 0.0% 4 0
shap.utils._masked_model 0.0% 0.0% 31 0
shap.utils._show_progress 100.0% 100.0% 6 0
shap.utils.image 0.0% 0.0% 21 0
shap.utils.transformers 0.0% 0.0% 7 0

Incomplete Annotations

shap._explanation (28 missing, 3 any)

Symbol Typable Typed Any
meth Explanation.getitem 2 1 0
meth Explanation._numpy_func 3 3 1
prop Explanation.values 2 0 0
prop Explanation.base_values 2 0 0
prop Explanation.data 2 0 0
prop Explanation.display_data 2 0 0
prop Explanation.instance_names 1 0 0
prop Explanation.output_names 2 0 0
prop Explanation.output_indexes 1 0 0
prop Explanation.feature_names 2 0 0
prop Explanation.lower_bounds 1 0 0
prop Explanation.upper_bounds 1 0 0
prop Explanation.error_std 1 0 0
prop Explanation.main_effects 2 0 0
prop Explanation.hierarchical_values 2 0 0
prop Explanation.clustering 2 0 0
attr Explanation.compute_time 1 0 0
attr Explanation.output_dims 1 0 0
meth Cohorts.getitem 2 1 0
meth Cohorts.call 3 3 2
attr Cohorts.cohorts 1 0 0

shap.actions._action (8 missing, 0 any)

Symbol Typable Typed Any
meth Action.init 2 0 0
meth Action.call 2 0 0
meth Action.lt 2 0 0
meth Action.repr 1 0 0
attr Action.cost 1 0 0

shap.actions._optimizer (6 missing, 0 any)

Symbol Typable Typed Any
meth ActionOptimizer.init 3 1 0
meth ActionOptimizer.call 3 0 0
attr ActionOptimizer.model 1 0 0

shap.explainers._additive (1 missing, 12 any)

Symbol Typable Typed Any
meth AdditiveExplainer.init 6 6 3
meth AdditiveExplainer.call 9 9 4
meth AdditiveExplainer.supports_model_with_masker 3 3 2
meth AdditiveExplainer.explain_row 8 8 3
attr AdditiveExplainer.model 1 0 0

shap.explainers._coalition (1 missing, 12 any)

Symbol Typable Typed Any
meth CoalitionExplainer.init 8 8 3
meth CoalitionExplainer.call 10 10 4
meth CoalitionExplainer.explain_row 9 9 2
attr CoalitionExplainer.expected_value 1 1 1
attr CoalitionExplainer._reshaped_model 1 1 1
attr CoalitionExplainer._clustering 1 1 1
attr CoalitionExplainer.model 1 0 0

shap.explainers._deep (11 missing, 0 any)

Symbol Typable Typed Any
meth DeepExplainer.init 5 0 0
meth DeepExplainer.shap_values 5 0 0
attr DeepExplainer.expected_value 1 0 0

shap.explainers._exact (0 missing, 8 any)

Symbol Typable Typed Any
meth ExactExplainer.init 6 6 4
meth ExactExplainer.call 8 8 2
meth ExactExplainer.explain_row 9 9 2

shap.explainers._explainer (0 missing, 15 any)

Symbol Typable Typed Any
meth Explainer.init 10 10 3
meth Explainer.call 9 9 3
meth Explainer.explain_row 8 8 3
meth Explainer.supports_model_with_masker 3 3 2
meth Explainer.save 4 4 1
meth Explainer.load 5 5 1
attr Explainer.model 1 1 1
attr Explainer.masker 1 1 1

shap.explainers._gpu_tree (11 missing, 0 any)

Symbol Typable Typed Any
meth GPUTreeExplainer.shap_values 7 0 0
meth GPUTreeExplainer.shap_interaction_values 4 0 0

shap.explainers._gradient (0 missing, 4 any)

Symbol Typable Typed Any
meth GradientExplainer.init 6 6 2
meth GradientExplainer.call 3 3 1
meth GradientExplainer.shap_values 7 7 1

shap.explainers._kernel (0 missing, 11 any)

Symbol Typable Typed Any
meth KernelExplainer.init 6 6 3
meth KernelExplainer._convert_symbolic_tensor 2 2 1
meth KernelExplainer.shap_values 3 3 1
meth KernelExplainer.explain 3 3 2
meth KernelExplainer.not_equal 3 3 2
attr KernelExplainer.link 1 1 1
attr KernelExplainer.model 1 1 1

shap.explainers._linear (0 missing, 11 any)

Symbol Typable Typed Any
meth LinearExplainer.init 7 7 3
meth LinearExplainer._parse_model 2 2 1
meth LinearExplainer.supports_model_with_masker 3 3 2
meth LinearExplainer.explain_row 8 8 3
attr LinearExplainer.coef 1 1 1
attr LinearExplainer.intercept 1 1 1

shap.explainers._partition (1 missing, 12 any)

Symbol Typable Typed Any
meth PartitionExplainer.init 8 8 3
meth PartitionExplainer.call 10 10 3
meth PartitionExplainer.explain_row 10 10 3
meth PartitionExplainer.owen 9 9 1
meth PartitionExplainer.owen3 9 9 1
attr PartitionExplainer.expected_value 1 1 1
attr PartitionExplainer.model 1 0 0

shap.explainers._permutation (1 missing, 12 any)

Symbol Typable Typed Any
meth PermutationExplainer.init 8 8 4
meth PermutationExplainer.call 9 9 3
meth PermutationExplainer.explain_row 9 9 3
meth PermutationExplainer.shap_values 7 7 2
attr PermutationExplainer.model 1 0 0

shap.explainers._sampling (0 missing, 6 any)

Symbol Typable Typed Any
meth SamplingExplainer.init 4 4 2
meth SamplingExplainer.call 4 4 1
meth SamplingExplainer.explain 3 3 2
meth SamplingExplainer.sampling_estimate 6 6 1

shap.explainers._tree (0 missing, 10 any)

Symbol Typable Typed Any
meth TreeExplainer.init 9 9 4
meth TreeExplainer.call 6 6 1
meth TreeExplainer.shap_values 7 7 1
meth TreeExplainer._get_shap_output 3 3 1
meth TreeExplainer.supports_model_with_masker 3 3 2
attr TreeExplainer.expected_value 1 1 1

shap.explainers.other._coefficient (5 missing, 0 any)

Symbol Typable Typed Any
meth Coefficient.init 2 0 0
meth Coefficient.attributions 2 0 0
attr Coefficient.model 1 0 0

shap.explainers.other._lime (14 missing, 0 any)

Symbol Typable Typed Any
meth LimeTabular.init 4 0 0
meth LimeTabular.attributions 4 0 0
attr LimeTabular.model 1 0 0
attr LimeTabular.mode 1 0 0
attr LimeTabular.data 1 0 0
attr LimeTabular.explainer 1 0 0
attr LimeTabular.out_dim 1 0 0
attr LimeTabular.flat_out 1 0 0

shap.explainers.other._maple (24 missing, 0 any)

Symbol Typable Typed Any
meth Maple.init 3 0 0
meth Maple.attributions 3 0 0
attr Maple.model 1 0 0
attr Maple.data 1 0 0
attr Maple.data_mean 1 0 0
attr Maple.explainer 1 0 0
attr Maple.out_dim 1 0 0
attr Maple.flat_out 1 0 0
meth TreeMaple.init 3 0 0
meth TreeMaple.attributions 3 0 0
attr TreeMaple.model 1 0 0
attr TreeMaple.data 1 0 0
attr TreeMaple.data_mean 1 0 0
attr TreeMaple.explainer 1 0 0
attr TreeMaple.out_dim 1 0 0
attr TreeMaple.flat_out 1 0 0

shap.explainers.other._random (19 missing, 0 any)

Symbol Typable Typed Any
meth Random.init 8 0 0
meth Random.explain_row 8 0 0
attr Random.constant 1 0 0
attr Random.constant_attributions 1 0 0
attr Random.model 1 0 0

shap.explainers.other._treegain (5 missing, 0 any)

Symbol Typable Typed Any
meth TreeGain.init 2 0 0
meth TreeGain.attributions 2 0 0
attr TreeGain.model 1 0 0

shap.explainers.pytree (88 missing, 0 any)

Symbol Typable Typed Any
func unwind_path 7 0 0
meth TreeExplainer.init 3 0 0
meth TreeExplainer.shap_values 4 0 0
meth TreeExplainer.shap_interaction_values 4 0 0
meth TreeExplainer.tree_shap 7 0 0
attr TreeExplainer.model_type 1 0 0
attr TreeExplainer.trees 1 0 0
attr TreeExplainer.feature_indexes 1 0 0
attr TreeExplainer.zero_fractions 1 0 0
attr TreeExplainer.one_fractions 1 0 0
attr TreeExplainer.pweights 1 0 0
func extend_path 9 0 0
func compute_expectations 7 0 0
func tree_shap_recursive 23 0 0
meth Tree.init 3 0 0
attr Tree.children_left 1 0 0
attr Tree.children_right 1 0 0
attr Tree.children_default 1 0 0
attr Tree.features 1 0 0
attr Tree.thresholds 1 0 0
attr Tree.node_sample_weight 1 0 0
attr Tree.max_depth 1 0 0
attr Tree.values 1 0 0
func unwound_path_sum 7 0 0

shap.maskers._composite (1 missing, 5 any)

Symbol Typable Typed Any
meth Composite.shape 2 2 1
meth Composite.mask_shapes 2 2 1
meth Composite.data_transform 2 2 1
meth Composite.call 3 3 2
attr Composite.clustering 1 0 0

shap.maskers._fixed (0 missing, 3 any)

Symbol Typable Typed Any
meth Fixed.call 3 3 2
meth Fixed.mask_shapes 2 2 1

shap.maskers._fixed_composite (11 missing, 0 any)

Symbol Typable Typed Any
meth FixedComposite.init 2 0 0
meth FixedComposite.call 3 0 0
meth FixedComposite.save 2 0 0
meth FixedComposite.load 3 0 0
attr FixedComposite.masker 1 0 0

shap.maskers._image (25 missing, 0 any)

Symbol Typable Typed Any
meth Image.init 3 0 0
meth Image.call 3 0 0
meth Image.inpaint 4 0 0
meth Image.build_partition_tree 1 0 0
meth Image.save 2 0 0
meth Image.load 3 0 0
attr Image.input_mask_value 1 0 0
attr Image.shape 1 0 0
attr Image.image_data 1 0 0
attr Image.blur_kernel 1 0 0
attr Image.fixed_background 1 0 0
attr Image.last_xid 1 0 0
attr Image.immutable_outputs 1 0 0
attr Image.input_shape 1 0 0
attr Image.mask_value 1 0 0

shap.maskers._masker (0 missing, 3 any)

Symbol Typable Typed Any
meth Masker.call 3 3 2
meth Masker._standardize_mask 3 3 1

shap.maskers._output_composite (13 missing, 0 any)

Symbol Typable Typed Any
meth OutputComposite.init 3 0 0
meth OutputComposite.call 3 0 0
meth OutputComposite.save 2 0 0
meth OutputComposite.load 3 0 0
attr OutputComposite.masker 1 0 0
attr OutputComposite.model 1 0 0

shap.maskers._tabular (14 missing, 0 any)

Symbol Typable Typed Any
meth Impute.init 3 0 0
attr Impute.data 1 0 0
attr Impute.method 1 0 0
attr Impute.mean 1 0 0
attr Impute.cov 1 0 0
meth Partition.init 4 0 0
meth Independent.init 3 0 0

shap.maskers._text (41 missing, 0 any)

Symbol Typable Typed Any
meth Text.init 5 0 0
meth Text.call 3 0 0
meth Text.data_transform 2 0 0
meth Text.token_segments 2 0 0
meth Text.clustering 2 0 0
meth Text._update_s_cache 2 0 0
meth Text.shape 2 0 0
meth Text.mask_shapes 2 0 0
meth Text.invariants 2 0 0
meth Text.feature_names 2 0 0
meth Text.save 2 0 0
meth Text.load 3 0 0
attr Text.output_type 1 0 0
attr Text.collapse_mask_token 1 0 0
attr Text.input_mask_token 1 0 0
attr Text.mask_token 1 0 0
attr Text.mask_token_id 1 0 0
attr Text.keep_prefix 1 0 0
attr Text.keep_suffix 1 0 0
attr Text.text_data 1 0 0
attr Text.fixed_background 1 0 0
attr Text.default_batch_size 1 0 0
attr Text.immutable_outputs 1 0 0
attr Text.tokenizer 1 0 0

shap.models._model (1 missing, 3 any)

Symbol Typable Typed Any
meth Model.init 2 2 1
meth Model.call 2 2 1
attr Model.inner_model 1 1 1
attr Model.output_names 1 0 0

shap.models._teacher_forcing (39 missing, 0 any)

Symbol Typable Typed Any
meth TeacherForcing.init 7 0 0
meth TeacherForcing.call 3 0 0
meth TeacherForcing.update_output_names 2 1 0
meth TeacherForcing.get_output_names 2 0 0
meth TeacherForcing.get_outputs 2 0 0
meth TeacherForcing.get_inputs 3 0 0
meth TeacherForcing.get_logodds 2 0 0
meth TeacherForcing.model_inference 3 0 0
meth TeacherForcing.get_teacher_forced_logits 3 0 0
meth TeacherForcing.save 2 0 0
meth TeacherForcing.load 3 0 0
attr TeacherForcing.tokenizer 1 0 0
attr TeacherForcing.device 1 0 0
attr TeacherForcing.batch_size 1 0 0
attr TeacherForcing.similarity_model_type 1 0 0
attr TeacherForcing.text_generate 1 0 0
attr TeacherForcing.similarity_model 1 0 0
attr TeacherForcing.similarity_tokenizer 1 0 0
attr TeacherForcing.model_agnostic 1 0 0

shap.models._text_generation (26 missing, 0 any)

Symbol Typable Typed Any
meth TextGeneration.init 5 0 0
meth TextGeneration.call 2 0 0
meth TextGeneration.get_inputs 3 0 0
meth TextGeneration.model_generate 2 0 0
meth TextGeneration.parse_prefix_suffix_for_model_generate_output 2 0 0
meth TextGeneration.save 2 0 0
meth TextGeneration.load 3 0 0
attr TextGeneration.explanation_row 1 0 0
attr TextGeneration.tokenizer 1 0 0
attr TextGeneration.device 1 0 0
attr TextGeneration.X 1 0 0
attr TextGeneration.target_X 1 0 0
attr TextGeneration.inner_model 1 0 0
attr TextGeneration.model_agnostic 1 0 0

shap.models._topk_lm (36 missing, 0 any)

Symbol Typable Typed Any
meth TopKLM.init 7 0 0
meth TopKLM.call 3 0 0
meth TopKLM.update_cache_X 2 0 0
meth TopKLM.get_output_names_and_update_topk_token_ids 2 0 0
meth TopKLM.get_logodds 2 0 0
meth TopKLM.get_inputs 3 0 0
meth TopKLM.generate_topk_token_ids 2 1 0
meth TopKLM.get_lm_logits 2 0 0
meth TopKLM.save 2 0 0
meth TopKLM.load 3 0 0
attr TopKLM.tokenizer 1 0 0
attr TopKLM.k 1 0 0
attr TopKLM.batch_size 1 0 0
attr TopKLM.device 1 0 0
attr TopKLM.X 1 0 0
attr TopKLM.topk_token_ids 1 0 0
attr TopKLM.output_names 1 0 0
attr TopKLM.model_type 1 0 0
attr TopKLM.inner_model 1 0 0

shap.models._transformers_pipeline (10 missing, 0 any)

Symbol Typable Typed Any
meth TransformersPipeline.init 3 0 0
meth TransformersPipeline.call 2 0 0
attr TransformersPipeline.rescale_to_logits 1 0 0
attr TransformersPipeline.label2id 1 0 0
attr TransformersPipeline.id2label 1 0 0
attr TransformersPipeline.output_shape 1 0 0
attr TransformersPipeline.output_names 1 0 0

shap.plots._bar (9 missing, 0 any)

Symbol Typable Typed Any
func bar 9 0 0

shap.plots._beeswarm (6 missing, 0 any)

Symbol Typable Typed Any
func beeswarm 17 11 0

shap.plots._benchmark (3 missing, 0 any)

Symbol Typable Typed Any
func benchmark 3 0 0

shap.plots._decision (19 missing, 0 any)

Symbol Typable Typed Any
func decision 23 4 0

shap.plots._embedding (7 missing, 0 any)

Symbol Typable Typed Any
func embedding 7 0 0

shap.plots._force (16 missing, 0 any)

Symbol Typable Typed Any
func force 15 0 0
func initjs 1 0 0

shap.plots._group_difference (11 missing, 0 any)

Symbol Typable Typed Any
func group_difference 11 0 0

shap.plots._heatmap (9 missing, 0 any)

Symbol Typable Typed Any
func heatmap 10 1 0

shap.plots._image (3 missing, 0 any)

Symbol Typable Typed Any
func image 12 11 0
func image_to_text 2 0 0

shap.plots._monitoring (6 missing, 0 any)

Symbol Typable Typed Any
func monitoring 6 0 0

shap.plots._partial_dependence (20 missing, 0 any)

Symbol Typable Typed Any
func partial_dependence 20 0 0

shap.plots._scatter (4 missing, 0 any)

Symbol Typable Typed Any
func scatter 18 14 0

shap.plots._text (9 missing, 0 any)

Symbol Typable Typed Any
func text 9 0 0

shap.plots._violin (23 missing, 0 any)

Symbol Typable Typed Any
func violin 23 0 0

shap.plots._waterfall (4 missing, 0 any)

Symbol Typable Typed Any
func waterfall 4 0 0

shap.plots.colors._colors (13 missing, 0 any)

Symbol Typable Typed Any
attr red_blue_no_bounds 1 0 0
attr gray_rgb 1 0 0
attr red_white_blue 1 0 0
attr light_red_rgb 1 0 0
attr red_blue 1 0 0
attr blue_rgb 1 0 0
attr red_blue_transparent 1 0 0
attr transparent_red 1 0 0
attr red_transparent_blue 1 0 0
attr red_blue_circle 1 0 0
attr transparent_blue 1 0 0
attr light_blue_rgb 1 0 0
attr red_rgb 1 0 0

shap.utils._general (0 missing, 9 any)

Symbol Typable Typed Any
func safe_isinstance 3 3 1
func format_value 3 3 1
meth OpChain.apply 2 2 2
meth OpChain.call 3 3 2
meth OpChain.getitem 2 2 1
func potential_interactions 3 3 2

shap.utils._legacy (4 missing, 0 any)

Symbol Typable Typed Any
func kmeans 4 0 0

shap.utils._masked_model (31 missing, 0 any)

Symbol Typable Typed Any
meth MaskedModel.init 6 0 0
meth MaskedModel.call 4 0 0
meth MaskedModel._full_masking_call 4 0 0
meth MaskedModel._delta_masking_call 4 0 0
meth MaskedModel.len 1 0 0
meth MaskedModel.varying_inputs 1 0 0
meth MaskedModel.main_effects 3 0 0
prop MaskedModel.mask_shapes 1 0 0
attr MaskedModel.model 1 0 0
attr MaskedModel.masker 1 0 0
attr MaskedModel.link 1 0 0
attr MaskedModel.linearize_link 1 0 0
attr MaskedModel.args 1 0 0
func make_masks 2 0 0

shap.utils.image (21 missing, 0 any)

Symbol Typable Typed Any
func load_image 2 0 0
func add_sample_images 2 0 0
func make_dir 2 0 0
func check_valid_image 2 0 0
func save_image 3 0 0
func resize_image 3 0 0
func display_grid_plot 5 0 0
func is_empty 2 0 0

shap.utils.transformers (7 missing, 0 any)

Symbol Typable Typed Any
func is_transformers_lm 2 0 0
func parse_prefix_suffix_for_tokenizer 2 0 0
func getattr_silent 3 0 0

Type-Ignore Comments

Flavor Count
type: ignore[misc] 8
type: ignore 4
type: ignore[attr-defined] 4
type: ignore[override] 3
type: ignore[dict-item] 2