trustyai.model.feature_domain
- trustyai.model.feature_domain(values: Tuple | List | None) FeatureDomain | None
Create a Java
FeatureDomain. This represents the valid range of values for a particular feature, which is useful when constraining a counterfactual explanation to ensure it only recovers valid inputs. For example, if we had a feature that described a person’s age, we might want to constrain it to the range [0, 125] to ensure the counterfactual explanation doesn’t return unlikely ages such as -5 or 715.- Parameters:
- valuesOptional[Union[Tuple, List]]
The valid values of the feature. If
valuestakes the form of:A tuple of floats or integers: The feature domain will be a continuous range from
values[0]tovalues[1].A list of floats or integers: The feature domain will be a numeric categorical, where values contains all possible valid feature values.
A list of strings: The feature domain will be a string categorical, where
valuescontains all possible valid feature values.A list of objects: The feature domain will be an object categorical, where
valuescontains all possible valid feature values. These may present an issue if the objects are not natively Java serializable.
Otherwise, the feature domain will be taken as Empty, which will mean it will be held fixed during the counterfactual explanation.
- Returns:
FeatureDomainA Java
FeatureDomainobject, to be used in thefeature()function.