为什么我在使用 xgboost 时会收到此 FutureWarning?

Why do I receive this FutureWarning when I use xgboost?

我正在使用 xgboost 来训练带有脚本的二元分类器

class_weights = list(class_weight.compute_class_weight('balanced',np.unique(y_train),y_train))
w_array = np.ones(len(y_train), dtype='float')
for i, val in enumerate(y_train):
    w_array[i] = class_weights[val]    

eval_set = [(x_train, y_train), (x_val, y_val)]
model = XGBClassifier(max_depth=5,n_estimators=1000)
model.fit(x_train, 
          y_train,
          verbose=0,
          eval_set=eval_set,
          eval_metric='auc',
          sample_weight=w_array,
          early_stopping_rounds=200)

在上面的脚本中,x_trainx_val分别是形状数组(386, 72)(387, 72)y_trainy_val 是零和一的数组。 运行脚本,我会收到警告

FutureWarning: Pass classes=[0 1], y=[1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1] as keyword args. From version 0.25 passing these as positional arguments will result in an error
  FutureWarning)

这是什么意思?

我的 xgboost 版本是 0.81

这里指的是compute_class_weight。它要求您显式传递您尝试预测的 类。

来自documentation

classes : ndarray

Array of the classes occurring in the data, as given by np.unique(y_org) with y_org the original class labels.