← Amazon Interview Insights

Amazon·Data Scientist·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Amazon data scientist interview that went deep into statistical ML fundamentals. Five meaty questions covering everything from OLS derivations to AdaBoost weight updates. Not a vibe check, they wanted actual math.

Questions Asked (5)

Q1

Derive ordinary least squares from scratch: walk through the model setup, assumptions, normal equations, the closed-form estimator, when the matrix inverse exists, the ridge regression alternative, and how regularization shifts the bias-variance tradeoff.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

This took way longer than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly stating the linear model and its assumptions, then derive the OLS estimator by minimizing the residual sum of squares and solving the normal equations. Discuss the conditions for the closed-form solution to exist, introduce ridge regression as a remedy for multicollinearity, and explain how regularization trades off bias and variance.

Pro tip: Emphasize the geometric interpretation of OLS as an orthogonal projection onto the column space, and connect ridge regression to adding a small constant to the diagonal to stabilize the inverse. This shows deep understanding beyond memorized formulas.

1. Model Setup and Assumptions

Define the linear model y = Xβ + ε, and state the key assumptions: linearity, exogeneity (E[ε|X]=0), homoscedasticity, no autocorrelation, and full column rank of X.

2. Derive the OLS Estimator

Minimize the residual sum of squares (RSS) = ||y - Xβ||² by taking the gradient with respect to β, setting it to zero, and solving the normal equations XᵀXβ = Xᵀy to get β̂ = (XᵀX)⁻¹Xᵀy.

3. Conditions for Existence

Explain that the closed-form solution exists if and only if XᵀX is invertible, which requires X to have full column rank (no perfect multicollinearity) and more observations than predictors (n > p).

4. Ridge Regression as an Alternative

Introduce ridge regression, which adds a penalty λ||β||² to the RSS, leading to β̂_ridge = (XᵀX + λI)⁻¹Xᵀy. This always yields an invertible matrix for λ > 0, even when XᵀX is singular.

5. Bias-Variance Tradeoff

Discuss how ridge introduces bias but reduces variance, often lowering mean squared error. As λ increases, bias increases and variance decreases; λ=0 corresponds to OLS.

Key Points to Mention

  • Normal equations derivation: setting the gradient of RSS to zero.
  • Full column rank and invertibility of XᵀX; consequences of multicollinearity.
  • Ridge regression closed-form solution and its geometric interpretation.
  • Bias-variance tradeoff: ridge increases bias but can reduce variance and overall MSE.
  • Choice of λ via cross-validation and its effect on model complexity.
  • Comparison to other regularization methods like LASSO (L1) for variable selection.

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

Q2

For logistic regression: write out the negative log-likelihood for binary classification, derive the gradient and Hessian, prove the loss is convex, then do one explicit gradient descent step with learning rate 0.5 using x=(1,2), y=1, and current weights w=(0.1,-0.2).

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The convexity proof tripped me up a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by writing the negative log-likelihood for binary logistic regression, then derive the gradient and Hessian using the sigmoid function and its derivative. Prove convexity by showing the Hessian is positive semidefinite. Finally, compute the predicted probability for the given point, update the weights using gradient descent with learning rate 0.5, and clearly state the new weights.

Pro tip: Emphasize the connection between the Hessian and convexity: the Hessian is X^T S X where S is diagonal with entries p_i(1-p_i) ≥ 0, making it positive semidefinite. This shows both convexity and that the loss is strictly convex if the data matrix has full rank.

1. Write the negative log-likelihood

For binary classification with labels y ∈ {0,1}, the negative log-likelihood is L(w) = -Σ [y_i log(p_i) + (1-y_i) log(1-p_i)], where p_i = σ(w^T x_i) and σ(z) = 1/(1+e^{-z}).

2. Derive gradient and Hessian

The gradient is ∇L(w) = Σ (p_i - y_i) x_i = X^T (p - y). The Hessian is ∇²L(w) = Σ p_i(1-p_i) x_i x_i^T = X^T S X, where S = diag(p_i(1-p_i)).

3. Prove convexity

Show that the Hessian is positive semidefinite: for any vector v, v^T ∇²L(w) v = Σ p_i(1-p_i) (v^T x_i)^2 ≥ 0 because p_i(1-p_i) ≥ 0. Thus L(w) is convex.

4. Compute one gradient descent step

Given x=(1,2), y=1, w=(0.1,-0.2), compute z = w^T x = 0.1*1 + (-0.2)*2 = -0.3. Then p = σ(z) = 1/(1+e^{0.3}) ≈ 0.5744. Gradient for this sample: (p - y)x = (0.5744 - 1)*(1,2) = (-0.4256, -0.8512). Update: w_new = w - η * gradient = (0.1, -0.2) - 0.5*(-0.4256, -0.8512) = (0.3128, 0.2256).

Key Points to Mention

  • Sigmoid function and its derivative: σ'(z) = σ(z)(1-σ(z)).
  • Negative log-likelihood formula for binary classification.
  • Gradient derivation using chain rule: ∇L(w) = X^T (p - y).
  • Hessian derivation: ∇²L(w) = X^T S X with S = diag(p_i(1-p_i)).
  • Convexity proof via positive semidefiniteness of the Hessian.
  • Explicit calculation of one gradient descent step with given numbers.

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

Q3

Name three distinct techniques to combat overfitting, explain when each one helps versus when it could hurt performance, and then design a cross-validation strategy to tune the L2 regularization strength lambda.

A/B Testing & ExperimentationTechnical Trade-offs
Author's notes

Went with regularization, early stopping, and data augmentation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly naming three distinct overfitting techniques (e.g., L2 regularization, dropout, early stopping) and for each, explain the mechanism, when it helps, and when it could hurt performance. Then, outline a cross-validation strategy for tuning lambda, emphasizing nested CV to avoid optimistic bias, and discuss practical considerations like computational cost and data size.

Pro tip: When discussing trade-offs, tie each technique to a concrete business scenario (e.g., high-dimensional sparse data vs. small datasets) to show you think beyond theory. For the CV strategy, mention that you'd use a separate validation set for early stopping if combined with other techniques, to avoid leakage.

1. Name and define three techniques

Choose three distinct methods such as L2 regularization, dropout, and early stopping. Briefly define each and its mechanism for reducing overfitting.

2. Explain when each helps

For each technique, describe scenarios where it is beneficial, e.g., L2 for high-dimensional data, dropout for deep neural networks, early stopping for iterative training.

3. Explain when each could hurt

Discuss potential downsides, such as L2 biasing coefficients too much, dropout increasing training time and variance, early stopping stopping too soon and missing better optima.

4. Design cross-validation strategy for lambda

Propose nested cross-validation: outer loop for performance estimation, inner loop for hyperparameter tuning. Specify k-fold (e.g., 5 or 10), stratification if needed, and how to handle computational constraints.

5. Address practical considerations

Mention how to scale the strategy (e.g., using random search or Bayesian optimization for lambda), and how to combine with other techniques without leakage.

Key Points to Mention

  • L2 regularization (weight decay) adds a penalty proportional to the square of coefficients, helping when features are correlated or numerous, but can underfit if lambda is too high.
  • Dropout randomly deactivates neurons during training, effective for deep networks with many parameters, but can increase training time and may not help with small datasets.
  • Early stopping halts training when validation error increases, useful for iterative methods like gradient descent, but can stop prematurely if validation noise is high.
  • Nested cross-validation: inner loop tunes lambda, outer loop evaluates performance, preventing optimistic bias from using the same data for tuning and evaluation.
  • Use k-fold CV with k=5 or 10, and consider stratified sampling for imbalanced classification.
  • For large datasets, use a single validation set or approximate CV to save computation; for small datasets, use leave-one-out or repeated k-fold.

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

Q4

Bootstrapping vs boosting: for bootstrapping, describe the percentile interval method for estimating uncertainty on a mean using the sample [2,3,5,7,11], show two example resamples with replacement and their means, and explain why this works without parametric assumptions. For boosting, explain the core idea and then manually run one AdaBoost iteration with three equally-weighted points where the weak learner misclassifies only the second point, computing epsilon, alpha, unnormalized weights, and the renormalized distribution.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Two-parter and it was a lot.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer in two clear parts: first, explain the percentile bootstrap interval for the mean, demonstrate with two resamples from the given sample, and justify its non-parametric nature. Second, describe boosting's core idea and manually compute one AdaBoost iteration with the given misclassification, showing all steps and calculations.

Pro tip: When explaining the percentile bootstrap, emphasize that it directly estimates the sampling distribution of the mean without assuming normality, which is crucial for small or skewed samples. For AdaBoost, double-check your arithmetic and clearly state each formula before plugging in numbers to avoid errors under pressure.

1. Explain percentile bootstrap interval

Describe the percentile method: resample with replacement many times, compute the mean for each resample, and take the 2.5th and 97.5th percentiles as the interval. Mention that this approximates the sampling distribution of the mean.

2. Provide two example resamples and means

Generate two resamples from [2,3,5,7,11] with replacement, compute their means, and show them as examples. For instance, Resample 1: [2,2,7,11,3] mean=5.0; Resample 2: [5,5,3,7,11] mean=6.2.

3. Explain why it works without parametric assumptions

Highlight that the bootstrap relies on the empirical distribution of the data, not on any assumed parametric form. By resampling, we mimic the process of drawing from the population, so the distribution of resample means approximates the true sampling distribution.

4. Describe boosting core idea

Explain that boosting sequentially combines weak learners, each focusing on the errors of the previous ones, to create a strong learner. Mention that it reduces bias and can achieve high accuracy.

5. Manually compute one AdaBoost iteration

With three equally weighted points and one misclassification, compute epsilon = 1/3, alpha = 0.5 * ln((1-epsilon)/epsilon) = 0.5 * ln(2) ≈ 0.3466. Update weights: misclassified point weight becomes (1/3)*exp(alpha) ≈ 0.473, others become (1/3)*exp(-alpha) ≈ 0.236. Sum = 0.945, renormalize to get distribution: [0.25, 0.50, 0.25].

Key Points to Mention

  • Bootstrap resampling with replacement and the empirical distribution
  • Percentile interval: 2.5th and 97.5th percentiles of resample means
  • No parametric assumptions: works for any statistic and distribution
  • Boosting: sequential ensemble, focuses on misclassified points
  • AdaBoost weight update formula: alpha = 0.5 * ln((1-epsilon)/epsilon)
  • Renormalization of weights to sum to 1

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

Q5

Compare bagging, boosting, and random forests across bias, variance, and sensitivity to noisy labels. Give a concrete scenario where you'd prefer each approach.

Technical Trade-offsData Modeling
Author's notes

Felt like the coolest question of the set because it's actually practical.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining each ensemble method briefly, then compare them across bias, variance, and noise sensitivity in a structured table-like format. Finally, provide a concrete scenario for each, ideally tied to real-world data science problems like fraud detection or customer churn. Emphasize the trade-offs and practical considerations for model selection.

Pro tip: Mention that random forests are often a strong baseline due to their robustness and minimal tuning, but boosting can outperform when carefully tuned and when the data is clean. Also, highlight that Amazon values scalability and production readiness, so discuss computational cost and ease of deployment.

1. Define the methods

Briefly explain bagging, boosting, and random forests: bagging trains models in parallel on bootstrapped samples; boosting trains sequentially, focusing on errors; random forests are bagging with decision trees and feature randomness.

2. Compare bias and variance

Bagging and random forests primarily reduce variance while keeping bias similar; boosting reduces bias but can increase variance if not regularized. Random forests further reduce variance due to feature randomness.

3. Analyze sensitivity to noisy labels

Bagging and random forests are robust to noisy labels because they average over many models; boosting is sensitive because it focuses on misclassified points, which may be noise, leading to overfitting.

4. Provide concrete scenarios

For bagging: high-variance models like unpruned decision trees on noisy data. For boosting: clean data where high accuracy is needed, e.g., click-through rate prediction. For random forests: general-purpose baseline with mixed data types and some noise.

5. Summarize trade-offs and practical considerations

Conclude with when to choose each: bagging for variance reduction, boosting for bias reduction with clean data, random forests for robustness and ease of use. Mention computational cost and tuning effort.

Key Points to Mention

  • Bagging reduces variance by averaging independent models trained on bootstrapped samples.
  • Boosting reduces bias by sequentially fitting models to residual errors, but can overfit noisy data.
  • Random forests add feature randomness to bagging, further reducing variance and decorrelating trees.
  • Boosting is sensitive to noisy labels because it upweights misclassified points, which may be noise.
  • Random forests are robust to noisy labels and require less tuning than boosting.
  • Concrete scenarios: bagging for high-variance models on noisy data; boosting for clean data with complex patterns; random forests for general-purpose robust modeling.

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