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

旧时模样 提交于 2021-01-29 10:40:28

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/58708090/lightgbm-warning-there-are-no-meaningful-features-as-all-feature-values-are-co

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!