简体   繁体   English

Python的XGBRegressor与R的XGBoost

[英]Python's XGBRegressor vs R's XGBoost

I'm using python's XGBRegressor and R's xgb.train with the same parameters on the same dataset and I'm getting different predictions. 我在同一数据集上使用具有相同参数的python的XGBRegressor和R的xgb.train,并且得到了不同的预测。

I know that XGBRegressor uses 'gbtree' and I've made the appropriate comparison in R, however, I'm still getting different results. 我知道XGBRegressor使用'gbtree'并且我已经在R中进行了适当的比较,但是,我仍然得到不同的结果。

Can anyone lead me in the right direction on how to differentiate the 2 and/or find R's equivalence to python's XGBRegressor? 任何人都可以引导我朝正确的方向介绍如何区分2和/或找到R与python的XGBRegressor对等吗?

Sorry if this is a stupid question, thank you. 抱歉,这是一个愚蠢的问题,谢谢。

Since XGBoost uses decision trees under the hood it can give you slightly different results between fits if you do not fix random seed so the fitting procedure becomes deterministic. 由于XGBoost在引擎盖下使用决策树,因此,如果不固定随机种子,则拟合之间的结果可能会略有不同,因此拟合过程将变得确定。

You can do this via set.seed in R and numpy.random.seed in Python. 您可以通过这样做set.seed在R和numpy.random.seed Python编写的。

Noting Gregor's comment you might want to set nthread parameter to 1 to achieve full determinism. 注意Gregor的注释,您可能希望将nthread参数设置为1以实现完全确定性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM