deprecation warning in xgboost

Question:

UserWarning: The use of label encoder in XGBClassifier is deprecated and will be removed in a future release.

here is my code:

df_train = pd.read_csv("train.csv")
df_test = pd.read_csv("test.csv")
df_train['steps_title']= df_train['steps_title'].map(d_steps_title)
df_test['steps_title']= df_test['steps_title'].map(d_steps_title)
x_train =df_train[df_train.columns[1:11]]
x_test = df_test[df_test.columns[1:11]]
y_test = df_test['steps_title']
y_train = df_train['steps_title']
kfold = KFold(n_splits=10)
features_train = df_train.columns[1:11]
clf = xgb.XGBClassifier(seed=42, subsample=0.9)
cv_results = cross_val_score(clf,x_train , y_train,cv=kfold , scoring='accuracy')
y_pred = cross_val_predict(clf,x_test,y_test,cv=10)
proba = cross_val_predict(clf,x_test,y_test,cv=10, method='predict_proba')
clf.fit(x_train , y_train , verbose=0, eval_set =[(x_test, y_test)])

I want to suppress the warnings.

I see this answer use_label_encoder =False but is doesn’t
work for me.

I searched everywhere but nothing seemed to work.

Thanks in advance

Asked By: narsan

||

Answers:

I want to suppress the warnings.

import warnings
warnings.filterwarnings("ignore", category=UserWarning)

This will suppress the warning.

Answered By: user14518353

I’d change the encoder to something supported long-term, as suppressing deprecation warnings creates tech debt that will have to be paid off later.

Answered By: mirekphd
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.