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

set_sample_weight in operator_utils.py deprecated in Python 3 #1240

Closed
ramppdev opened this issue Feb 23, 2022 · 1 comment
Closed

set_sample_weight in operator_utils.py deprecated in Python 3 #1240

ramppdev opened this issue Feb 23, 2022 · 1 comment

Comments

@ramppdev
Copy link

The function set_sample_weight() in operator_utils.py is using inspect.getargspec(obj.fit) in line 112. This function seems to be deprecated in Python 3 and throws an error when trying to use the fit function fit(x, y, sample_weight=weights) with sample weights.
Pipelines that include for example XGBClassifier seem to be throwing a Value error, others do not throw an error.

A quick fix for this would be to replace line 112:
if inspect.getargspec(obj.fit).args.count("sample_weight"):
with:
if "sample_weight" in inspect.getfullargspec(obj.fit).args:

This seems to be working fine for me.

@ckastner
Copy link
Contributor

That works for me, too.

There's another instance of getargspec in tests/tpot_test.py, a simple replacement with getfullargspec is sufficient there, too.

@Rampdev, would you like to file a PR? Otherwise I'll do it.

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

2 participants