r - XGBoost 仅使用部分功能
问题描述
我在 R 中实现了 XGBoost。在我的数据中,我有 54 个特征和 7000 个样本,但是在训练之后,我得到的模型只有 13 个特征。我想知道有人知道为什么只使用了一小部分功能吗?感谢
以下是我使用的参数:
trainm <- sparse.model.matrix(number ~ .-1, data = train)
train_label <- train[,"number"]
train_matrix <- xgb.DMatrix(data = as.matrix(trainm), label = train_label)
testm <- sparse.model.matrix(number~.-1, data = test)
test_label <- test[,"number"]
test_matrix <- xgb.DMatrix(data = as.matrix(testm), label = test_label)
# Parameters
xgb_params <- list("eval_metric" = "mae")
watchlist <- list(train = train_matrix, test = test_matrix)
bst_model <- xgb.train(data = train_matrix,
params = xgb_params,
nrounds = 100, ## iteration
watchlist = watchlist,
eta = 0.005, ## learning rate
max.depth = 10, ## tree depth
gamma = 0.2, ## artificial bias (avoid overfitting)
subsample = 0.8, ## random sampling
colsample_bytree = 0.8, ## subsample columns when constructing each tree.
num_feature = 54)
解决方案
推荐阅读
- driver - 如何将wifi驱动程序添加到buildroot
- json - 如何在 Kotlin 中解析 JSON 数组
- facebook - (#200) 该应用程序未列入使用此 API 的白名单
- c++ - std::map::operator[] 比 std::map::insert 更高效?
- wordpress - 更改悬停菜单颜色
- css - 如何在图像上获得透明波浪边框效果
- sql - Laravel 查询不使用 where 子句作为日期
- javascript - 如果接受断开/连接 Web 套接字,WebSocket 不会重新连接
- bash - 如何在shell脚本的字符串中使用参数?
- java - Java javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1] 消息:prolog 中不允许内容