当我为scale_pos_weight
赋值时,XGB是否也在评估过程中进行类平衡采样作为训练?
这里有一个设置示例:
Classifier = XGBClassifier(objective="binary:logistic",n_jobs=4,scale_pos_weight=10)
Classifier.fit(train_features, train_labels,eval_metric="aucpr",eval_set=[(train_features,train_labels),(test_features,test_labels)])
它对我的(test_features,test_labels)
进行采样吗?
尝试以下方法:
neg, pos = np.bincount(train_labels)
print(np.bincount(train_labels))
import math
class_weight1 = math.sqrt(neg/pos)
print(class_weight1)
class_weight2 = neg/pos
print(class_weight2)
``
分类器=XGB分类器(random_state=0,scale_pos_weight=class_weight 1(
It will resampling the classes in training set only. Resampling techniques are not applicable to test set.