KatInterview

Model Selection and Threshold Tuning in Classification Tasks

Machine LearningModel answer
HardModel answerMachine Learningmodel-evaluationensemble-methodsregularization

Last updated

Analyze cost-sensitive threshold selection, compare ensemble methods for production systems, and explain how regularization penalties shape model weights.

You're working on machine learning systems and need to make decisions about model configuration, evaluation metrics, and algorithm selection. Answer the following questions with detailed reasoning.

Question 1: Cost-Sensitive Classification

You're building a classifier to identify premium content. The business impact is asymmetric: mistakenly labeling regular content as premium costs the company 10× more than failing to promote actual premium content.

Explain how you would set the classification threshold given this cost structure. Your response should cover:

  • The mathematical reasoning for threshold selection
  • How this impacts your position on the precision-recall space versus ROC space
  • Which evaluation metric family is most appropriate and why
  • Any practical considerations when the model outputs aren't well-calibrated

Question 2: Production Ensemble Systems

You need to choose between Random Forest and Gradient Boosting for a latency-sensitive production system.

Address these points:

  1. How does adding more trees affect each algorithm's training error? What does this imply about overfitting risk as you scale the ensemble size?
  2. Decision trees can split using either Gini impurity or entropy. Explain the practical difference between these criteria and when you might prefer one over the other.

Question 3: Regularization Mechanics

For a logistic regression model, explain how L1 and L2 regularization penalties affect the learned weight vector.

Your answer should include:

  • The mathematical reason L1 drives weights to exactly zero while L2 only shrinks them
  • A geometric or optimization perspective on why this difference emerges
  • Practical implications for feature selection

Hints

Hint 1

For cost-sensitive thresholds, think about expected cost rather than just accuracy. The decision boundary should reflect the relative costs of each error type.

Hint 2

Random Forests average independent predictions while Gradient Boosting builds trees sequentially to correct errors. This fundamental difference drives their overfitting behavior.

Hint 3

Look at the shape of the penalty function near zero. L1 has a constant slope everywhere, while L2's gradient approaches zero as weights shrink.