← Upstart Interview Insights

Upstart·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Got a technical screen for a Data Scientist role at Upstart that went deep into logistic regression fundamentals. One meaty multi-part question covering the full ML loss function pipeline, from likelihood to gradients. Felt like a written exam more than a conversation.

Questions Asked (4)

Q1

For binary logistic regression, write out the maximum-likelihood objective both with and without L2 regularization, and be explicit about whether you're maximizing or minimizing.

Technical Trade-offsData Modeling
Author's notes

I defaulted to writing the minimization form (negative log-likelihood) without being asked, which is fine but I fumbled the transition when they asked me to show the maximization version too.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly stating the setup: binary labels y ∈ {0,1}, features x, parameters w (and bias b). Then write the log-likelihood (to be maximized) and the negative log-likelihood (to be minimized), and show how L2 regularization adds a penalty term to the negative log-likelihood. Be explicit about the sign and the optimization direction.

Pro tip: Mention that in practice, optimization libraries (e.g., scikit-learn, TensorFlow) minimize the negative log-likelihood plus regularization, and that the regularization parameter λ (or C = 1/λ) controls the strength of the penalty. This shows awareness of implementation details.

1. Define the model and notation

State that for binary logistic regression, P(y=1|x) = σ(w·x + b), where σ(z) = 1/(1+e^{-z}). Assume a dataset of N independent samples {(x_i, y_i)}.

2. Write the likelihood and log-likelihood

The likelihood is L(w) = ∏_{i=1}^N σ(w·x_i + b)^{y_i} (1-σ(w·x_i + b))^{1-y_i}. The log-likelihood is ℓ(w) = ∑_{i=1}^N [y_i log σ(w·x_i + b) + (1-y_i) log(1-σ(w·x_i + b))].

3. State the unregularized objective

The maximum-likelihood objective is to maximize ℓ(w). Equivalently, minimize the negative log-likelihood: J(w) = -ℓ(w).

4. Add L2 regularization

The L2-regularized objective is to maximize ℓ(w) - (λ/2) ||w||^2, or equivalently minimize J_reg(w) = -ℓ(w) + (λ/2) ||w||^2, where λ ≥ 0 controls the penalty strength.

5. Clarify optimization direction and conventions

Emphasize that maximizing the log-likelihood is equivalent to minimizing the negative log-likelihood, and that regularization is typically added to the negative log-likelihood (so it penalizes large weights). Note that some libraries use C = 1/λ.

Key Points to Mention

  • Logistic regression models the log-odds as a linear function: log(p/(1-p)) = w·x + b.
  • The log-likelihood for binary labels can be written compactly as ∑ [y_i log σ(z_i) + (1-y_i) log(1-σ(z_i))].
  • Maximizing the log-likelihood is equivalent to minimizing the negative log-likelihood (a convex function).
  • L2 regularization adds a penalty term (λ/2) ||w||^2 to the negative log-likelihood, discouraging large weights.
  • The regularization parameter λ (or C in scikit-learn) controls the trade-off between fitting the data and keeping weights small.
  • Be explicit about whether you are maximizing or minimizing: state the objective and its equivalent form.

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

Q2

Write out the explicit cross-entropy loss for a binary logistic regression model.

Data Modeling
Author's notes

Muscle memory from school, pretty much.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the binary logistic regression model and its probabilistic output, then derive the cross-entropy loss from maximum likelihood estimation. Present the final loss function clearly, explaining each term and its role in penalizing incorrect predictions.

Pro tip: Emphasize that cross-entropy loss is equivalent to the negative log-likelihood of the Bernoulli distribution, and mention that it's convex, which ensures reliable optimization. This shows depth beyond just memorizing the formula.

1. Define the model

State that logistic regression models the probability of the positive class as p(y=1|x) = σ(w·x + b), where σ is the sigmoid function.

2. Write the likelihood

For a dataset of N independent samples, the likelihood is the product of p(y_i=1|x_i) for positive examples and (1 - p(y_i=1|x_i)) for negative examples.

3. Take negative log-likelihood

The cross-entropy loss is the negative log-likelihood: L(w,b) = -Σ [y_i log(p_i) + (1-y_i) log(1-p_i)], where p_i = σ(w·x_i + b).

4. Explain components

Clarify that y_i is the true label (0 or 1), p_i is the predicted probability, and the loss penalizes deviations from the true labels, with log terms ensuring large penalties for confident wrong predictions.

5. Mention optimization

Note that this loss is convex and typically minimized using gradient descent, with gradients having a simple form: ∇_w L = Σ (p_i - y_i) x_i.

Key Points to Mention

  • Binary logistic regression outputs probabilities via the sigmoid function.
  • Cross-entropy loss is derived from maximum likelihood estimation for Bernoulli-distributed labels.
  • The explicit formula: L = -Σ [y_i log(p_i) + (1-y_i) log(1-p_i)].
  • The loss is convex, ensuring a unique global minimum.
  • Gradient of the loss with respect to weights is (p_i - y_i) x_i, enabling efficient optimization.
  • Cross-entropy heavily penalizes confident incorrect predictions due to the logarithmic terms.

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

Q3

Derive the gradients of the cross-entropy loss with respect to the weight vector and the bias term.

Algorithms & Data StructuresData Modeling
Author's notes

This is where things got interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly defining the setup: a single-layer model with softmax output and cross-entropy loss. Then derive the gradient of the loss with respect to the logits, which simplifies to (predicted probability - true label). Finally, use the chain rule to express the gradients with respect to weights and bias in terms of the input features and this logit gradient.

Pro tip: Emphasize that the gradient with respect to the bias is simply the sum of the logit gradients over the batch, which is a useful sanity check and often overlooked. Also, mention that this derivation is the foundation for backpropagation in neural networks.

1. Define the model and loss

Clearly state the model: logits z = Wx + b, softmax probabilities p = softmax(z), and cross-entropy loss L = -sum(y_i log(p_i)). Define all variables and dimensions.

2. Compute gradient of loss w.r.t. logits

Derive dL/dz = p - y, where p is the predicted probability vector and y is the one-hot true label vector. Explain the steps using the chain rule and properties of softmax.

3. Apply chain rule for weights and bias

Use z = Wx + b to get dL/dW = (dL/dz) x^T and dL/db = dL/dz. Show that for a batch, these become matrix multiplications and sums.

4. Extend to batch and regularization (optional)

If applicable, mention how the gradients change when averaging over a batch or adding L2 regularization. This shows awareness of practical implementation.

Key Points to Mention

  • Softmax function and its derivative
  • Cross-entropy loss formula
  • Chain rule application
  • Gradient of loss w.r.t. logits simplifies to (p - y)
  • Gradient w.r.t. weights: (p - y) x^T
  • Gradient w.r.t. bias: sum of (p - y) over batch

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

Q4

What is the difference between the 'loss', the 'objective', and the 'regularized objective' in this logistic regression setup?

Technical Trade-offsData Modeling
Author's notes

Honestly the question I was least prepared for even though it sounds easy.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining each term clearly and in relation to the others: loss is the per-example or aggregate error, objective is the function being optimized (often loss plus regularization), and regularized objective adds a penalty term to the objective. Then explain how they connect in logistic regression, emphasizing that the regularized objective is what is actually minimized during training, and discuss the role of regularization in preventing overfitting.

Pro tip: Mention that while the loss is typically the negative log-likelihood, the objective might include additional terms like regularization, and that the choice of regularization affects the bias-variance trade-off. Also, note that in practice, the terms are sometimes used interchangeably, so clarify the context.

1. Define Loss

Explain that loss (or cost) function measures the error between predictions and true labels for a single example or the entire dataset. In logistic regression, it's typically the negative log-likelihood (log loss).

2. Define Objective

Describe the objective function as the overall function that the optimization algorithm aims to minimize or maximize. It often includes the loss but may also include other terms. In logistic regression without regularization, the objective is the loss.

3. Define Regularized Objective

Introduce regularization as an additional penalty term added to the objective to control model complexity. The regularized objective is the sum of the loss and a regularization term (e.g., L1 or L2 penalty).

4. Relate the Concepts

Clarify that the loss is a component of the objective, and the regularized objective is a specific type of objective that includes regularization. Emphasize that in practice, the regularized objective is what is minimized during training.

5. Discuss Implications

Explain why regularization is used: to prevent overfitting, improve generalization, and handle multicollinearity. Mention that the choice of regularization strength (hyperparameter) is crucial and often tuned via cross-validation.

Key Points to Mention

  • Logistic regression loss is typically the negative log-likelihood (log loss).
  • Objective function is the function being optimized; without regularization, it equals the loss.
  • Regularized objective adds a penalty term (L1, L2, or elastic net) to the loss.
  • Regularization helps prevent overfitting and improves model generalization.
  • The regularization hyperparameter controls the trade-off between fitting the data and keeping weights small.
  • In practice, terms 'loss' and 'objective' are sometimes used interchangeably, but context matters.

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