LightGBM 警告:没有有意义的特征,因为所有特征值都是常量
LightGBM Warning: There are no meaningful features, as all feature values are constant
我试过下面的简单代码:
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)
输出结果如下:
[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
我的特征显然不是一成不变的。
怎么了?
我 运行 Python 3.5.2 Ubuntu 16.04.
我想通了。
问题是min_data_in_leaf
的默认值是20,我没改。
我的数据只有 20 行。为此,LightGBM 报告无法拆分,因为每次拆分的最小样本数为 20。
(事实上,它不需要分裂它,因为解决方案是一棵只有一片叶子的树。但显然 LightGBM 正在检查分裂的可能性。)
我增加了行数,LightGBM 训练得很好。
我试过下面的简单代码:
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)
输出结果如下:
[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
我的特征显然不是一成不变的。
怎么了?
我 运行 Python 3.5.2 Ubuntu 16.04.
我想通了。
问题是min_data_in_leaf
的默认值是20,我没改。
我的数据只有 20 行。为此,LightGBM 报告无法拆分,因为每次拆分的最小样本数为 20。
(事实上,它不需要分裂它,因为解决方案是一棵只有一片叶子的树。但显然 LightGBM 正在检查分裂的可能性。)
我增加了行数,LightGBM 训练得很好。