Open vdesai24 opened 3 years ago
@vdesai24, the output for the counterfactual is currently only shows the desired_class which is either 0 or 1. We could add another column which can contain the probabilities of the target class in classification scenario.
@amit-sharma what do you think about adding additional column for adding probabilities in classification scenarios?
Regards,
yes, that's a good idea. We just need to call the classifier again on the returned CF data to obtain the predicted probabilities. This would be a general solution that can work for any CF method. For efficiency, we may make it as an optional flag, so that this additional computation is not done.
Hi, Thanks, when can I get this enhancement in the package.
Regards,
We will have to see how to prioritize this change, given the other enhancements we are working on. Hopefully this will be included in the next release, near Dec.
Thanks @amit-sharma
Hi @amit-sharma may I know if this enhancement has been updated? Thanks!
Hi,
I am trying to generate counterfactuals for a classification model. Trained the model using RandomForestClassifier. I am expecting the target variable should show the predicted probability. It is showing predicted class instead. What changes do I need to make to give me the predcited probabilities in the generated counterfactuals. Below is the code to generate counterfactuals: model = RandomForestClassifier() d = dice_ml.Data(dataframe=train_dataset, continuous_features=['age', 'hours_per_week'], outcome_name='income') m = dice_ml.Model(model=model, model_type='classifier',backend="sklearn") exp = dice_ml.Dice(d, m, method="random")
e1 = exp.generate_counterfactuals(x_test[0:1], total_CFs=5, desired_class='opposite') e1.visualize_as_dataframe(show_only_changes=True)
Output:
I need predicted probabilities instead of the predicted class in the outcome.