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

simple repro for lightgbm.basic.LightGBMError: Check failed: (best_split_info.left_count) > (0) #4739

Open
Tracked by #5153
arnocandel opened this issue Oct 28, 2021 · 5 comments

Comments

@arnocandel
Copy link

arnocandel commented Oct 28, 2021

Description

3.3.1
lightgbm.basic.LightGBMError: Check failed: (best_split_info.left_count) > (0)

Reproducible example

import numpy as np

import lightgbm as lgb

print(lgb.__version__)
from lightgbm.sklearn import LGBMRegressor

y = np.array([0.53144988, 0.16774223, 0.76881392, 0.92817055, 0.60949366,
              0.15018349, 0.4896267, 0.37734495, 0.84860141, 0.91109723,
              0.38384872, 0.3154959, 0.56839415, 0.18781804, 0.12584154,
              0.68759581, 0.79960672, 0.57353657, 0.97322998, 0.63405438,
              0.88842172, 0.49541476, 0.35161653, 0.71423037, 0.50392912,
              0.22563761, 0.24497444, 0.7928007, 0.49517241, 0.91509367,
              0.94537183, 0.53323223, 0.25249259, 0.72086206, 0.36743876,
              0.49864844, 0.22657505, 0.35356565, 0.65085179, 0.3129329,
              0.76873545, 0.7818371, 0.85240948, 0.94990574, 0.10732291,
              0.91072536, 0.33605516, 0.82638043, 0.89810064, 0.0427153,
              0.195795, 0.29450132, 0.62699988, 0.08622311, 0.14294502,
              0.51582652, 0.68934133, 0.85662581, 0.64736168, 0.58161868,
              0.71111596, 0.25241686, 0.90015968, 0.44229369, 0.02052082,
              0.95966101, 0.65222542])
X = np.array([[3.18185419e-01, 2.89023757e-01, 5.77969849e-01, 9.89430726e-01,
               9.65823591e-01, 4.35866356e-01, 7.08020449e-01, 6.19103551e-01,
               6.38400987e-02, 3.53105962e-02],
              [5.42394221e-01, 1.68133736e-01, 6.61103487e-01, 9.33694065e-01,
               3.17397714e-01, 1.13112494e-01, 5.09606361e-01, 3.44259858e-01,
               4.73232955e-01, 4.14570451e-01],
              [1.42603919e-01, 1.91800538e-02, 3.36583555e-01, 2.94364035e-01,
               8.37472022e-01, 8.58708993e-02, 9.73887622e-01, 3.12646963e-02,
               4.43220079e-01, 3.36796641e-01],
              [8.90651584e-01, 5.35332203e-01, 8.81459594e-01, 1.75708532e-01,
               4.75718975e-01, 2.11277634e-01, 9.45999622e-01, 1.33894756e-01,
               4.57212269e-01, 6.26072288e-01],
              [7.79401243e-01, 9.56866443e-01, 1.70467928e-01, 1.41045675e-01,
               6.69940189e-02, 3.38076502e-01, 6.88320279e-01, 6.82391763e-01,
               8.74678671e-01, 3.55845541e-01],
              [5.81818402e-01, 4.34412897e-01, 6.64072335e-01, 4.12887394e-01,
               5.41235030e-01, 3.26000094e-01, 1.95810333e-01, 5.87836087e-01,
               4.06061262e-01, 1.63262546e-01],
              [8.17808449e-01, 9.97163057e-01, 6.96638763e-01, 9.25436556e-01,
               9.60793436e-01, 1.17184043e-01, 4.17131901e-01, 3.22245061e-01,
               4.30662215e-01, 5.39673746e-01],
              [2.05167741e-01, 2.63019413e-01, 8.83500576e-01, 6.35816809e-03,
               5.55981696e-01, 2.88187623e-01, 3.85903746e-01, 8.70030344e-01,
               5.50931394e-01, 6.03763044e-01],
              [4.53382730e-02, 7.53461540e-01, 7.12815583e-01, 6.62131011e-01,
               7.86399424e-01, 2.09391356e-01, 7.92746365e-01, 6.09459579e-01,
               5.99589534e-02, 9.49483573e-01],
              [5.86662054e-01, 7.05183983e-01, 6.66065812e-01, 3.35565925e-01,
               5.12406886e-01, 9.66254354e-01, 8.24884236e-01, 4.01079774e-01,
               2.41382405e-01, 2.31151462e-01],
              [3.58709067e-01, 6.02830112e-01, 4.12370235e-01, 8.04818392e-01,
               7.58394659e-01, 7.76848930e-04, 3.96741301e-01, 1.31194887e-03,
               8.39560151e-01, 9.24953699e-01],
              [9.54115510e-01, 7.83517957e-01, 6.44224107e-01, 9.74720478e-01,
               6.09119385e-02, 9.64327335e-01, 7.13578641e-01, 1.33071810e-01,
               1.35911852e-01, 2.40373567e-01],
              [4.66838598e-01, 1.21149153e-01, 4.00868095e-02, 2.53724694e-01,
               5.94093204e-01, 4.03500825e-01, 2.37935066e-01, 9.03411210e-02,
               5.54361224e-01, 3.76765244e-02],
              [9.51037347e-01, 6.85941994e-01, 5.70678294e-01, 2.25899532e-01,
               9.09298480e-01, 2.14991480e-01, 3.84037346e-01, 9.20931995e-01,
               9.65196609e-01, 7.32102334e-01],
              [8.91737282e-01, 3.88502002e-01, 8.20056081e-01, 9.54227507e-01,
               7.59446144e-01, 4.37388092e-01, 1.88927636e-01, 1.55541092e-01,
               1.61684141e-01, 6.48446798e-01],
              [5.03441751e-01, 1.99590661e-02, 3.64342809e-01, 6.76882923e-01,
               1.59425780e-01, 5.06470799e-01, 2.76417106e-01, 2.50236064e-01,
               6.98554099e-01, 6.80231988e-01],
              [9.91782129e-01, 4.01137888e-01, 9.94243443e-01, 6.28425002e-01,
               3.93217385e-01, 3.66914004e-01, 5.52262247e-01, 8.22997332e-01,
               8.02758992e-01, 2.48500288e-01],
              [1.28971189e-01, 7.91224837e-01, 6.56189620e-01, 4.34788704e-01,
               7.86576748e-01, 5.58793902e-01, 8.13735008e-01, 4.96907681e-01,
               6.58830225e-01, 9.24300849e-01],
              [1.73971161e-01, 4.73667346e-02, 1.41531944e-01, 9.34568942e-01,
               6.59916624e-02, 7.56337881e-01, 7.35831082e-01, 4.50509995e-01,
               6.33384645e-01, 6.38507068e-01],
              [7.03876495e-01, 8.52190554e-01, 9.98002216e-02, 5.30180812e-01,
               1.68142244e-01, 6.91841066e-01, 8.77876163e-01, 7.10170805e-01,
               1.61363304e-01, 5.82616568e-01],
              [3.24936271e-01, 2.51661092e-01, 3.82364511e-01, 9.62205350e-01,
               9.76874113e-01, 2.11986020e-01, 2.65532076e-01, 5.21539927e-01,
               6.57329440e-01, 1.80945143e-01],
              [7.39542127e-01, 8.79172266e-01, 2.45922700e-01, 1.78757682e-01,
               4.59933043e-01, 7.30295300e-01, 7.41509974e-01, 3.82421404e-01,
               5.73267162e-01, 9.37056363e-01],
              [3.26930970e-01, 9.06182528e-01, 9.31589901e-01, 7.18757391e-01,
               1.38016984e-01, 8.63216281e-01, 7.35545635e-01, 4.25509483e-01,
               3.81862521e-01, 7.71566749e-01],
              [6.08468950e-01, 6.07269466e-01, 5.37800252e-01, 3.60420018e-01,
               6.05153143e-01, 3.01103026e-01, 5.01489975e-02, 9.80627090e-02,
               8.52045178e-01, 4.76603448e-01],
              [3.74868572e-01, 1.09831981e-01, 9.82353151e-01, 5.63509107e-01,
               9.61682498e-01, 2.24955752e-01, 7.60268509e-01, 8.71614873e-01,
               4.60037082e-01, 1.36498474e-02],
              [2.18688518e-01, 7.66238391e-01, 4.01495129e-01, 3.03250819e-01,
               3.72382611e-01, 6.24149561e-01, 3.22301015e-02, 5.17376661e-01,
               4.09348458e-01, 9.96234119e-01],
              [1.77500807e-02, 5.06687164e-01, 9.81505334e-01, 9.70056236e-01,
               3.63963604e-01, 8.62461999e-02, 8.76301169e-01, 5.26666999e-01,
               1.38859525e-01, 3.10335785e-01],
              [7.75099039e-01, 3.41126382e-01, 9.17287529e-01, 1.48236200e-01,
               4.60816361e-02, 8.78562391e-01, 4.58367527e-01, 2.46618260e-02,
               6.61275625e-01, 3.03886663e-02],
              [5.54207087e-01, 8.91311109e-01, 8.87472689e-01, 1.54440075e-01,
               3.10997277e-01, 9.44535136e-01, 4.22006585e-02, 5.36339343e-01,
               7.47466385e-01, 5.09494781e-01],
              [8.63127708e-01, 7.73489356e-01, 7.95619667e-01, 5.65422833e-01,
               4.60403450e-02, 9.36309457e-01, 3.93576413e-01, 8.37611139e-01,
               1.20686911e-01, 1.41933560e-01],
              [5.46937168e-01, 1.70781657e-01, 7.37233222e-01, 6.36630654e-01,
               3.26322526e-01, 4.31406885e-01, 3.36527377e-01, 8.67089510e-01,
               5.60174644e-01, 7.31700733e-02],
              [7.74994314e-01, 4.62573111e-01, 5.73544085e-01, 3.78483057e-01,
               6.66345835e-01, 1.28712848e-01, 9.65926588e-01, 9.71738935e-01,
               2.48684183e-01, 5.87164275e-02],
              [4.16893423e-01, 2.66163111e-01, 9.86757100e-01, 5.94894171e-01,
               4.84992146e-01, 5.26426911e-01, 6.79219425e-01, 3.03919911e-01,
               2.69816697e-01, 7.00096011e-01],
              [3.12332809e-01, 4.95140314e-01, 9.46641743e-01, 5.65941297e-02,
               1.97475180e-01, 4.06387538e-01, 3.87612045e-01, 6.59010410e-01,
               5.90242863e-01, 8.47919881e-01],
              [5.49513936e-01, 4.94294167e-01, 6.12262189e-01, 6.61391973e-01,
               3.87216538e-01, 8.45645070e-01, 8.54860902e-01, 3.00478861e-02,
               8.61017525e-01, 5.69399893e-01],
              [2.08273102e-02, 8.56991470e-01, 8.70342135e-01, 4.94938195e-01,
               2.32386574e-01, 7.19348252e-01, 5.65339625e-01, 4.17521983e-01,
               7.07941353e-01, 6.88744783e-01],
              [7.04441547e-01, 1.33060589e-01, 4.51710790e-01, 4.87689584e-01,
               6.77359879e-01, 3.87157321e-01, 9.78422761e-01, 8.32681954e-01,
               7.52077460e-01, 3.96014117e-02],
              [7.88508475e-01, 7.72777200e-01, 7.70213306e-01, 5.49225688e-01,
               3.87479626e-02, 2.52078533e-01, 2.08272755e-01, 6.54579937e-01,
               4.68169525e-02, 9.82616544e-01],
              [7.67286777e-01, 4.50217068e-01, 8.64583731e-01, 4.83039379e-01,
               4.03288335e-01, 1.39519110e-01, 1.49392352e-01, 9.27831769e-01,
               8.88006091e-01, 3.09861183e-01],
              [3.09537441e-01, 3.14179182e-01, 5.94607770e-01, 2.09987804e-01,
               2.86082804e-01, 6.59840643e-01, 6.08347058e-01, 7.83432186e-01,
               3.68370444e-01, 1.27868533e-01],
              [6.27912521e-01, 1.66130409e-01, 2.72896916e-01, 2.09247298e-03,
               6.24459505e-01, 4.66325611e-01, 9.54815924e-01, 4.24415499e-01,
               4.17629659e-01, 1.31334037e-01],
              [5.44481874e-01, 4.80354816e-01, 1.47305414e-01, 8.11797738e-01,
               4.29502904e-01, 5.83623648e-01, 9.59380805e-01, 3.36371094e-01,
               4.44141895e-01, 4.44416553e-01],
              [4.53134596e-01, 7.70575285e-01, 6.93166256e-01, 6.83151841e-01,
               9.98141944e-01, 2.31279731e-01, 4.22518551e-01, 2.26850212e-01,
               3.29058528e-01, 7.01860368e-01],
              [8.31144035e-01, 7.05150902e-01, 4.88297194e-01, 1.10751212e-01,
               2.25393310e-01, 8.88443410e-01, 3.48545104e-01, 7.55236924e-01,
               4.17347670e-01, 4.41502370e-02],
              [4.71336812e-01, 1.27031162e-01, 3.80690604e-01, 5.89103699e-01,
               9.51822460e-01, 4.47219580e-01, 8.45367074e-01, 9.67241883e-01,
               8.51189256e-01, 2.08620846e-01],
              [2.72592187e-01, 1.57283619e-01, 8.92082810e-01, 1.39352113e-01,
               5.55329680e-01, 6.97059393e-01, 9.59534407e-01, 7.70655394e-01,
               5.82415998e-01, 8.12091351e-01],
              [6.07162654e-01, 4.58761096e-01, 9.97879267e-01, 6.17132008e-01,
               3.45982522e-01, 5.97284973e-01, 7.59921074e-01, 3.53568405e-01,
               1.11613289e-01, 7.26114094e-01],
              [1.68245345e-01, 4.99758661e-01, 8.66977453e-01, 4.78529662e-01,
               6.20375633e-01, 9.24068630e-01, 7.53879011e-01, 4.61294264e-01,
               8.71223509e-01, 9.36193019e-02],
              [9.66888294e-02, 2.99453318e-01, 3.38510089e-02, 5.62017381e-01,
               9.55588102e-01, 1.48495078e-01, 3.15734178e-01, 3.50952536e-01,
               4.16247427e-01, 7.29162812e-01],
              [1.90073535e-01, 3.57726961e-01, 4.67596143e-01, 8.55837464e-01,
               8.90357435e-01, 3.82368535e-01, 2.95750201e-01, 1.51440397e-01,
               8.03694010e-01, 8.61748934e-01],
              [3.04727614e-01, 5.09294450e-01, 8.87491047e-01, 4.44049329e-01,
               1.60664797e-01, np.nan, 1.22876525e-01, 6.34693384e-01,
               8.89074385e-01, 4.94441360e-01],
              [1.64173380e-01, 1.97973341e-01, 7.76408553e-01, 6.44786656e-01,
               7.44671762e-01, 3.71712744e-01, 9.24405515e-01, 4.98660028e-01,
               6.78113401e-01, 4.34669375e-01],
              [4.39537972e-01, 5.00336945e-01, 6.08679950e-01, 7.56482482e-02,
               7.03113675e-01, 4.67869431e-01, 9.25293803e-01, 2.63714314e-01,
               3.04002613e-01, 7.89068282e-01],
              [2.96324134e-01, 3.47903281e-01, 3.37706625e-01, 1.09468468e-01,
               6.29165411e-01, 6.60714626e-01, 5.70518255e-01, 6.07967854e-01,
               6.33475557e-02, 5.39262772e-01],
              [9.22458708e-01, 9.76127207e-01, 3.38783339e-02, 3.63025814e-01,
               3.93288672e-01, 9.07869995e-01, 7.84373879e-01, 2.22829297e-01,
               2.60821939e-01, 8.17542989e-03],
              [1.27766475e-01, 8.63162041e-01, 6.66272402e-01, 8.42970073e-01,
               3.46390277e-01, 2.33778700e-01, 1.70735702e-01, 5.24761118e-02,
               5.45668840e-01, 5.89304566e-02],
              [1.77003309e-01, 4.66098219e-01, 4.28403139e-01, 4.66060191e-01,
               6.55651152e-01, 7.68752992e-01, 3.68951783e-02, 9.97475982e-01,
               7.27926731e-01, 7.04242051e-01],
              [6.09888256e-01, 7.18641579e-01, 7.58494675e-01, 7.96449006e-01,
               1.01494558e-01, 6.82912350e-01, 9.45746005e-01, 6.30482554e-01,
               6.60302997e-01, 4.65696126e-01],
              [6.15089297e-01, 5.25112629e-01, 9.01882291e-01, 9.91563797e-01,
               2.68366426e-01, 7.52449930e-01, 9.60335791e-01, 1.76753268e-01,
               9.07719731e-01, 2.64494836e-01],
              [8.71554315e-01, 2.61243165e-01, 7.97336459e-01, 9.98746693e-01,
               1.73271328e-01, 6.62790000e-01, 8.16630185e-01, 7.73106039e-01,
               4.47031230e-01, 7.25655496e-01],
              [9.18140948e-01, 9.85920906e-01, 1.67565029e-02, 2.37738967e-01,
               9.05849695e-01, 3.44968408e-01, 1.81968398e-02, 6.04619801e-01,
               3.36690992e-01, 5.86442769e-01],
              [2.68731356e-01, 1.97539657e-01, 7.72563934e-01, 1.56265963e-02,
               7.01116264e-01, 9.46206748e-01, 7.42765069e-01, 8.55278194e-01,
               8.94469380e-01, 1.95468709e-01],
              [8.26039016e-01, 9.84082699e-01, 3.31964970e-01, 7.87075937e-01,
               1.34150311e-01, 2.92552173e-01, 4.68275577e-01, 5.16839385e-01,
               3.03706437e-01, 9.00437415e-01],
              [9.76348102e-01, 2.09061339e-01, 5.76777458e-01, 5.56127310e-01,
               1.40824780e-01, 5.04489720e-01, 5.06504953e-01, 9.04679418e-01,
               6.19154647e-02, 1.84684664e-01],
              [4.73469347e-01, 3.74517381e-01, 4.02617574e-01, 8.53760898e-01,
               4.29291695e-01, 3.71721350e-02, 4.63113755e-01, 9.55779314e-01,
               7.03190714e-02, 2.41078913e-01],
              [1.82235748e-01, 1.87728569e-01, 3.16519350e-01, 8.34673166e-01,
               9.61117685e-01, 6.49957597e-01, 7.07406878e-01, 9.87051785e-01,
               1.90370724e-01, 1.64440617e-01],
              [2.89555103e-01, 9.45270181e-01, 2.55926251e-01, 5.06947339e-01,
               3.71064276e-01, 8.60436022e-01, 6.52961075e-01, 9.91739154e-01,
               9.44839418e-01, 9.90690231e-01]], dtype=np.float32)

sample_weight = np.array(
    [2, 1, 1, 1, 0, 1, 2, 2, 1, 2, 1, 1, 2, 1, 10, 2, 1,
     10, 10, 2, 0, 2, 1, 10, 1, 2, 1, 2, 2, 10, 10, 10, 10, 1, 0,
     10, 10, 1, 1, 10, 10, 0, 0, 10, 10, 0, 0, 1, 10, 10,
     10, 2, 10, 1, 10, 1, 2, 1, 10, 0, 1, 2, 0, 1, 10, 10, 0])

model = LGBMRegressor(
    deterministic=True,
    objective='mape',
    subsample=0.7,
    subsample_freq=1
)

model.fit(X=X, y=y, sample_weight=sample_weight)

Environment info

Ubuntu 20.04 x86

LightGBM version or commit hash: 3.3.1

Command(s) you used to install LightGBM

pip install lightgbm-3.3.1-py3-none-manylinux1_x86_64.whl 

Discovered by H2O Driverless AI testing

Additional Comments

@arnocandel
Copy link
Author

#3679

@guolinke
Copy link
Collaborator

guolinke commented Mar 3, 2022

I think the zero sample weight may cause the problem.
@shiyu1994 did you try to fix this before?

@shiyu1994
Copy link
Collaborator

I'm not sure whether zero sample weight is the root cause for this example. But we've seen others report the same bug without zero sample weight, for example
#3679 (comment).
I'm investigating this.

@andins
Copy link

andins commented Mar 24, 2022

I run into the same issue for a project I'm working on.
When I tried the about reproducible example it also fails with the same error, however if I change the objective from 'mape' to 'rmse' it runs smoothly. Hope this may help debug it.

@edwardcjohnson
Copy link

i get the same error with v4.1.0 with 'boosting_type': 'dart'. if i use 'boosting_type': 'gbdt', then it runs smoothly.
Hope this may help debug it.

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

No branches or pull requests

5 participants