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

quickstart.ipynb indicates we can train bnn and fnn without other parameters but I get error: UnboundLocalError: local variable 'labels' referenced before assignment #263

Open
littlebeanbean7 opened this issue Nov 11, 2024 · 6 comments

Comments

@littlebeanbean7
Copy link

https://github.com/fani-lab/OpeNTF/blob/main/quickstart.ipynb shows that we can run

python main.py -data ../data/raw/dblp/toy.dblp.v12.json -domain dblp -model bnn
python main.py -data ../data/raw/dblp/toy.dblp.v12.json -domain dblp -model fnn

but both of the models will get error message below. I found only if I add "-fairness det_greedy -attribute popularity", this error would disappear -- this contradicts with the quickstart.ipynb.

Traceback (most recent call last):
File "main.py", line 210, in
run(data_list=args.data_list,
File "main.py", line 167, in run
m_obj.run(splits, vecs_, indexes, f'{output_path}', settings['model']['baseline'][baseline_name], settings['model']['cmd'], settings['fair'], merge_skills=False)
File "/mnt/data/lingling/OpeNTF/src/mdl/ntf.py", line 141, in run
if 'fair' in cmd: self.fair(output, vecs, splits, fair_settings)
File "/mnt/data/lingling/OpeNTF/src/mdl/ntf.py", line 88, in fair
for fpred, output in pairs: adila.Reranking.run(fpred=fpred,
File "/mnt/data/lingling/OpeNTF/src/Adila/src/main.py", line 350, in run
stats, labels, ratios = Reranking.get_stats(teamsvecs, coefficient=1, output=output, eq_op=eq_op, att=att)
File "/mnt/data/lingling/OpeNTF/src/Adila/src/main.py", line 98, in get_stats
return stats, labels, None
UnboundLocalError: local variable 'labels' referenced before assignment

@littlebeanbean7 littlebeanbean7 changed the title quickstart.ipynb indictes we can train bnn and fnn without other parameters but I get error: UnboundLocalError: local variable 'labels' referenced before assignment quickstart.ipynb indicates we can train bnn and fnn without other parameters but I get error: UnboundLocalError: local variable 'labels' referenced before assignment Nov 11, 2024
@hosseinfani
Copy link
Member

@jamil2388 @rezaBarzgar @thangk can any of you look into this and support @littlebeanbean7 . thank you.

@jamil2388
Copy link
Member

Hi @hosseinfani,
as far as I can assume, the quickstart.ipynb has become quite outdated here. The error is seemed to be occurring for calling up the main.py from Adila module at some point, which in default cases, should not happen.

Instead of using quickstart.ipynb, I guess the OpeNTF.ipynb is a more suitable started now, as it was updated very recently (5 months ago), compared to the quickstart.ipynb (2 years+ ago). Let me know the suggestions based on your experience please. Thanks!

@littlebeanbean7
Copy link
Author

Hi @jamil2388 thank you for your reply! I looked into OpeNTF.ipynb, it seems contradicts with itself: it says -fairness and -attribute are "optional arguments", however, if I remove the 2 parameters, I get error: UnboundLocalError: local variable 'labels' referenced before assignment.

@jamil2388
Copy link
Member

Hi @littlebeanbean7, we are trying to find out the origin of the problem. We will reach back to you after resolution. Thank you for your patience!

@hosseinfani
Copy link
Member

@jamil2388 thanks for the hint.

@Hamedloghmani
Ideally, when the user puts fair = None in the setting.py here :

'fair': {'np_ratio': None,

it should not load any package for the Adila. However, due to this line, it does! https://github.com/fani-lab/OpeNTF/blob/7905ad34028cdec5db661a3bf8e45e158fd6e816/src/main.py#L209C5-L209C118

@Hamedloghmani
Copy link
Member

Hi @hosseinfani ,
Thank you for the info. I'm working on the changes, will push soon.
Also I'll log and explain the changes in the issues.

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

4 participants