Skip to content

Commit

Permalink
Merge branch 'main' into gaugup/ReferPredictedValueCFData
Browse files Browse the repository at this point in the history
  • Loading branch information
gaugup authored Oct 30, 2023
2 parents a21327a + 4d8d9b7 commit 1bf94d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion responsibleai/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dice-ml>=0.10,<0.11
dice-ml>=0.11,<0.12
econml>=0.14.1
statsmodels<0.14.0
jsonschema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ class TestCounterfactualAdvancedFeatures(object):

@pytest.mark.parametrize('vary_all_features', [True, False])
@pytest.mark.parametrize('feature_importance', [True, False])
@pytest.mark.parametrize('encode_target_as_strings', [True, False])
def test_counterfactual_vary_features(
self, vary_all_features, feature_importance):
self, vary_all_features, feature_importance,
encode_target_as_strings):
X_train, X_test, y_train, y_test, feature_names, _ = \
create_iris_data()
if encode_target_as_strings:
y_train = y_train.astype(str)
y_test = y_test.astype(str)

model = create_lightgbm_classifier(X_train, y_train)
X_train['target'] = y_train
Expand All @@ -50,6 +55,23 @@ def test_counterfactual_vary_features(

cf_obj = rai_insights.counterfactual.get()[0]
assert cf_obj is not None
for index in range(0, len(cf_obj.cf_examples_list)):
assert isinstance(
cf_obj.cf_examples_list[
index].test_instance_df[
'target'].values[0], str) == encode_target_as_strings

assert cf_obj.cf_examples_list[
index].test_instance_df['target'].values[0] in set(
y_train)

cf_target_array = cf_obj.cf_examples_list[0].final_cfs_df[
'target'].values
for inner_index in range(0, 10):
assert isinstance(
cf_target_array[
inner_index], str) == encode_target_as_strings
assert cf_target_array[inner_index] in set(y_train)

@pytest.mark.parametrize('feature_importance', [True, False])
def test_counterfactual_permitted_range(self, feature_importance):
Expand Down

0 comments on commit 1bf94d3

Please sign in to comment.