← Uber Interview Insights

Uber·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jul 2026

Summary

Uber ML engineer interview that was basically a deep dive into logistic regression, not just the implementation but all the surrounding theory. More thorough than I expected for a single question.

Questions Asked (4)

Q1

Implement logistic regression from scratch for binary classification, including the sigmoid model, cross-entropy loss, gradient descent training, and both predict_proba and predict methods.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The coding part was fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly stating the mathematical components: sigmoid function, cross-entropy loss, and gradient descent update rule. Then outline the class structure with fit, predict_proba, and predict methods, emphasizing vectorized operations for efficiency. Finally, discuss practical considerations like numerical stability and convergence checks.

Pro tip: Mention adding a small epsilon to probabilities before taking the log to avoid log(0) errors, and use vectorized operations instead of loops for scalability—this shows production-level awareness.

1. Define the Model and Loss

Explain the sigmoid function σ(z) = 1/(1+e^{-z}) and cross-entropy loss J(θ) = -1/m Σ [y log(ŷ) + (1-y) log(1-ŷ)]. Highlight that the loss is convex, ensuring convergence to global minimum.

2. Derive the Gradient

Show that the gradient of the loss with respect to weights is X^T (ŷ - y) / m. This simple form enables efficient vectorized updates.

3. Implement Gradient Descent Training

Initialize weights to zeros or small random values. Iterate: compute predictions, compute gradient, update weights θ := θ - α * gradient. Optionally include convergence check based on loss change.

4. Implement predict_proba and predict

predict_proba returns sigmoid(X @ θ). predict applies a threshold (default 0.5) to predict_proba to output binary labels.

5. Discuss Practical Considerations

Mention feature scaling, regularization (L2) to prevent overfitting, and handling class imbalance. Also note that logistic regression assumes linear decision boundary.

Key Points to Mention

  • Sigmoid function and its role in mapping linear outputs to probabilities
  • Cross-entropy loss and its gradient derivation
  • Vectorized implementation for efficiency (avoid loops)
  • Numerical stability: clipping probabilities or adding epsilon to log
  • Convergence criteria: loss threshold or max iterations
  • Regularization (L1/L2) and its effect on weights

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Why use cross-entropy loss instead of mean squared error for classification tasks?

Technical Trade-offs
Author's notes

I talked about convexity and got a follow-up on gradient behavior near saturation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the theoretical foundations: cross-entropy is the proper scoring rule for probabilistic classification, while MSE assumes Gaussian noise and is better for regression. Then discuss practical implications like gradient behavior and optimization, and finally mention when MSE might still be used (e.g., regression) to show balanced understanding.

Pro tip: Mention that cross-entropy loss is equivalent to minimizing the Kullback-Leibler divergence between the predicted and true distributions, which aligns with maximum likelihood estimation. Also, note that in practice, using MSE with sigmoid/softmax can lead to slow convergence due to vanishing gradients, a point that resonates with engineers dealing with large-scale models.

1. Define the problem and loss functions

Briefly state that classification predicts discrete labels, and compare cross-entropy (negative log-likelihood) with MSE (squared error).

2. Explain theoretical justification

Cross-entropy arises from maximum likelihood estimation for categorical distributions, while MSE assumes a Gaussian distribution over continuous outputs.

3. Discuss gradient and optimization behavior

Cross-entropy yields larger gradients when predictions are wrong, leading to faster convergence; MSE with sigmoid/softmax can cause vanishing gradients.

4. Address practical considerations

Mention that cross-entropy is standard in frameworks (e.g., PyTorch's CrossEntropyLoss) and works well with softmax; MSE is still used for regression or when outputs are not probabilities.

5. Conclude with trade-offs

Summarize that cross-entropy is preferred for classification due to probabilistic interpretation and better optimization, but MSE may be suitable for regression or when calibrated probabilities are not needed.

Key Points to Mention

  • Cross-entropy is the negative log-likelihood of the true label under the predicted probability distribution.
  • MSE assumes Gaussian noise and is not a proper scoring rule for classification.
  • Gradient of cross-entropy with softmax simplifies to (predicted - true), avoiding vanishing gradients.
  • MSE with sigmoid/softmax can lead to slow convergence and poor local minima.
  • Cross-entropy penalizes confident wrong predictions more heavily, which is desirable for classification.
  • In practice, cross-entropy is the default for classification in major deep learning libraries.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

How would you extend binary logistic regression to handle multi-class classification, and how would you add L2 regularization?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Softmax regression came naturally, no issues there.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining that multinomial logistic regression (softmax regression) naturally extends binary logistic regression by modeling the probability of each class using the softmax function. Then describe how L2 regularization is added by penalizing the squared magnitude of the weights in the loss function, and discuss the implications for optimization and model behavior.

Pro tip: Mention that in practice, you might use one-vs-rest for simplicity or when classes are not mutually exclusive, but softmax is preferred for mutually exclusive classes. Also, note that L2 regularization helps prevent overfitting and improves generalization, especially with high-dimensional data.

1. Review binary logistic regression

Briefly recap that binary logistic regression models P(y=1|x) using the sigmoid function applied to a linear combination of features.

2. Extend to multi-class with softmax

Explain that for K classes, we compute a linear score for each class and apply the softmax function to obtain probabilities. The model is trained by minimizing the cross-entropy loss.

3. Introduce L2 regularization

Describe adding an L2 penalty term (lambda * sum of squared weights) to the loss function, which discourages large weights and helps control overfitting.

4. Discuss optimization and implementation

Mention that the regularized loss is convex and can be optimized with gradient descent or quasi-Newton methods. Note that regularization is typically not applied to bias terms.

5. Compare alternatives and trade-offs

Contrast softmax with one-vs-rest approach, and discuss when to use each. Also, mention that L2 regularization can be tuned via cross-validation.

Key Points to Mention

  • Softmax function for multi-class probability estimation
  • Cross-entropy loss for multi-class classification
  • L2 regularization term added to the loss function
  • Gradient descent or other optimization algorithms for training
  • One-vs-rest vs. softmax (multinomial) approaches
  • Hyperparameter tuning for regularization strength (lambda)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Walk through how you'd evaluate a binary classifier, and explain how changing the decision threshold affects your metrics.

Product Analytics & MetricsTechnical Trade-offs
Author's notes

Pretty standard.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by outlining a comprehensive evaluation framework that covers discrimination, calibration, and business impact, then explain how the decision threshold is a tunable parameter that trades off precision and recall. Use a concrete example (e.g., fraud detection at Uber) to illustrate how threshold changes affect metrics and why the optimal threshold depends on the cost of errors.

Pro tip: Always tie the threshold choice back to the business objective and error costs—interviewers at Uber want to see that you can translate model metrics into product decisions, not just recite definitions.

1. Define evaluation goals and metrics

Clarify the problem context, class balance, and business costs (e.g., false negatives vs. false positives). Choose appropriate metrics such as precision, recall, F1, AUC-ROC, AUC-PR, and calibration.

2. Evaluate model discrimination and calibration

Use ROC/PR curves to assess ranking ability and calibration plots to check probability reliability. Discuss how these are threshold-independent.

3. Explain threshold impact on confusion matrix

Describe how moving the threshold changes TP, FP, TN, FN, and consequently precision, recall, and F1. Use a visual or example to show the trade-off.

4. Optimize threshold for business objective

Select threshold by maximizing expected utility or minimizing cost, using cost-sensitive analysis or constraints (e.g., recall ≥ 90%). Mention techniques like ROC convex hull or precision-recall trade-off.

5. Monitor and iterate post-deployment

Emphasize that threshold may need recalibration as data drifts or business costs change. Set up monitoring for key metrics and feedback loops.

Key Points to Mention

  • Threshold-independent metrics: AUC-ROC, AUC-PR, and calibration (e.g., Brier score, reliability diagrams).
  • Threshold-dependent metrics: precision, recall, F1, accuracy, and confusion matrix.
  • Trade-off between precision and recall: increasing threshold typically increases precision and decreases recall.
  • Cost-sensitive evaluation: assign costs to FP and FN, then choose threshold that minimizes total cost.
  • Class imbalance: accuracy is misleading; use PR-AUC and consider resampling or class weights.
  • Business context: align threshold with product goals (e.g., fraud detection may prioritize recall).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.