KatInterview

Regression Loss Functions, Imbalanced Classification Metrics, and Thresholding

Machine LearningModel answer
MediumModel answerMachine Learningloss-functionsclass-imbalanceevaluation-metrics

Last updated

Compare MAE vs MSE for regression, interpret ROC-AUC and PR-AUC under severe class imbalance, design loss functions for imbalanced neural networks, and select classification thresholds rigorously.

You're building machine learning systems and need to make sound decisions about loss functions, evaluation metrics, and operating points. Answer each part with specific reasoning:

Part 1: Regression Loss Functions
Compare MAE (mean absolute error) and MSE (mean squared error) as optimization objectives. Discuss their sensitivity to outliers, gradient properties during training, and practical optimization challenges. Provide a specific scenario where MSE produces poor results while MAE works well.

Part 2: Classification Metrics Under Imbalance
You have a binary classifier on a dataset where only 1% of examples are positive. The model achieves ROC-AUC = 0.90 but PR-AUC = 0.25. Explain what each metric reveals about model performance. Why can ROC-AUC appear strong while PR-AUC remains low? Which metric matters more for this use case?

Part 3: Neural Network Design for Imbalanced Data
Design the output layer and loss function for a binary classification neural network. Explain two approaches to handling class imbalance: class weighting and focal loss. For each, describe how it modifies the gradient signal from positive versus negative examples during backpropagation.

Part 4: Threshold Selection Without Bias
Your application requires precision to be at least 0.50 at the chosen operating threshold. Describe a rigorous process for selecting this threshold from model predictions, ensuring your estimate is not optimistically biased. Address data splitting, calibration considerations, and validation strategy.

Hints

Hint 1

For regression, consider what statistical quantity each loss function estimates at its optimum

Hint 2

Under severe imbalance, a small false positive rate translates to many more false positives than true positives in absolute terms

Hint 3

Focal loss reduces gradient contributions based on prediction confidence, not just class membership

Hint 4

Threshold selection requires a held-out set that is never used during model training or hyperparameter tuning