-
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
Monotonicity of 0's different result than no monotonicity set #4936
Comments
Thanks for this write-up and reproducible example! I ran this code tonight and can confirm I got the same results you reported. Experimenting with this, I found that any of the following individual changes result in the predictions being identical:
test code (click me)import lightgbm as lgb
import pandas as pd
import numpy as np
data_url = "https://github.com/microsoft/LightGBM/files/7831557/df.csv"
df = pd.read_csv(data_url)
y = df['y']
X = df.drop('y', axis=1)
model_class = lgb.sklearn.LGBMRegressor
params = {
'min_child_samples': 1,
'subsample_freq': 1,
'random_state': 1234,
'deterministic': True,
'monotone_constraints': [0] * X.shape[1],
}
model = model_class(**params)
model.fit(X, y)
preds1 = model.predict(X)
print(preds1[0:20])
params.pop('monotone_constraints', None)
model = model_class(**params)
model.fit(X, y)
preds2 = model.predict(X)
print(preds2[0:20])
assert np.allclose(preds1, preds2) This definitely seems like a bug, but it seems a bit more specific than "passing all 0s for I think it looks like:
|
I don't find the same result as you. Adding bagging_seed doesn't help:
gives
Also note that In making the MRE I originally had the bagging_seed set to 1236 and determined it didn't matter/effect the outcome, so that is why I removed it. But it is not relevant, since you can keep it if you wish and still the same problem I described happens. And again, just because bagging causes it doesn't mean it is the only way it can be caused. That is just a result of my MRE reduction to one specific case that happen to show it. |
What version of |
I can try on master. But are you aware of a specific fix? |
No, I didn't know this issue existed until this bug report. Just trying to help narrow it down further. |
Same result on latest from pypi on different machine after only installing:
and the same script using bagging_seed set:
gives:
version:
|
3.3.2 is a special release that doesn't include most of the changes currently on To install from latest git clone --recursive https://github.com/microsoft/LightGBM.git
cd python-package
python setup.py install |
Same result:
|
Ah yeah you're right, I just tried again and got the same result you did. I crossed out the suggestion about |
df.csv
This is MRE, but more complicated examples also do this and lead to arbitrarily different results for predictions.
The text was updated successfully, but these errors were encountered: