Questions tagged [xgboost]

XGBoost is a library for constructing boosted tree models in R, Python, Java, Scala, and C++. Use this tag for issues specific to the package (i.e., input/output, installation, functionality).

Before using the XGBoost tag, try to test whether your issue is related specifically to the functionality of XGBoost. Often, problems arise from the surrounding model-building environment (such as R's caret or Python's scikit-learn), the quality of the data being used, or purely statistical concerns that might belong on Cross Validated.

2788 questions
35
votes
9 answers

XGBoost plot_importance doesn't show feature names

I'm using XGBoost with Python and have successfully trained a model using the XGBoost train() function called on DMatrix data. The matrix was created from a Pandas dataframe, which has feature names for the columns. Xtrain, Xval, ytrain, yval =…
stackoverflowuser2010
  • 38,621
  • 48
  • 169
  • 217
34
votes
2 answers

What is the difference between num_boost_round and n_estimators

I saw that some xgboost methods take a parameter num_boost_round, like this: model = xgb.cv(params, dtrain, num_boost_round=500, early_stopping_rounds=100) Others however take n_estimators like this: model_xgb = xgb.XGBRegressor(n_estimators=360,…
bsky
  • 19,326
  • 49
  • 155
  • 270
34
votes
1 answer

Difference between Objective and feval in xgboost

What is the difference between objective and feval in xgboost in R? I know this is something very fundamental but I am unable to exactly define them/ their purpose. Also, what is a softmax objective, while doing multi class classification?
33
votes
3 answers

Xgboost-How to use "mae" as objective function?

I know xgboost need first gradient and second gradient, but anybody else has used "mae" as obj function?
Sam Qian
  • 341
  • 1
  • 4
  • 4
33
votes
12 answers

ValueError: feature_names mismatch: in xgboost in the predict() function

I have trained an XGBoostRegressor model. When I have to use this trained model for predicting for a new input, the predict() function throws a feature_names mismatch error, although the input feature vector has the same structure as the training…
Sujay S Kumar
  • 621
  • 1
  • 5
  • 10
31
votes
3 answers

XGBoost for multilabel classification?

Is it possible to use XGBoost for multi-label classification? Now I use OneVsRestClassifier over GradientBoostingClassifier from sklearn. It works, but use only one core from my CPU. In my data I have ~45 features and the task is to predict about 20…
30
votes
3 answers

What are different options for objective functions available in xgboost.XGBClassifier?

Apart from binary:logistic (which is the default objective function), is there any other built-in objective function that can be used in xbgoost.XGBClassifier ?
Venkatachalam
  • 16,288
  • 9
  • 49
  • 77
26
votes
8 answers

Getting this simple problem while importing Xgboost on Jupyter notebook

Everything was running fine in Jupyter notebook until I imported Xgboost. As soon as I import it I get the problem below. I have Python 3.8 and have installed it via terminal pip3 method, what should I do…
jon
  • 751
  • 1
  • 6
  • 9
25
votes
3 answers

How to hide warnings from xgboost library in jupyter?

Not working: import warnings warnings.filterwarnings('ignore') The warning I get: [14:24:45] WARNING: C:/Jenkins/workspace/xgboost-win64_release_0.90/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of…
kaban
  • 423
  • 1
  • 5
  • 10
25
votes
3 answers

Multiclass classification with xgboost classifier?

I am trying out multi-class classification with xgboost and I've built it using this code, clf = xgb.XGBClassifier(max_depth=7, n_estimators=1000) clf.fit(byte_train, y_train) train1 = clf.predict_proba(train_data) test1 =…
user_12
  • 1,778
  • 7
  • 31
  • 72
24
votes
7 answers

Invalid classes inferred from unique values of `y`. Expected: [0 1 2 3 4 5], got [1 2 3 4 5 6]

I've trained dataset using XGB Classifier, but I got this error in local. It worked on Colab and also my friends don't have any problem with same code. I don't know what that error means... Invalid classes inferred from unique values of y. …
ohoh
  • 261
  • 1
  • 2
  • 4
24
votes
4 answers

Trouble training xgboost on categorical column

I am trying to run a Python notebook (link). At line below In [446]: where author train XGBoost, I am getting an error ValueError: DataFrame.dtypes for data must be int, float or bool. Did not expect the data types in fields…
arush1836
  • 1,327
  • 8
  • 19
  • 37
24
votes
4 answers

How to restore the original feature names in XGBoost feature importance plot (after preprocessing removed them)?

Preprocessing the training data (such as centering or scaling) before training an XGBoost model, can lead to a loss of feature names. Most answers on SO suggest training the model in such a way that feature names aren't lost (such as using…
user11086563
24
votes
4 answers

What does the value of 'leaf' in the following xgboost model tree diagram means?

I am guessing that it is conditional probability given that the above (tree branch) condition exists. However, I am not clear on it. If you want to read more about the data used or how do we get this diagram then go to :…
dsl1990
  • 1,157
  • 5
  • 13
  • 25
24
votes
10 answers

Feature Importance with XGBClassifier

Hopefully I'm reading this wrong but in the XGBoost library documentation, there is note of extracting the feature importance attributes using feature_importances_ much like sklearn's random forest. However, for some reason, I keep getting this…
Minh
  • 2,180
  • 5
  • 23
  • 50