Closed Chen2908 closed 3 years ago
Just to clarify, all feature values are either 0 or 1?
It eoul be good to know what type of classifier are you implementing. The CF search algorithm is gradient based so it assumes you can get some gradient signal df(x)/dx (f - model, x - input) which will be very tricky for non-differentiable models like tree based or rule based methods.
Also, the method works in continuous space, so assuming we can make the optimisation process work, the output counterfactuals will have non-binary values in general, is this something that is acceptable for your use case?
Hello, I've tried using CounterFactualProto to produce counterfactual explanations. A little background on our data and model: I have a dataset for a classification task where all features have a binary value. My model is a custom model, which derives from the scikit learn most basic model ClassifierMixin. I implement the fit, predict and predict_proba for my model. I following your documentation and examples but explanations are not produced. I was wondering if it has anything to do with the features binary values. Below in the code I use: shape = (1,) + background_set.shape[1:] func_predict_proba = lambda x: self.null_model.predict_proba(x, self.counter) explainer = CounterFactualProto(func_predict_proba, shape, use_kdtree=True, feature_range=(0.0, 1.0)) explainer.fit(background_set) explanation = explainer.explain(record_to_explain_df) print(f'Original prediction: {explanation.orig_class}') print('Counterfactual prediction: {}'.format(explanation.explainer['class']))
However in the explanation I get 'cf: None'. I tried different eps values with no luck. Any thoughts?
Thanks in advance.