首页 > 解决方案 > 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)       

标签: rmachine-learningxgboost

解决方案


推荐阅读