robustx.generators package
Subpackages
- robustx.generators.CE_methods package
- Submodules
- robustx.generators.CE_methods.BinaryLinearSearch module
- robustx.generators.CE_methods.GuidedBinaryLinearSearch module
- robustx.generators.CE_methods.KDTreeNNCE module
- robustx.generators.CE_methods.MCE module
- robustx.generators.CE_methods.NNCE module
- robustx.generators.CE_methods.Wachter module
- Module contents
- robustx.generators.robust_CE_methods package
- Submodules
- robustx.generators.robust_CE_methods.APAS module
- robustx.generators.robust_CE_methods.ArgEnsembling module
- robustx.generators.robust_CE_methods.DiverseRobustCE module
- robustx.generators.robust_CE_methods.MCER module
- robustx.generators.robust_CE_methods.ModelMultiplicityMILP module
- robustx.generators.robust_CE_methods.PROPLACE module
- robustx.generators.robust_CE_methods.RNCE module
- robustx.generators.robust_CE_methods.ROAR module
- robustx.generators.robust_CE_methods.STCE module
- Module contents
Submodules
robustx.generators.CEGenerator module
- class robustx.generators.CEGenerator.CEGenerator(ct, custom_distance_func=None)[source]
Bases:
ABC
Abstract class for generating counterfactual explanations for a given task.
This class provides a framework for generating counterfactuals based on a distance function and a given task. It supports default distance functions such as Euclidean and Manhattan, and allows for custom distance functions.
- __customFunc
A custom distance function.
- Type:
callable, optional
- property custom_distance_func
Returns custom distance function passed at instantiation @return: distance Function, (DataFrame, DataFrame) -> Int
- generate(instances, neg_value=0, column_name='target', **kwargs)[source]
Generates counterfactuals for a given DataFrame of instances.
@param instances: A DataFrame of instances for which you want to generate counterfactuals explanations. @param distance_func: The method to calculate the distance between two points. Options are ‘l1’ / ‘manhattan’, ‘l2’ / ‘euclidean’, and ‘custom’. @param column_name: The name of the target column. @param neg_value: The value considered negative in the target variable. @return: A DataFrame of the counterfactual explanations for the provided instances.
- Return type:
DataFrame
- generate_for_all(neg_value=0, column_name='target', **kwargs)[source]
Generates counterfactuals for all instances with a given negative value in their target column.
@param neg_value: The value in the target column which counts as a negative instance. @param column_name: The name of the target variable. @param distance_func: The method to calculate the distance between two points. Options are ‘l1’ / ‘manhattan’, ‘l2’ / ‘euclidean’, and ‘custom’. @return: A DataFrame of the counterfactuals for all negative values.
- Return type:
DataFrame
- generate_for_instance(instance, neg_value=0, column_name='target', **kwargs)[source]
Generates a counterfactual for a provided instance.
@param instance: The instance for which you would like to generate a counterfactual. @param distance_func: The method to calculate the distance between two points. Options are ‘l1’ / ‘manhattan’, ‘l2’ / ‘euclidean’, and ‘custom’. @param column_name: The name of the target column. @param neg_value: The value considered negative in the target variable. @return: A DataFrame containing the counterfactual explanations for the instance.
- Return type:
DataFrame
- property task