DiCE icon indicating copy to clipboard operation
DiCE copied to clipboard

[Question] Does DiCE support user-constrained feature ranges?

Open siebediels opened this issue 5 years ago • 4 comments

I'd like to enforce constraints on the ranges that each feature can take when being perturbed - for example limiting 'hours_per_week' to anything within [40,60]. Is this currently possible, either directly through the interface or by changing some internals?

I read about it in your paper, but haven't yet found out how to implement this in practice. Relevant excerpt:

(...) to provide constraints on feature manipulation. They can be specified in two ways. First, as box constraints on feasible ranges for each feature, within which CF examples need to be searched."

Thanks in advance! Siebe

siebediels avatar May 19 '20 10:05 siebediels

Hey, you can specify box constraints using permitted_range parameter while initiating data object d. For instance, you can do d = dice_ml.Data(dataframe=dataset, continuous_features=['age', 'hours_per_week'], outcome_name='income', permitted_range={'hours_per_week':[40,60]})

https://github.com/interpretml/DiCE/blob/master/dice_ml/data_interfaces/public_data_interface.py#L21

raam93 avatar May 19 '20 12:05 raam93

Hey, thank you very much for the quick and helpful reply.

siebediels avatar May 19 '20 12:05 siebediels

Hi, I'd like to ask a follow-up question, hope you don't mind.

Is there a way to manually set possible feature-ranges for categorical features (perhaps by tweaking some internals)? For continuous features it seems to work well, but I'd like to do something similar for categorical features. E.g. allowing "education" to take only the values ['bachelors', 'masters', 'prof-school'].

Looking forward to your reply. Siebe

siebediels avatar May 23 '20 16:05 siebediels

Currently, we don't support that, but it will be really good to have that option! Most likely a small tweak in https://github.com/interpretml/DiCE/blob/master/dice_ml/data_interfaces/public_data_interface.py#L242 method should work. I will have a look soon and update them. Meanwhile, please feel free to raise a pull request to do the same.

raam93 avatar Jun 03 '20 09:06 raam93