Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what is the difference between parameter n_estimator and n_rounds? #2854

Closed
sun137653577 opened this issue Nov 2, 2017 · 1 comment
Closed

Comments

@sun137653577
Copy link

hi Contributors,
Xgboost is really an exciting tool for data mining. While I am confused with the parameter n_estimator and n_rounds? Per my understanding, both are used as trees numbers or boosting times. But, there is a big difference in predictions. Following are my codes, seek your help. Many thanks.

  1. only n_estimators
    clf = XGBRegressor(objective='reg:tweedie',
    learning_rate=0.01,
    n_estimators=500,
    max_depth=6,
    gamma=0.5,
    subsample=1,
    colsample_bytree=0.8,
    reg_alpha=1,
    missing=None)
    xgb_param=clf.get_xgb_params()
    dtrain = xgb.DMatrix(x_train,label=y_train)
    model = xgb.train(xgb_param,dtrain)

  2. codes with n_rounds
    clf = XGBRegressor(objective='reg:tweedie',
    learning_rate=0.01,
    max_depth=6,
    gamma=0.5,
    subsample=1,
    colsample_bytree=0.8,
    reg_alpha=1,
    missing=None)
    xgb_param=clf.get_xgb_params()
    n_rounds=500
    dtrain = xgb.DMatrix(x_train,label=y_train)
    model= xgb.train(xgb_param,dtrain,n_rounds)

Jianju

@sethah
Copy link
Contributor

sethah commented Nov 2, 2017

They are the same. You can see it in the source code:

self._Booster = train(params, trainDmatrix,
                              self.n_estimators, evals=evals,
                              early_stopping_rounds=early_stopping_rounds,
                              evals_result=evals_result, obj=obj, feval=feval,
                              verbose_eval=verbose, xgb_model=xgb_model)

In the first instance you aren't passing the num_boost_round parameter and so it defaults to 10. That explains the difference.

@tqchen tqchen closed this as completed Jul 4, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants