-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[python-package] Seeing unexpected behaviour in refit() #6583
Comments
Thanks for using LightGBM. You're right that given two I tried tonight with the latest development version of import lightgbm as lgb
import pandas as pd
from sklearn.datasets import make_regression
X, y = make_regression(n_samples=10_000, n_features=5, random_state=708)
df_train = pd.DataFrame(X)
bst = lgb.train(
train_set=lgb.Dataset(
data=df_train,
label=y
),
params={
"objective": "regression",
"num_iterations": 10,
"seed": 708,
"deterministic": True,
"force_row_wise": True,
"num_threads": 1
}
)
bst_new = bst.refit(
data=df_train,
label=y,
decay_rate=0.95
) Chose a sample and saw it fall into the same leaf nodes in both models' first tree: example_case = df_train.head(1)
orig_leaf_index = bst.predict(example_case, num_iteration=1, pred_leaf=True)
new_leaf_index = bst_new.predict(example_case, num_iteration=1, pred_leaf=True)
print(f"leaf indices: old={orig_leaf_index}, new={new_leaf_index}")
# leaf indices: old=[10], new=[10] But with different raw predicted values: bst.predict(example_case, num_iteration=1, raw_score=True)
# array([-12.81107821]
bst_new.predict(example_case, num_iteration=1, raw_score=True)
# array([-17.67358137]) environment info (click me)
So to investigate this further, we're going to need your help. Can you share a minimal, reproducible example? That'd be code that any of us can copy, paste, and run which reproduces the behavior you're seeing. You could use my example above as a starting point. Your report leaves out a lot of important details, including the content of the training data. You may want to review "How to create a minimal, reproducible example" in the Stack Overflow docs (link) for some tips on how to report software questions like this. If you're unable to reproduce this behavior, then could you provide the content of both models in text files? You could called |
This issue has been automatically closed because it has been awaiting a response for too long. When you have time to to work with the maintainers to resolve this issue, please post a new comment and it will be re-opened. If the issue has been locked for editing by the time you return to it, please open a new issue and reference this one. Thank you for taking the time to improve LightGBM! |
Description
Hi team,
I'm currently working on a classification task that involves incremental learning .To update the model with new data I am using refit() function.Now given an instance X=[x1,x2,x3,...,xn],and tree_index, I am seeing X falling into different leaf node for initial and updated model which is not expected as refit does not change the structure of the main model.Can somebody please help me understand why it is happening ?
Reproducible example
Updating main model
I was expecting l1 and l2 to be equal
Environment info
LightGBM version : 4.4.0
python version : 3.8.3
The text was updated successfully, but these errors were encountered: