Search code examples
pythonxgboost

deprecation warning in xgboost


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


Solution

  • I want to suppress the warnings.

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

    This will suppress the warning.