-
Notifications
You must be signed in to change notification settings - Fork 835
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
Fairadapt inclusion in AIF360 #257
Conversation
This pull request introduces 13 alerts when merging 3ff929e into fcda24e - view on LGTM.com new alerts:
|
Hi @dplecko - can you check the LGTM report above and remove unused imports? |
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.
Looks good overall. Some changes requested. Thanks for the contribution.
please also modify README to include this method and setup.py (if needed). Can you also run sphinx and check if the documentation compiles properly?
# selectively install the missing packages | ||
names_to_install = [x for x in packnames if not robjects.packages.isinstalled(x)] | ||
if len(names_to_install) > 0: | ||
utils.install_packages(StrVector(names_to_install)) |
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.
Can you install this through modification of setup.py as a dependency of fairadapt? Best place is to do this in the extras
block and define a new key for fairadapt
. If that is not possible since these are r packages, its ok to have them here.
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.
What is this utils
package BTW? I do not see a function install_packages
in utils.py.
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.
this the utils
package from base R - I have renamed this now to avoid name clashing.
JMLR paper: https://www.jmlr.org/papers/volume21/19-966/19-966.pdf [1] | ||
Github page: https://github.com/dplecko/fairadapt [2] | ||
""" | ||
def __init__(self, |
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.
Can you also add Attributes
here. See https://github.com/Trusted-AI/AIF360/blob/master/aif360/sklearn/postprocessing/calibrated_equalized_odds.py for an example. Attributes are public attributes of the class.
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 added prot_attr_
and groups_
- those two seemed sensible.
from aif360.sklearn.utils import check_inputs, check_groups | ||
|
||
|
||
class fairadapt(BaseEstimator): |
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.
Please follow the standard docstring formatting as given in https://github.com/Trusted-AI/AIF360/blob/master/aif360/sklearn/postprocessing/calibrated_equalized_odds.py to provide references. Also add may be one more sentence about fairadapt to provide more details.
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.
The documentation should now be fixed.
# merge X_train and y_train | ||
df_train = pd.concat([X_train, y_train], axis = 1) | ||
|
||
Fairadapt_R = robjects.r( |
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.
Is it necessary to have the R object string here or can we define it down below somewhere and use it here?
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 this is the easiest solution... it could done slightly differently, but would not look much better I believe.
utils.install_packages(StrVector(names_to_install)) | ||
|
||
|
||
def fit_transform(self, X_train, y_train, X_test): |
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.
Is it necessary to pass X_train
and X_test
here? Typically we have a separate predict
or transform
function to process the test data. If this is how fairadapt works, its fine, just wanted to check.
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.
so the fairadapt
workflow does support separating the training and testing; however, when doing so, I would have to be attaching some S3 classes from R to a python object... and would make everything look more wild. I believe this is a good intermediate solution.
@@ -0,0 +1,424 @@ | |||
{ |
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.
Can you include a good preamble in the notebook that describes what fairadapt is, how it works, and also what are the steps in the notebook? The more information the better (to the extent possible). We like to keep the notebooks self-contained so that people can start their exploration here. Also, it is good to say what is unique about fairadapt compared to other preproc methods, and what it can do that other methods cannot. This will help users appreciate the novelty of the method.
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.
Similar comment applies to individual cells. Please add more information on what each cell does to the extent possible
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.
Ok, this is now expanded with much more detail.
FA = fairadapt.fairadapt(prot_attr = "sex", adj_mat = adj_mat, outcome = "annual-income") | ||
Xf_train, yf_train, Xf_test = FA.fit_transform(X_train, y_train, X_test) | ||
|
||
assert isinstance(Xf_train, pd.DataFrame) |
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.
Can you add some metric to test if fairadapt actually worked as expected?
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.
Yep, no problem, I added a check to see that the metric improved.
This pull request introduces 13 alerts when merging 6236e0f into a5dac73 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 580a5a7 into a5dac73 - view on LGTM.com new alerts:
|
Signed-off-by: Drago Plecko <www.plecko@gmail.com>
…ed-AI#267) Signed-off-by: Drago Plecko <www.plecko@gmail.com>
Update component.yaml to kfp v2 compatible. In v2, you need to declare the data type for all of the input/output arguments. Signed-off-by: Yihong Wang <yh.wang@ibm.com> Signed-off-by: Drago Plecko <www.plecko@gmail.com>
Signed-off-by: SSaishruthi <saishruthi.tn@ibm.com> Signed-off-by: Drago Plecko <www.plecko@gmail.com>
…testing; Signed-off-by: Drago Plecko <www.plecko@gmail.com>
580a5a7
to
59257dd
Compare
This pull request introduces 1 alert when merging 59257dd into a5dac73 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging f3bf417 into a5dac73 - view on LGTM.com new alerts:
|
CI workflows failing at the R interface @dplecko's analysis: Fixed several warnings, but the major thing to be solved is the following: @SSaishruthi @gdequeiroz @hoffmansc - Any thoughts on how to fix this? |
Maybe I'm missing something but do we not need to install R first in the
|
Signed-off-by: Drago Plecko <www.plecko@gmail.com>
…radapt_to_aif Signed-off-by: Drago Plecko <www.plecko@gmail.com>
277522d
to
2faa21e
Compare
This pull request introduces 1 alert when merging 2faa21e into 963df2e - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging c74d08f into 963df2e - view on LGTM.com new alerts:
|
Signed-off-by: Samuel Hoffman <hoffman.sc@gmail.com>
Signed-off-by: Samuel Hoffman <hoffman.sc@gmail.com>
cca652c
to
a75a356
Compare
This pull request introduces 1 alert when merging a75a356 into 963df2e - view on LGTM.com new alerts:
|
added 'plotting' option to igraph Signed-off-by: Samuel Hoffman <hoffman.sc@gmail.com>
Signed-off-by: Samuel Hoffman <hoffman.sc@gmail.com>
This pull request introduces 1 alert when merging b8f809f into 963df2e - view on LGTM.com new alerts:
|
Signed-off-by: Samuel Hoffman <hoffman.sc@gmail.com>
Signed-off-by: Samuel Hoffman <hoffman.sc@gmail.com>
This pull request introduces 2 alerts when merging 17183f3 into 963df2e - view on LGTM.com new alerts:
|
* Fairadapt code, demo and test * remove numpy 1.19.5 pin * deprecate python 3.6 and support 3.9 Co-authored-by: Drago Plecko <drago.plecko@stat.math.ethz.ch> Co-authored-by: nrkarthikeyan <knatesan@asu.edu> Co-authored-by: Samuel Hoffman <hoffman.sc@gmail.com>
Hi guys,
Here is a pull request adding three files we mentioned (
fairadapt.py
,test_fairadapt.py
anddemo_fairadapt.ipynb
).Most importantly: the installation of the necessary R-packages using
rpy2
is currently done from thefairadapt
class (checkfairadapt.py
line 54). I am guessing you would be looking for a better solution, i.e., that R-packages are installed together with AIF. Please just make sure, if this option is used, that we have installed:ranger
version0.13.1
fairadapt
version0.2.0
Both of the above are now available via CRAN, which should make installing them using conda much easier!
Thank you in advance for attending to this!
Best,
Drago