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

score belong to different target classes. class 0 when init_score is given else 1 #6408

Closed
i-plusplus opened this issue Apr 5, 2024 · 2 comments
Labels

Comments

@i-plusplus
Copy link

Description

I am trying to train a LGBMClassfier with init_score for rare event prediction(CTR). Close to 99% of data is 0 and 1% of data is 1.
From the documentation it is not clear for which class init_score is expected.
If I give init_score while training the model, lightgbm assumes 0 to be positive event and generate raw_score for 0.
If I don't give init_score while training the model, lightgbm assumes 1 to be positive event and generate raw_score for 1.

Reproducible example

params['metric'] = 'binary_logloss'
clf4 = lgb.LGBMClassifier(n_jobs=-1)
clf4.fit(X=df[catf + numf], y = df.clicks, sample_weight=df.weight.values, categorical_feature=catf, init_score = init_score)

Environment info

LightGBM version or commit hash: Lightgbm version: '4.3.0'

Is there any way to force Lightgbm to generate the score for 1 instead of 0.

@jmoralez
Copy link
Collaborator

Hey @i-plusplus, thanks for using LightGBM. On binary classification the init score is expected to be given for the positive class.

If I give init_score while training the model, lightgbm assumes 0 to be positive event and generate raw_score for 0.

Can you provide a small, reproducible example of that? Your example is missing the data, parameters, weights, etc.

@i-plusplus
Copy link
Author

Thanks for the response @jmoralez .

It was not the issue in lightgbm. It was a issue the way I was converting the values. Sorry about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants