gpt4 book ai didi

r - 如何在R中使用XGBoost算法进行回归?

转载 作者:行者123 更新时间:2023-11-30 08:22:32 25 4
gpt4 key购买 nike

我正在尝试使用 XGBoost 技术进行预测。由于我的因变量是连续的,因此我使用 XGBoost 进行回归,但各个门户中提供的大多数引用都是用于分类的。虽然我知道通过使用

objective = "reg:linear"

我们可以进行回归,但我仍然需要澄清其他参数。如果有人能给我提供它的 R 代码片段,那将是一个很大的帮助。

最佳答案

xgboost(data = X, 
booster = "gbtree",
objective = "binary:logistic",
max.depth = 5,
eta = 0.5,
nthread = 2,
nround = 2,
min_child_weight = 1,
subsample = 0.5,
colsample_bytree = 1,
num_parallel_tree = 1)

这些是您在使用树木助推器时可以使用的所有参数。对于线性助推器,您可以使用以下参数来玩...

xgboost(data = X, 
booster = "gblinear",
objective = "binary:logistic",
max.depth = 5,
nround = 2,
lambda = 0,
lambda_bias = 0,
alpha = 0)

这些参数的详细含义可以引用xgboost CRAN文档中xg.train()的描述。

关于r - 如何在R中使用XGBoost算法进行回归?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33209391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com