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 "Mechanisms for Fair Classification" by Zafar et al. #1043
base: main
Are you sure you want to change the base?
ENH add mitigation algorithm "Mechanisms for Fair Classification" by Zafar et al. #1043
Conversation
Most of this code is copied from the sklearn LogisticRegression
Easy version for now, see comments in code
Returning renamed sensitive features, and not dropping a column in case of binary sensitive feature.
Some minor changes done by me, e.g. intercept on line 705. Still need to figure out how to do this in the right way
Not happy with this way of doing it, probably need to do it more like sklearn and less like the code in the paper.
Now implemented as in sklearn, instead of how the paper does it
…ensoostenbach/fairlearn into mechanisms_fair_classification
@adrinjalali Here is an overview of lines in
There are also some warnings that I am not sure what to do with, e.g. the warning on line 43. For that warning, should I implement a test that specifically tests for the right solver, or does that warning mean something else? I realize this is quite a lot, perhaps we could chat sometime so I could get a better grasp of how codecov works and how I should tackle these warnings :). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think codecov is complaining because the tests are failing (on an import) and therefore the coverage file is not actually covering the new code at all. I'll look into it.
So there's been some re-work of the loss methods in scikit-learn=1.1, and your import from Check this PR for the changes: https://github.com/scikit-learn/scikit-learn/pull/21808/files To fix this, you probably need a function in |
@adrinjalali I've moded all content in Thanks for notifying about the change in sklearn! I was not aware of this at all. I've pushed a fix for this, however I'm not sure if it should be done like this since this is a first for me. |
…ensoostenbach/fairlearn into mechanisms_fair_classification
Hi @rensoostenbach - is it clear for you what remains to be done to get this PR merged? Let us know if you still have any questions :) |
@hildeweerts I believe that I should perhaps write some more tests on the lines that codecov is failing on, but I am unsure for which parts of the code I should do that. On one hand, I feel like I have written some tests for parts of the code that codecov still wants me to write a test on, and I'm not sure if I should write tests for parts of the code that originate from sklearn on the other hand. Also, I think this PR is still blocked by #1093, as per this comment. |
I noticed that when Hilde committed 5c32555, Codecov wasn't complaining anymore, but now it is again. I am still not really sure how to fix that in the best way. Also, the PR gate is giving a weird error for flake8, but locally I only get the following flake8 errors:
So it seems that the docs are still not recognizing attributes properly. |
This PR will solve #1025 and implements the Logistric Regression from the paper Fairness Constraints: Mechanisms for Fair Classification by Zafar et al.
Assumptions made so far:
sklearn.linear_model.LogisticRegression
. I have also seen the discussion in Proposal: Port EqualOpportunityClassifier and DemographicParityClassifier #466, and have taken it into account regarding the naming.SLSQP
solver. All solvers implemented in sklearn do not work with constraints, and 'SLSQP' does while also being available in theoptimize.minimize
function, making it an easy choice.Progress:
Once all this is finished, I can look to extend this to a new GLM framework in sklearn, as mentioned here.