3
$\begingroup$

When I evaluate the model I seem to be getting a decent RMSE score but when I try to actually see the predictions when I call the model all my values are the same.

 xdata = xgboost.DMatrix(X_train, y_train, feature_names=all_vars)
 xdata_val = xgboost.DMatrix(X_valid, y_valid, feature_names=all_vars)
 xgb_parms['seed'] = random.randint(0,1e9)
 model = xgboost.train(xgb_parms, xdata)
 model.eval(xdata_val)
 ypred = model.predict(xdata_val)

I believe the error is on my last step, what am I doing wrong?

$\endgroup$
2
  • $\begingroup$ Try to draw the XGB tree and see how it looks like. Since XGB is a tree model, it might overfit (if the data is unbalanced for instance) generating a small tree that always returns the frequent class label. $\endgroup$ Commented Mar 28, 2018 at 23:36
  • 1
    $\begingroup$ Please provide minimal reproducible example, i.e. the complete code needed to reproduce your results, including the data. If your data can’t be shared, try to reproduce the problem with some publicly available dataset. This will increase your chances to get answer. $\endgroup$
    – aivanov
    Commented Jan 22, 2021 at 20:51

1 Answer 1

1
$\begingroup$

Make sure to pass the model an "objective" parameter and also use "rmse" for the "eval_metric" parameter.

https://github.com/dmlc/xgboost/blob/master/doc/parameter.rst

$\endgroup$
3
  • $\begingroup$ Your link seems to be broken $\endgroup$
    – aivanov
    Commented Jan 22, 2021 at 20:47
  • 1
    $\begingroup$ @aivanov link has been updated! $\endgroup$
    – bbennett36
    Commented Jan 24, 2021 at 21:23
  • $\begingroup$ Hm, the default values for the objective and eval_metric (reg:squarederror and rmse, resp.) should be OK I guess. $\endgroup$
    – aivanov
    Commented Jan 24, 2021 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.