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

setParams() got an unexpected keyword argument 'lambda' #13

Open
WL1988 opened this issue Jun 17, 2022 · 2 comments
Open

setParams() got an unexpected keyword argument 'lambda' #13

WL1988 opened this issue Jun 17, 2022 · 2 comments

Comments

@WL1988
Copy link

WL1988 commented Jun 17, 2022

When I try to involve the L2 regularization parameter into the xgboostregressor by specifying the lambda_ parameter, an error occurred indicating that "TypeError: setParams() got an unexpected keyword argument 'lambda'". Could you help me to fix it? Your kind help is greatly appreciated.

@sllynn
Copy link
Owner

sllynn commented Jun 17, 2022

Try with a trailing underscore, i.e. lambda_. I think this was renamed to avoid the clash with python's lambda reserved keyword.

@WL1988
Copy link
Author

WL1988 commented Jun 18, 2022

Try with a trailing underscore, i.e. lambda_. I think this was renamed to avoid the clash with python's lambda reserved keyword.

@sllynn Thank you very much for the advice. Actually, that's what I did to use 'lambda_', i.e., the parameter I used are "model = XGBoostRegressor(objective='reg:squarederror', numRound=100, eta=0.1, maxDepth=5, alpha=0.0, lambda_=1.0)", and then the aforementioned TypeError raised. I guess it is related to the code in the 'init' function of the class 'XGBoostRegressor' in below:
if "lambda_" in kwargs:
kwargs["lambda"] = kwargs.pop("lambda_")
self.setParams(**kwargs)"
In addition, I found that the parameter used for the L2 regularization in xgboost4j_spark is 'lambda' (ref: https://xgboost.readthedocs.io/en/latest/jvm/scaladocs/xgboost4j-spark/ml/dmlc/xgboost4j/scala/spark/XGBoostRegressor.html). The rename process of replacing 'lambda_' with 'lambda' is probably to ensure the parameter consistence with the scala code. Nevertheless, I don't know what I could do to fix it. Do you have any opinions on this? Thank you very much and look forward to your reply.

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