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

Unknown type of parameter:objective, got:method #5185

Closed
seanyboi opened this issue Apr 28, 2022 · 4 comments
Closed

Unknown type of parameter:objective, got:method #5185

seanyboi opened this issue Apr 28, 2022 · 4 comments
Labels

Comments

@seanyboi
Copy link

seanyboi commented Apr 28, 2022

Description

I am trying to add a custom objective to the parameters variable of lightgbm.train(). The custom objective is a method of a class I have built so self.<class>.<method>

The error being returned is:

raise TypeError(f'Unknown type of parameter:{key}, got:{type(val).__name__}')
TypeError: Unknown type of parameter:objective, got:method

Environment info

LightGBM version or commit hash:

Command(s) you used to install LightGBM

pip3 install lightgbm

Version: 3.3.2

@jameslamb
Copy link
Collaborator

Thanks for using LightGBM!

For v3.3.2 of lightgbm, custom object functions must be passed to lgb.train() via the keyword argument fobj.

You can view the documentation for that release at https://lightgbm.readthedocs.io/en/v3.3.2/pythonapi/lightgbm.train.html.

Passing a custom objective function via params was only very recently added here in GitHub (#5052), and will be a part of the v4.0.0 release.

If this suggestion doesn't resolve your issue, please provide a reproducible example showing what you're trying, and we'd be happy to provide further help.

@seanyboi
Copy link
Author

AH that makes complete sense! Thanks for getting back to me :). I was using the 'latest' documentation. You'd assume the latest documentation would be inline with the current latest release of lightgbm. May be something to consider rolling back the latest documentation for now because it may stump a few more people!

Thanks!

@jameslamb
Copy link
Collaborator

May be something to consider rolling back the latest documentation

Thanks very much for your report and suggestion @seanyboi ! I agree with you. As the gap between the latest lightgbm release and the current state of the repo has widened, we've been seeing other reports of similar "didn't realize I was looking at latest docs" confusion.

I've opened #5342 for discussion of what we might do with LightGBM's docs site. If you'd like to add anything to that discussion, we'd welcome it!

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants