model_remediation.counterfactual.keras.utils.validate_counterfactual_structure

Validates that struct is a valid Counterfactual structure.

struct Structure that will be validated.
struct_name Name of struct, used only for error messages.
element_type Type of elements. If None, types are not checked.

A struct is a valid Counterfactual structure if it is either a single element (including tuples) or is an unnested dictionary (with string keys). If element_type is set, the function will also validate that all elements are of the correct type.

TypeError If struct is neither a single element (including a tuple) nor a dict.
ValueError If struct is a dict with non-string keys.
ValueError If struct is a dict with values that are not single elements (including tuples).