Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LightGBM Warning: There are no meaningful features, as all feature values are constant

Tags:

lightgbm

I have tried the following simple code:

import lightgbm, pandas
params = {'objective': 'multiclass', 'num_classes': 4}
train_df = pandas.DataFrame({'f0': [0, 1, 2, 3] * 5, 'f1': [0, 0, 1] * 6 + [1, 2]}, dtype=float)
train_target = pandas.Series([0, 1, 2, 3] * 5)
train_set = lightgbm.Dataset(train_df, train_target)
model = lightgbm.train(params=params, train_set=train_set)

The output is as follows:

[LightGBM] [Warning] There are no meaningful features, as all feature values are constant.

[LightGBM] [Info] Total Bins 0

[LightGBM] [Info] Number of data: 20, number of used features: 0

[LightGBM] [Info] Start training from score -1.386294

[LightGBM] [Info] Start training from score -1.386294

[LightGBM] [Info] Start training from score -1.386294

[LightGBM] [Info] Start training from score -1.386294

[LightGBM] [Warning] Stopped training because there are no more leaves that meet the split requirements

My features are clearly not constant.

What is wrong?

I am running Python 3.5.2 on Ubuntu 16.04.

like image 835
Baruch Youssin Avatar asked Dec 10 '25 13:12

Baruch Youssin


1 Answers

I figured it out.

The problem is that the default value of min_data_in_leaf is 20, and I did not change it.

My data have only 20 rows. For this reason, LightGBM reported that it could not split it as the minimum number of samples in each split is 20.

(In fact, it did not need to split it as the solution is one tree having only one leaf. But apparently LightGBM is checking for the possibility of a split anyway.)

I increased the number of rows and LightGBM trained fine.

like image 165
Baruch Youssin Avatar answered Dec 15 '25 23:12

Baruch Youssin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!