179 questions
No questions match those filters.
You applied class weights to fix a 1:1000 class imbalan...
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansClass weights address the wrong axis of the problem. They rebalance the counts — how much each class contributes to the total loss — but they say nothing about difficulty. Even after weighting, a fraud dataset still contains hundreds of thousands of easy, obviously-legitimate transactions the model already classifies with high confidence. Each of those contributes a small gradient, but there are so many of them that their sum dominates the update step, leaving little capacity for the handful of ambiguous, genuinely hard fraud cases that actually need the model’s attention.
This is gradient drowning, and no amount of retuning the class weight ratio fixes it, because reweighting scales gradients uniformly within a class rather than suppressing the ones the model has already learned.
Focal Loss solves the right problem. It multiplies the standard cross-entropy term by a modulating factor (1 − p_t)^γ, where p_t is the model’s predicted probability for the true class. When the model is confident and correct, that factor collapses toward zero and the example’s loss contribution is effectively muted. When the model is unsure, the factor stays close to one and the example keeps contributing full gradient. The practical framing: weighted cross-entropy rebalances moderate imbalance (roughly 1:10) by adjusting counts; Focal Loss handles extreme imbalance (1:1000 and beyond) by adjusting for hardness. In production fraud detection you typically need both — class weights to get the scale right, and Focal Loss (γ around 2 is a common starting point) to keep the easy majority from starving the model of signal on the cases that matter.