Keeping rare labels represented across validation folds

Stratified K-fold tries to preserve class proportions in each fold.

StratifiedKFold in practice

With ten spam messages in a hundred, five folds can each contain two. With only two positives overall, five folds cannot all contain a positive.

中文

分层交叉验证怎样照顾少数类别?

分层 K 折尽量让每折保持总体类别比例。

StratifiedKFold 应用实例

100 封邮件中 10 封垃圾邮件,五折时每折可分到两封。若总共只有两封,五折无法让每折都有正例。

References / 参考来源

Keep reading / 继续阅读