Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

A PyTorch workflow for extreme class imbalance

AI summary

A tutorial presents an end-to-end PyTorch workflow for binary classification with tens of thousands of positive examples and single-digit negative examples. It recommends evaluating with PR curves, F1 and recall rather than accuracy, then demonstrates focal or weighted cross-entropy, SMOTE oversampling and threshold tuning. It also discusses anomaly detection when there are too few negative examples to support conventional classification.

In-depth insight

The tutorial shows how a model can achieve nearly perfect accuracy while failing to identify any rare negative examples, and outlines steps intended to make the minority class more important during training and evaluation.

核心结论:当正样本几万、负样本只有个位数时,直接训练等于白练——模型会「聪明地」全猜正类,accuracy 高达 99.99% 却一个负样本都抓不到。正确的姿势是四步走:① 先把评估指标从 accuracy 换成 PR-curve / F1 / recall;② 用 focal loss 或加权交叉熵重设损失函数;③ 对少数类做 SMOTE 过采样或数据增强;④ 最后调低预测阈值(threshold),在 precision 和 recall 之间找回平衡。极端到个位数时,别再想「把它当分类问题」,直接转成异常检测 / one-class 问题更现实。

#PyTorch#scikit-learn#imbalanced-learn

Original · 12 min readRead the original
Group chat

No comments yet. Start the conversation.