@@ -50,6 +50,8 @@ def generate_counterfactuals(self, query_instances, total_CFs,
5050 desired_class = "opposite" , desired_range = None ,
5151 permitted_range = None , features_to_vary = "all" ,
5252 stopping_threshold = 0.5 , posthoc_sparsity_param = 0.1 ,
53+ proximity_weight = 0.2 , sparsity_weight = 0.2 , diversity_weight = 5.0 ,
54+ categorical_penalty = 0.1 ,
5355 posthoc_sparsity_algorithm = "linear" , verbose = False , ** kwargs ):
5456 """General method for generating counterfactuals.
5557
@@ -65,6 +67,15 @@ def generate_counterfactuals(self, query_instances, total_CFs,
6567 If None, uses the parameters initialized in data_interface.
6668 :param features_to_vary: Either a string "all" or a list of feature names to vary.
6769 :param stopping_threshold: Minimum threshold for counterfactuals target class probability.
70+ :param proximity_weight: A positive float. Larger this weight, more close the counterfactuals are to the
71+ query_instance. Used by ['genetic', 'gradientdescent'],
72+ ignored by ['random', 'kdtree'] methods.
73+ :param sparsity_weight: A positive float. Larger this weight, less features are changed from the query_instance.
74+ Used by ['genetic', 'kdtree'], ignored by ['random', 'gradientdescent'] methods.
75+ :param diversity_weight: A positive float. Larger this weight, more diverse the counterfactuals are.
76+ Used by ['genetic', 'gradientdescent'], ignored by ['random', 'kdtree'] methods.
77+ :param categorical_penalty: A positive float. A weight to ensure that all levels of a categorical variable sums to 1.
78+ Used by ['genetic', 'gradientdescent'], ignored by ['random', 'kdtree'] methods.
6879 :param posthoc_sparsity_param: Parameter for the post-hoc operation on continuous features to enhance sparsity.
6980 :param posthoc_sparsity_algorithm: Perform either linear or binary search. Takes "linear" or "binary".
7081 Prefer binary search when a feature range is large (for instance,
0 commit comments