【发布时间】:2016-03-26 18:11:12
【问题描述】:
我不确定xgboost 的许多不错的功能是否可以按我需要的方式组合(?),但我想要做的是在多类因变量。
我知道xgboost 可以做任何一件事情:
-
Random Forest 通过调整
xgboost参数:
bst <- xgboost(data = train$data, label = train$label, max.depth = 4, num_parallel_tree = 1000, subsample = 0.5, colsample_bytree =0.5, nround = 1, objective = "binary:logistic")
bst <- xgboost(data = sparse_matrix, label = output_vector, max.depth = 4,
eta = 1, nthread = 2, nround = 10,objective = "binary:logistic")
-
Multinomial(多类)因变量模型通过
multi:softmax或multi:softprob
xgboost(data = data, label = multinomial_vector, max.depth = 4,
eta = 1, nthread = 2, nround = 10,objective = "multi:softmax")
但是,当我尝试一次完成所有这些操作时,遇到了一个关于不合格 length 的错误:
sparse_matrix <- sparse.model.matrix(TripType~.-1, data = train)
Y <- train$TripType
bst <- xgboost(data = sparse_matrix, label = Y, max.depth = 4, num_parallel_tree = 100, subsample = 0.5, colsample_bytree =0.5, nround = 1, objective = "multi:softmax")
Error in xgb.setinfo(dmat, names(p), p[[1]]) :
The length of labels must equal to the number of rows in the input data
length(Y)
[1] 647054
length(sparse_matrix)
[1] 66210988200
nrow(sparse_matrix)
[1] 642925
我得到的长度错误是将我的单个多类依赖向量的长度(我们称之为 n)与稀疏矩阵索引的长度进行比较,我认为这是 j * n 表示 j 个预测变量。
这里的具体用例是 Kaggle.com Walmart 竞赛(数据是公开的,但默认情况下非常大——大约 650,000 行和数千个候选特征)。我一直在通过 H2O 在其上运行多项式 RF 模型,但听起来很多其他人一直在使用 xgboost,所以我想知道这是否可能。
如果不可能,那么我想知道是否可以/应该分别估计因变量的每个级别并尝试得出结果?
【问题讨论】:
标签: r sparse-matrix random-forest xgboost