|
| 1 | +import pytest |
| 2 | +from dice_ml.utils.exception import UserConfigValidationException |
| 3 | + |
| 4 | + |
| 5 | +class TestExplainerBaseBinaryClassification: |
| 6 | + |
| 7 | + @pytest.mark.parametrize("desired_class, binary_classification_exp_object", [(1, 'random'),(1,'genetic'),(1,'kdtree')], indirect=['binary_classification_exp_object']) |
| 8 | + def test_zero_totalcfs(self, desired_class, binary_classification_exp_object, sample_custom_query_1): |
| 9 | + exp = binary_classification_exp_object # explainer object |
| 10 | + with pytest.raises(UserConfigValidationException): |
| 11 | + exp.generate_counterfactuals( |
| 12 | + query_instances=[sample_custom_query_1], |
| 13 | + total_CFs=0, |
| 14 | + desired_class=desired_class) |
| 15 | + |
| 16 | +class TestExplainerBaseMultiClassClassification: |
| 17 | + |
| 18 | + @pytest.mark.parametrize("desired_class, multi_classification_exp_object", [(1, 'random'),(1,'genetic'),(1,'kdtree')], indirect=['multi_classification_exp_object']) |
| 19 | + def test_zero_totalcfs(self, desired_class, multi_classification_exp_object, sample_custom_query_1): |
| 20 | + exp = multi_classification_exp_object # explainer object |
| 21 | + with pytest.raises(UserConfigValidationException): |
| 22 | + exp.generate_counterfactuals( |
| 23 | + query_instances=[sample_custom_query_1], |
| 24 | + total_CFs=0, |
| 25 | + desired_class=desired_class) |
| 26 | + |
| 27 | + |
| 28 | +class TestExplainerBaseRegression: |
| 29 | + |
| 30 | + @pytest.mark.parametrize("desired_class, regression_exp_object", [(1, 'random'),(1,'genetic'),(1,'kdtree')], indirect=['regression_exp_object']) |
| 31 | + def test_zero_totalcfs(self, desired_class, regression_exp_object, sample_custom_query_1): |
| 32 | + exp = regression_exp_object # explainer object |
| 33 | + with pytest.raises(UserConfigValidationException): |
| 34 | + exp.generate_counterfactuals( |
| 35 | + query_instances=[sample_custom_query_1], |
| 36 | + total_CFs=0, |
| 37 | + desired_class=desired_class) |
0 commit comments