Questions tagged [xgbclassifier]
112 questions
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
16
votes
2 answers
The loss function and evaluation metric of XGBoost
I am confused now about the loss functions used in XGBoost. Here is how I feel confused:
we have objective, which is the loss function needs to be minimized; eval_metric: the metric used to represent the learning result. These two are totally…

Bs He
- 717
- 1
- 10
- 22
13
votes
2 answers
XGBoost for multiclassification and imbalanced data
I am dealing with a classification problem with 3 classes [0,1,2], and imbalanced class distribution as shown below.
I want to apply XGBClassifier (in Python) to this classification problem, but the model does not respond to class_weight…

Pooyan Moradifar
- 145
- 1
- 1
- 6
8
votes
1 answer
how to plot XGBoost evaluation metrics?
I've the following code
eval_set = [(X_train, y_train), (X_test, y_test)]
eval_metric = ["auc","error"]
In the following part, I'm training the XGBClassifier model
model = XGBClassifier()
%time model.fit(X_train, y_train, eval_set=eval_set,…

Van Peer
- 2,127
- 2
- 25
- 35
7
votes
2 answers
Custom loss in XGBoost is not updating
Context
I am trying to use a custom loss function for an XGBoost binary classifier.
The idea was to implement in XGBoost the soft-Fbeta loss, which I read about here. Simply put: instead of using the standard logloss, use a loss function that…

GiacomoP
- 83
- 3
7
votes
1 answer
Python XGBoost classifier can't `predict`: `TypeError: Not supported type for data`
I have a dataset like so:
print(X_test.dtypes)
metric1 int64
rank float64
device_type int8
NA_estimate float64
When I try to make predictions on this data set, I get the following…

user2205916
- 3,196
- 11
- 54
- 82
6
votes
1 answer
Shap value dimensions are different for RandomForest and XGB why/how? Is there something one can do about this?
The SHAP values returned from tree explainer's .shap_values(some_data) gives different dimensions/results for XGB as for random forest. I've tried looking into it, but can't seem to find why or how, or an explanation in any of Slundberg's (SHAP…

D00dood
- 443
- 2
- 14
5
votes
1 answer
Why calling fit resets custom objective function in XGBClassifier?
I have tried to setup XGBoost sklearn API XGBClassifier to use custom objective function (brier) according to the documentation:
.. note:: Custom objective function
A custom objective function can be provided for the ``objective``
…

Xaume
- 293
- 2
- 16
5
votes
1 answer
ImportError: cannot import name 'XGBClassifier' from 'xgboost' (unknown location)
xgboost imported successfully, but I'm not able to import XGBClassifier.

Yash Vichare
- 51
- 1
- 2
4
votes
1 answer
What is difference between xgboost.plot_importance() and model.feature_importances_ XGBclassifier
What is difference between xgboost.plot_importance() and model.feature_importances_ in XGBclassifier.
so here I make some dummy data
import numpy as np
import pandas as pd
# generate some random data for demonstration purpose, use your original…

Farah Amirah
- 59
- 1
- 6
4
votes
1 answer
Parameters: { scale_pos_weight } might not be used
I'm dealing with this warning:
[20:16:09] WARNING: ../src/learner.cc:541:
Parameters: { scale_pos_weight } might not be used.
This may not be accurate due to some parameters are only used in language bindings but
passed down to XGBoost core. …

sooaran
- 183
- 1
- 2
- 13
4
votes
1 answer
XGBoost - get probabilities after multi:softmax function
I have a question regarding xgboost and multiclass. I am not using the sklearn wrapper as I always struggle with some parameters. I was wondering if it is possible to get the probability vector plus the softmax output. The following is my…

Guido Muscioni
- 1,203
- 3
- 15
- 37
3
votes
0 answers
xgb.cv creates Warning: Empty dataset at worker: 0
I am using a XGBClassifier and try to do a grid search in order to tune some parameters, and I get this warning : WARNING: ../src/learner.cc:1517: Empty dataset at worker: 0 whenever I launch the command xgb.cv(). It does not work either when I try…

MPTheAnt
- 31
- 3
3
votes
1 answer
How to get hyperparameters of xgb.train in python
xgb.train is the low level API to train an xgboost model in Python.
When I use XGBClassifier, which is a wrapper and calls xgb.train when
a model is trained, I can print the XGBClassifier object and the
hyperparameters are printed.
When using…

gato
- 91
- 1
- 9
3
votes
0 answers
How fix AttributeError: dlsym(0x7fa8b0814da0, XGBoosterGetStrFeatureInfo): symbol not found
I want to run xgb on my Mac (specifications). I followed this instructions: https://towardsdatascience.com/install-xgboost-and-lightgbm-on-apple-m1-macs-cb75180a2dda.
The result is the problem with XGBClassifier
enter image description here

Miha Chestneyshin
- 31
- 2