← Về thư mục
tests/shap/test_scripts.py
- ArgumentBoundTests · class · L53-L73 — class ArgumentBoundTests(unittest.TestCase)
- test_a_positive_integer_is_accepted_and_zero_is_not · method · L54-L61 — def test_a_positive_integer_is_accepted_and_zero_is_not(self) -> None: # --background-size 0 would build an empty background, which makes every # SHAP value meaningless rather than merely wrong.
- test_zero_is_a_valid_class_index_but_a_negative_one_is_not · method · L63-L66 — def test_zero_is_a_valid_class_index_but_a_negative_one_is_not(self) -> None
- test_tolerances_must_be_strictly_positive · method · L68-L73 — def test_tolerances_must_be_strictly_positive(self) -> None
- SingleOutputStub · class · L76-L80 — class SingleOutputStub
- init · method · L79-L80 — def init(self, shape: tuple[int, ...]) -> None
- OutputSelectionTests · class · L83-L112 — class OutputSelectionTests(unittest.TestCase)
- test_a_two_dimensional_explanation_is_returned_unchanged_for_class_zero · method · L84-L86 — def test_a_two_dimensional_explanation_is_returned_unchanged_for_class_zero(self) -> None
- test_a_two_dimensional_explanation_rejects_any_other_class · method · L88-L90 — def test_a_two_dimensional_explanation_rejects_any_other_class(self) -> None
- test_an_unexpected_rank_names_the_shape_it_got · method · L92-L96 — def test_an_unexpected_rank_names_the_shape_it_got(self) -> None
- test_a_class_index_past_the_last_output_is_rejected · method · L98-L100 — def test_a_class_index_past_the_last_output_is_rejected(self) -> None
- test_output_names_fall_back_to_a_positional_label · method · L102-L106 — def test_output_names_fall_back_to_a_positional_label(self) -> None
- test_a_named_output_keeps_its_name · method · L108-L112 — def test_a_named_output_keeps_its_name(self) -> None
- ExplanationTests · class · L115-L180 — class ExplanationTests(unittest.TestCase)
- setUpClass · method · L119-L133 — def setUpClass(cls) -> None
- test_the_explainer_produces_one_slice_per_class · method · L135-L138 — def test_the_explainer_produces_one_slice_per_class(self) -> None
- test_selecting_a_class_takes_that_slice_and_no_other · method · L140-L148 — def test_selecting_a_class_takes_that_slice_and_no_other(self) -> None
- test_shap_values_reconstruct_the_predicted_probability · method · L150-L161 — def test_shap_values_reconstruct_the_predicted_probability(self) -> None: # The defining property: base value + contributions = model output. The # script asserts this with np.testing.assert_allclose; here the target # is recomputed from predict_proba so the check is independent.
- test_the_two_class_slices_are_mirror_images · method · L163-L167 — def test_the_two_class_slices_are_mirror_images(self) -> None: # Binary probabilities sum to one, so each feature's contribution to # class 1 must be the negative of its contribution to class 0.
- test_the_base_value_is_the_background_mean_prediction · method · L169-L180 — def test_the_base_value_is_the_background_mean_prediction(self) -> None: # With an interventional masker the base value is the model's average # output over the background sample, and it is identical for every row.
- FigureExportTests · class · L183-L205 — class FigureExportTests(unittest.TestCase)
- setUp · method · L184-L185 — def setUp(self) -> None
- test_saving_an_axis_writes_a_file_and_leaves_no_open_figure · method · L187-L196 — def test_saving_an_axis_writes_a_file_and_leaves_no_open_figure(self) -> None: # A report that exports four figures without closing them exhausts # matplotlib's figure warning threshold and leaks memory.
- test_a_missing_axis_falls_back_to_the_current_figure · method · L198-L205 — def test_a_missing_axis_falls_back_to_the_current_figure(self) -> None: # Some shap.plots helpers return None and draw into gcf().
- ReportRunTests · class · L208-L309 — class ReportRunTests(unittest.TestCase)
- setUpClass · method · L212-L233 — def setUpClass(cls) -> None
- tearDownClass · method · L236-L237 — def tearDownClass(cls) -> None
- test_every_documented_artefact_is_written · method · L239-L253 — def test_every_documented_artefact_is_written(self) -> None
- test_the_metadata_records_the_run_it_actually_did · method · L255-L264 — def test_the_metadata_records_the_run_it_actually_did(self) -> None
- test_the_additivity_error_is_inside_the_tolerance_it_reports · method · L266-L270 — def test_the_additivity_error_is_inside_the_tolerance_it_reports(self) -> None
- test_the_reconstruction_csv_adds_up_row_by_row · method · L272-L284 — def test_the_reconstruction_csv_adds_up_row_by_row(self) -> None
- test_the_importance_table_is_ranked_by_mean_absolute_shap · method · L286-L293 — def test_the_importance_table_is_ranked_by_mean_absolute_shap(self) -> None
- test_the_first_row_breakdown_is_ordered_by_contribution_size · method · L295-L305 — def test_the_first_row_breakdown_is_ordered_by_contribution_size(self) -> None
- test_the_run_prints_its_metadata_and_where_it_wrote · method · L307-L309 — def test_the_run_prints_its_metadata_and_where_it_wrote(self) -> None
- ReportFailureTests · class · L312-L338 — class ReportFailureTests(unittest.TestCase)
- test_a_class_index_outside_the_model_is_rejected_before_any_work · method · L313-L328 — def test_a_class_index_outside_the_model_is_rejected_before_any_work(self) -> None
- test_a_negative_background_size_is_refused_by_the_parser · method · L330-L338 — def test_a_negative_background_size_is_refused_by_the_parser(self) -> None