训练数据要放到Dataset中供lgb使用,构建数据如下:
1 import lightgbm as lgb 2 import numpy as np 3 4 # 训练数据,500个样本,10个维度 5 train_data = np.random.rand(500, 10) 6 # 构建二分类数据 7 label = np.random.randint(2, size=500) 8 # 放入到dataset中 9 train = lgb.Dataset(train_data, label=label) 10 print(train)
很清晰的构建数据方式,记住这种用法
原文:https://www.cnblogs.com/demo-deng/p/9618514.html