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

error when using (cloud)pickle to dump a fitted sklearn AdversarialDebiasing model #462

Open
evilantal opened this issue Sep 12, 2023 · 0 comments

Comments

@evilantal
Copy link

evilantal commented Sep 12, 2023

Also posted as a reply under a similar issue, but as this concerns the sklearn implementation (of AdversarialDebiasing) and cloudpickle combo specifically, I thought to also open a separate issue.

I tried this using the sklearn version. But when I try to pickle.dump() using cloudpickle, I get an error saying "cannot pickle 'Graph' object".
I'm not even sure why a fitted AdversarialDebiasing model would be a 'Graph' object.

cloudpickle version = 1.5.0
aif360 version = 0.5.0

EDIT: Same error when using regular pickle

In the example below X is a DataFrame that includes 'protfeat' set as index and y is a numpy array of 1/0 labels.

from aif360.sklearn.inprocessing import AdversarialDebiasing
import tensorflow.compat.v1 as tf
from aif360.datasets import StandardDataset
import pandas as pd
from cloudpickle import pickle

tf.disable_eager_execution()
sess = tf.Session()

model = AdversarialDebiasing(
    prot_attr='protfeat',
    scope_name='debiased_model',
    num_epochs=50,
    batch_size=128,
    debias=True, 
    random_state=1337,
    classifier_num_hidden_units=200
)

model.fit(X, y)

with open(os.path.join(folder.get_path(), 'test_pickle.pkl'), 'w') as f:
     pickle.dump(model, f)
@evilantal evilantal changed the title error when using cloudpickle to dump a fitted sklearn AdversarialDebiasing model error when using (cloud)pickle to dump a fitted sklearn AdversarialDebiasing model Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant