Skip to content

Commit

Permalink
Add heterogeneity_model checks (#1210)
Browse files Browse the repository at this point in the history
* Add hetrogenity_model checks

Signed-off-by: Gaurav Gupta <[email protected]>

* Fix lint

Signed-off-by: Gaurav Gupta <[email protected]>
  • Loading branch information
gaugup authored Feb 11, 2022
1 parent b7bd2af commit 18d38dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ModelTypes:
"""Model type constants."""
AUTOML = 'automl'
LINEAR = 'linear'
FOREST = 'forest'


class DefaultParams:
Expand Down
8 changes: 8 additions & 0 deletions responsibleai/responsibleai/managers/causal_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ def add(
f"got {nuisance_model}")
raise UserConfigValidationException(message)

if heterogeneity_model not in [ModelTypes.FOREST,
ModelTypes.LINEAR]:
message = (f"heterogeneity_model should be one of "
f"['{ModelTypes.FOREST}', "
f"'{ModelTypes.LINEAR}'], "
f"got {heterogeneity_model}")
raise UserConfigValidationException(message)

validate_train_test_categories(
train_data=self._train,
test_data=self._test,
Expand Down
7 changes: 6 additions & 1 deletion responsibleai/tests/causal_manager_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@ def validate_causal(rai_insights, data, target_column,
_check_causal_properties(rai_insights.causal.list(),
expected_causal_effects=2)

# Add a bad configuration
# Add a bad configuration for nuisance_model
with pytest.raises(UserConfigValidationException):
rai_insights.causal.add(treatment_features,
nuisance_model='fake_model')

# Add a bad configuration for heterogeneity_model
with pytest.raises(UserConfigValidationException):
rai_insights.causal.add(treatment_features,
heterogeneity_model='fake_model')


def _check_causal_properties(
causal_props, expected_causal_effects):
Expand Down

0 comments on commit 18d38dd

Please sign in to comment.