咨询:xgboost正负样本标签翻转后AUROC小幅变化的原因
Hey there! Let's unpack why you're seeing such a tiny shift (0.778 → 0.779) in AUROC after flipping labels in XGBoost, even with the same seed and scale_pos_weight set. This boils down to three key factors:
scale_pos_weightcreates a symmetric weight balance
Normally, flipping labels would make your AUROC equal to1 - original AUROC(since the model is now learning to distinguish the opposite class). But here, yourscale_pos_weightparameter locks in a balance that counteracts this. Let's say originally you hadPpositive samples andNnegative ones, so you setscale_pos_weight = N/Pto fix class imbalance. When you flip labels, your new positive count isNand negative isP—but if you keptscale_pos_weightatN/P, that value now equalsnew_negative_count / new_positive_count. This means you're effectively balancing the new class distribution the same way you balanced the old one. The model ends up learning a decision boundary that's functionally equivalent in terms of ranking ability, so AUROC stays nearly identical.Tiny randomness in XGBoost training
Even withset.seed()set, XGBoost can have minuscule non-determinism if you're using multi-threading (the default). Thread scheduling order can slightly alter the order of node splits during training, leading to tiny differences in predicted probabilities. These small shifts are enough to nudge AUROC by 0.001, which is totally negligible for practical purposes.AUROC calculation precision
AUROC relies on ranking predicted probabilities. When those probabilities change even slightly (thanks to the above randomness), the AUROC score can tick up or down by a thousandth of a point—especially with large datasets. This is just a numerical artifact, not a meaningful change in model performance.
In short, that 0.001 shift is nothing to worry about. It's a combination of symmetric weighting preserving your model's core ranking ability and minor training noise. Your model is performing essentially the same as before the label flip.
内容的提问来源于stack exchange,提问作者Tianliang Bian

