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

can't use ranking with label value >= 31 #1090

Closed
alexeib opened this issue Dec 1, 2017 · 10 comments
Closed

can't use ranking with label value >= 31 #1090

alexeib opened this issue Dec 1, 2017 · 10 comments

Comments

@alexeib
Copy link

alexeib commented Dec 1, 2017

gbm = lgb.LGBMRanker(n_estimators=10)
feats = []
labels = []
for i in range(50):
    feats.append([random.random(), random.random()])
    labels.append(0 if random.random() > 0.5 else 31)
gbm.fit(X=feats, y=labels, group=[50])

will get an error:
lightgbm.basic.LightGBMError: b'label (31) excel the max range 31'

using any value less than 31 in labels works fine. using any value >= 31 will always produce the error above, with the "max range" being the max value of the label (but it will always say (31) for label value)

@guolinke
Copy link
Collaborator

guolinke commented Dec 1, 2017

you should set “label_gain”

@alexeib
Copy link
Author

alexeib commented Dec 1, 2017

that doesnt seem to be one of the parameters either on LGBMRanker or on the fit() function in sklearn interface?

also, how come it works for labels with values < 31, and why is the message so strange? i looked in the code and can't figure out how it can even enter into the branch with that statement, given the values it is printing out

setting label_gain to any value does change the message, given the code above, it is always:
b'label (1) excel the max range 50
for various values of label_gain

edit: ok it works if i set it to an array that is the size of my maximum label size. thanks for help and would be nice to document!

@alexeib alexeib closed this as completed Dec 1, 2017
@alexeib
Copy link
Author

alexeib commented Dec 1, 2017

closing although i think error message, documentation and sklearn interface could use a touch up :) thanks again

@guolinke
Copy link
Collaborator

guolinke commented Dec 1, 2017

@StrikerRUS can you help to add this to the document ?

@StrikerRUS
Copy link
Collaborator

@guolinke Sure, will do it today.

@Edmondguo
Copy link

how to change label_gain in Python API? I can't find it whether in LGBMRanker or in the fit() function.

@StrikerRUS
Copy link
Collaborator

@Edmondguo Use **kwargs for any parameter which isn't presented in arguments.

@mayritaspring
Copy link

how to change label_gain in Python API? I can't find it whether in LGBMRanker or in the fit() function.

hi Edmondguo, do you figure out this problem? because I also cannot find it.....thank you so much

@cmcai0104
Copy link

cmcai0104 commented Jun 24, 2019

Hi, @alexeib What's "the size of my maximum label size" means?

if my label is: 1,2,3,...,100,1,2,3,...,200,1,2,3,...,1000, how to set my “label_gain”?

@guolinke
Copy link
Collaborator

@cmcai0104
just make sure label_gain[label_value] is valid.

@lock lock bot locked as resolved and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants