Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add mitigation algorithm from "Optimized Pre-Processing for Discrimination Prevention" by Calmon et al. #1028

Open
4 tasks
hildeweerts opened this issue Feb 15, 2022 · 4 comments · May be fixed by #1340
Open
4 tasks
Assignees
Labels
enhancement New feature or request help wanted

Comments

@hildeweerts
Copy link
Contributor

The paper Optimized Pre-Processing for Discrimination Prevention by Calmon et al. introduces a preprocessing algorithm for demographic parity while limiting the number of individual distortions. The goal of this task is to add the algorithm described in this paper to Fairlearn.

  • The original implementation by the authors of the paper can be found here.
  • An existing implementation can be found in AIF360 OptimPreproc.

Completing this item requires:

  • technique code in fairlearn.preprocessing
  • unit tests in test.unit.preprocessing
  • descriptive API reference (directly in the docstring)
  • a short user guide in docs.user_guide.mitigation.rst

A fully fledged example notebook is not required.

To claim this task please respond below. Of course, you can also ask questions!

@hildeweerts hildeweerts added enhancement New feature or request help wanted labels Feb 15, 2022
@rakesh9177
Copy link

Hello @hildeweerts , I would like to work on this. I have some idea on this paper and have already implemented code on this. Can I work on this one?

@hildeweerts
Copy link
Contributor Author

Hi @rakesh9177, many thanks for your interest! I will assign this issue to you.

I do want to emphasize that adding a new algorithm to Fairlearn is quite a substantial task! Before you spend a lot of time on the actual implementation, I therefore highly highly highly recommend you post your plans (API design etc.) and any other questions you have in this issue thread.

We try to adhere to the scikit-learn API conventions as much as we can. As this is a pre-processing algorithm, I'd recommend you check out the implementation of CorrelationRemover as an example.

Let me know if anything is unclear at this stage!

@rakesh9177
Copy link

Thank you @hildeweerts ,

I reviewed the above code of Correlation remover and intend to follow similar structure as scikit-learn implementation. I also reviewed the code implemented in AIF360

I want to implement in such a way that user can use it in below way

from fairlearn.preprocessing import OptimizedPreprocessor 
df = adult_data()

X_feature_names = ["Age (decade)", "Education Years"]
Y_feature_names = ["Income Binary"]
Discriminative_feature_names = ["sex"]

//this structure is used from AIF360, get_distortion_adult is a data specific function on putting distortion in data, we can give an example of how to do this but eventually it differs from data to data
//epsilon, clist, dlist are based of paper but can be changed for experimentation and if they intend to follow rules from a different organization
optim_options = {
    "distortion_fun": get_distortion_adult,
    "epsilon": 0.05,
    "clist": [0.99, 1.99, 2.99],
    "dlist": [0.1, 0.05, 0],
}

opt = OptimizedPreprocessor(optim_options=optim_options)

opt.fit(df=df, D_features=D_feature_names, X_features=X_feature_names, Y_features=Y_feature_names)

df_transformed = opt.transform(
    df=df, D_features=D_feature_names, X_features=X_feature_names, Y_features=Y_feature_names
)

My implementation might look like

class OptimizedPreprocessor:
     def __init__():
      //code
     def fit():
      //code
     def transform():
      //code

please let me know your thoughts on this. Thank you!

@rakesh9177
Copy link

rakesh9177 commented Jan 29, 2024

Hello @hildeweerts , I opened a pulled request and implemented the algorithm as mentioned above. #1340

Please review and let me know

Thanks!

@romanlutz romanlutz linked a pull request Jan 30, 2024 that will close this issue
7 tasks
@romanlutz romanlutz linked a pull request Jan 30, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants