← Uber Interview Insights

Uber·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Uber ML engineer round that was basically one long coding question dressed up as a design discussion. They wanted a full logistic regression implementation from scratch, runnable end-to-end, with a side conversation about regularization and convergence. More depth than I expected for a single question.

Questions Asked (3)

Q1

Implement logistic regression from scratch with fit, predict_proba, and predict methods. The implementation should use gradient descent on the negative log-likelihood loss, handle numerical stability in the sigmoid, and support binary classification with a 0.5 threshold.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

This took up basically the whole session.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and assumptions, then outline the mathematical formulation and implementation plan. Write clean, modular code with separate methods for sigmoid, loss, gradient, fit, predict_proba, and predict, ensuring numerical stability and vectorization. Test with a small synthetic dataset and discuss trade-offs like convergence criteria and regularization.

Pro tip: Demonstrate numerical stability by implementing a stable sigmoid that avoids overflow, and mention that you would use log-sum-exp trick for the loss. Also, discuss how you would handle regularization and convergence monitoring to show production readiness.

1. Clarify requirements and assumptions

Confirm input/output expectations, binary classification, threshold, and whether to include regularization. Ask about performance constraints and data size.

2. Outline mathematical formulation

Define sigmoid function, negative log-likelihood loss, and gradient. Explain how gradient descent updates weights.

3. Implement core methods

Code sigmoid with numerical stability, compute loss and gradient, and implement fit using gradient descent with convergence checks.

4. Implement prediction methods

Implement predict_proba using sigmoid, and predict by thresholding probabilities at 0.5.

5. Test and discuss trade-offs

Validate on synthetic data, discuss convergence criteria, regularization, and scalability considerations.

Key Points to Mention

  • Numerical stability in sigmoid: use piecewise implementation to avoid overflow (e.g., if x >= 0: 1/(1+exp(-x)) else exp(x)/(1+exp(x))).
  • Negative log-likelihood loss and its gradient: derive gradient as X^T (sigmoid(Xw) - y) / m.
  • Gradient descent: batch vs stochastic, learning rate selection, convergence criteria (e.g., change in loss < tol).
  • Vectorization: use NumPy operations for efficiency, avoid loops over samples.
  • Regularization: optional L2 regularization to prevent overfitting, and how to incorporate into gradient.
  • Threshold: default 0.5 for binary classification, but can be tuned based on business metrics.

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

Q2

How do you choose a learning rate, and what convergence criterion would you use for this implementation?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Came right after the coding part.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem context (model, data, compute budget) and then discuss a systematic approach to learning rate selection, from initial range testing to advanced schedules. For convergence, define both practical stopping criteria (e.g., early stopping based on validation loss) and theoretical criteria (e.g., gradient norm threshold), emphasizing the trade-offs in a production setting like Uber.

Pro tip: Mention that at Uber, where models are often retrained frequently, automating learning rate selection with tools like Optuna or Ray Tune and using early stopping with a patience parameter is crucial to balance performance and resource usage.

1. Clarify the context

Ask about the model architecture, dataset size, and available compute. This determines whether you can afford extensive hyperparameter tuning or need a quick heuristic.

2. Initial learning rate selection

Describe methods like LR range test (Smith, 2015) to find a good starting point, or use defaults from similar problems (e.g., 0.001 for Adam). Mention that the optimal LR depends on batch size and optimizer.

3. Learning rate schedules

Explain how you might adjust the LR during training: step decay, cosine annealing, or reduce-on-plateau. For large-scale systems, one-cycle policy can speed up convergence.

4. Convergence criteria

Define both practical (validation loss plateau, early stopping with patience) and theoretical (gradient norm below threshold, parameter change small) criteria. Emphasize that in production, early stopping based on validation metrics is common.

5. Trade-offs and automation

Discuss the trade-off between convergence speed and final performance, and how to automate the process (e.g., hyperparameter tuning frameworks, learning rate schedulers) to reduce manual effort.

Key Points to Mention

  • Learning rate range test (LR finder) to estimate optimal LR
  • Impact of batch size on learning rate (linear scaling rule)
  • Common schedules: step decay, cosine annealing, reduce-on-plateau, one-cycle
  • Convergence criteria: validation loss plateau, gradient norm threshold, early stopping with patience
  • Automated hyperparameter tuning (e.g., Optuna, Ray Tune) for scalability
  • Trade-offs: convergence speed vs. final performance, resource constraints

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

Q3

How would you add L2 regularization to this logistic regression implementation, and what effect does it have on the gradient update?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Pretty standard once you've seen it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the mathematical formulation of L2 regularization in logistic regression, then describe how it modifies the gradient update by adding a penalty term. Finally, discuss the practical implications such as reduced overfitting and the need to tune the regularization hyperparameter.

Pro tip: Mention that L2 regularization corresponds to a Gaussian prior on the weights in a Bayesian framework, and that it can be implemented efficiently by adding weight decay to the optimizer, which is common in deep learning libraries.

1. Define L2 Regularization

Explain that L2 regularization adds a penalty term (lambda/2) * ||w||^2 to the loss function, where lambda controls the strength of regularization.

2. Modify the Loss Function

Write the regularized loss: J(w) = -1/m * sum(y*log(y_hat) + (1-y)*log(1-y_hat)) + (lambda/2) * ||w||^2, excluding the bias term.

3. Derive the Gradient Update

Compute the gradient: dJ/dw = (1/m) * X^T * (y_hat - y) + lambda * w. The update rule becomes w := w - alpha * ((1/m) * X^T * (y_hat - y) + lambda * w).

4. Discuss the Effect

Explain that the added term shrinks weights towards zero, reducing model complexity and overfitting. It also introduces a bias-variance trade-off controlled by lambda.

5. Implementation Considerations

Mention that the bias term is typically not regularized, and that lambda can be tuned via cross-validation. Also note that L2 regularization can be implemented as weight decay in optimizers.

Key Points to Mention

  • L2 regularization adds a penalty proportional to the square of the weights.
  • The gradient update includes an additional term lambda * w, which causes weight decay.
  • Regularization helps prevent overfitting by penalizing large weights.
  • The bias term is usually not regularized.
  • The hyperparameter lambda controls the strength of regularization and needs tuning.
  • L2 regularization is equivalent to a Gaussian prior on weights in Bayesian learning.

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