← Amazon Interview Insights

Amazon·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jul 2026

Summary

Amazon ML Engineer interview, all technical fundamentals, no system design or behavioral that I can recall. It felt like a grad school exam more than a job interview, which I was not fully prepared for.

Questions Asked (7)

Q1

What is the bias-variance trade-off, and how do regularization techniques address it?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Bread and butter question but I still fumbled the explanation a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly defining bias and variance and the trade-off between them, then explain how regularization techniques like L1 and L2 penalize model complexity to reduce variance at the cost of slightly increased bias. Finally, connect this to practical model performance, emphasizing the goal of minimizing total error and improving generalization.

Pro tip: Mention that regularization is not a silver bullet—it requires tuning the regularization strength (e.g., lambda) via cross-validation, and different techniques (L1 vs. L2) have distinct effects on feature selection and weight shrinkage.

1. Define Bias and Variance

Explain bias as error from erroneous assumptions (underfitting) and variance as sensitivity to training data fluctuations (overfitting).

2. Describe the Trade-off

Discuss how increasing model complexity reduces bias but increases variance, and vice versa, leading to a U-shaped total error curve.

3. Introduce Regularization

Define regularization as adding a penalty term to the loss function to constrain model weights, thus controlling complexity.

4. Explain How Regularization Addresses the Trade-off

Detail how L1 (Lasso) promotes sparsity and L2 (Ridge) shrinks weights, both reducing variance and preventing overfitting, often at the cost of slightly higher bias.

5. Conclude with Practical Implications

Emphasize that the goal is to minimize total error, and regularization strength is tuned via cross-validation to achieve optimal bias-variance balance.

Key Points to Mention

  • Bias-variance decomposition of expected error
  • Underfitting vs. overfitting
  • L1 regularization (Lasso) and feature selection
  • L2 regularization (Ridge) and weight shrinkage
  • Elastic Net as a combination
  • Hyperparameter tuning (e.g., lambda) using cross-validation

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

Q2

Derive the gradient of the loss function for logistic regression when L2 regularization is applied.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one I actually liked.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the logistic regression model and the loss function with L2 regularization. Then derive the gradient step-by-step, clearly showing the chain rule application and the regularization term. Finally, present the simplified gradient expression and discuss its implications.

Pro tip: Emphasize that the L2 regularization term adds a linear penalty to the gradient, which shrinks weights and helps prevent overfitting. Mention that this is equivalent to a Gaussian prior in a Bayesian framework, showing deeper understanding.

1. Define the model and loss

State the logistic regression hypothesis: h_θ(x) = σ(θ^T x), where σ is the sigmoid function. Define the loss function with L2 regularization: J(θ) = -1/m Σ [y^(i) log(h_θ(x^(i))) + (1-y^(i)) log(1-h_θ(x^(i)))] + λ/(2m) Σ θ_j^2.

2. Compute gradient of unregularized loss

Derive the gradient of the log-loss with respect to θ. Use the chain rule and the fact that σ'(z) = σ(z)(1-σ(z)). Show that ∇_θ J_unreg = 1/m Σ (h_θ(x^(i)) - y^(i)) x^(i).

3. Add gradient of L2 regularization

Differentiate the L2 penalty term: ∇_θ (λ/(2m) Σ θ_j^2) = λ/m θ. Note that the bias term θ_0 is typically not regularized, so the gradient for θ_0 remains unchanged.

4. Combine and simplify

Combine the two gradients to get the final gradient: ∇_θ J(θ) = 1/m Σ (h_θ(x^(i)) - y^(i)) x^(i) + λ/m θ (with θ_0 excluded from regularization).

5. Discuss implications and trade-offs

Explain how the regularization term affects the update rule (e.g., weight decay) and the role of λ in controlling overfitting. Mention that this gradient is used in optimization algorithms like gradient descent.

Key Points to Mention

  • Logistic regression hypothesis and sigmoid function
  • Log-loss (cross-entropy) and its gradient derivation using chain rule
  • L2 regularization term and its gradient (λ/m θ)
  • Exclusion of bias term from regularization
  • Final gradient expression and its use in gradient descent
  • Effect of λ on model complexity and overfitting

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

Q3

Compare ROC-AUC and PR-AUC. When should you prefer one over the other?

Product Analytics & MetricsTechnical Trade-offs
Author's notes

Said PR-AUC is better for imbalanced classes because ROC can look deceptively good when negatives dominate.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining ROC-AUC and PR-AUC, highlighting their mathematical foundations and interpretation. Then compare their behavior under class imbalance and different evaluation goals, and conclude with clear guidelines on when to prefer each metric, ideally with examples.

Pro tip: Mention that PR-AUC is more informative when the positive class is rare and the cost of false positives is high, but also note that ROC-AUC can be misleading in such cases because it incorporates true negatives. This shows you understand the business context behind metric selection.

1. Define the metrics

Briefly explain that ROC-AUC plots TPR vs. FPR and measures the probability that a random positive is ranked higher than a random negative, while PR-AUC plots precision vs. recall and focuses on the positive class.

2. Discuss sensitivity to class imbalance

Explain that ROC-AUC can be overly optimistic when the negative class dominates because FPR can remain low even with many false positives, whereas PR-AUC directly reflects performance on the positive class and is more sensitive to changes in the positive class distribution.

3. Relate to evaluation goals and costs

Connect each metric to different objectives: ROC-AUC is suitable when both classes are equally important or when ranking overall is key; PR-AUC is preferable when the positive class is rare and the cost of false positives is high, such as in fraud detection or medical screening.

4. Provide practical guidelines

Summarize when to prefer each: use PR-AUC for imbalanced datasets where positive class performance is critical; use ROC-AUC for balanced datasets or when comparing models across different thresholds without focusing on a specific operating point.

5. Conclude with a balanced view

Emphasize that the choice depends on the problem context, and in practice, it's often useful to report both metrics along with other measures like precision@k or recall@k for a comprehensive evaluation.

Key Points to Mention

  • ROC-AUC is threshold-independent and measures the ability to distinguish between classes, but it can be misleading under severe class imbalance.
  • PR-AUC focuses on the positive class and is more informative when the positive class is rare and the cost of false positives is high.
  • The baseline for PR-AUC is the prevalence of the positive class, so it should be compared against that baseline, not 0.5.
  • ROC-AUC is invariant to class distribution changes, while PR-AUC is sensitive to them, which can affect model comparison across different datasets.
  • In imbalanced settings, a high ROC-AUC may not translate to good precision at high recall, which is often what matters in practice.
  • Amazon's business context (e.g., fraud detection, product recommendations) often involves imbalanced data, making PR-AUC a relevant choice.

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

Q4

How do you detect and prevent data leakage when doing cross-validation?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Talked about fitting scalers inside the fold, not outside.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining data leakage and its common sources in cross-validation, then explain detection methods such as monitoring performance gaps and using diagnostic checks. Finally, detail prevention strategies like proper data splitting, pipeline encapsulation, and temporal ordering, emphasizing how these apply in production ML systems.

Pro tip: Emphasize that leakage often occurs during feature engineering and hyperparameter tuning, and mention that using scikit-learn's Pipeline or Amazon SageMaker's built-in validation mechanisms can enforce separation. Also, highlight the importance of simulating production data flow to catch subtle leaks.

1. Define data leakage and its impact

Briefly explain what data leakage is and why it's critical in cross-validation, especially for model generalization and business metrics.

2. Identify common sources of leakage

List typical leakage sources such as preprocessing on full data, temporal dependencies, group structures, and target encoding without proper folds.

3. Detect leakage

Describe detection techniques: comparing CV scores to a hold-out set, checking for unusually high performance, and using adversarial validation or permutation tests.

4. Prevent leakage

Explain prevention methods: encapsulate all preprocessing within CV folds using pipelines, use time-series split for temporal data, group splits for clustered data, and nested CV for hyperparameter tuning.

5. Validate and monitor

Discuss post-deployment monitoring for leakage drift and the importance of continuous validation in production.

Key Points to Mention

  • Data leakage definition and its effect on model evaluation
  • Common leakage sources: preprocessing before splitting, temporal data, group leakage, target leakage
  • Detection techniques: performance gap analysis, adversarial validation, learning curves
  • Prevention: scikit-learn Pipeline, time-series split, group k-fold, nested cross-validation
  • Amazon-specific tools: SageMaker Processing, SageMaker Experiments, and built-in validation
  • Best practices: simulate production data flow, use hold-out set, and monitor post-deployment

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

Q5

What approaches exist for handling class imbalance, and how do they affect model calibration?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Listed oversampling, undersampling, class weights, and threshold tuning.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by categorizing the main approaches to handling class imbalance, such as data-level, algorithm-level, and hybrid methods. Then, for each category, explain how it affects model calibration, emphasizing that many techniques improve minority class recall but distort predicted probabilities. Finally, discuss mitigation strategies like calibration adjustments or choosing methods that preserve calibration.

Pro tip: Mention that calibration should be evaluated using proper scoring rules like Brier score or log loss, and that in production, you might need to recalibrate after resampling. Also, note that some methods like class weighting can be seen as a form of cost-sensitive learning and may not require explicit calibration if the goal is ranking.

1. Categorize imbalance handling approaches

Briefly list the main categories: data-level (resampling), algorithm-level (cost-sensitive), and hybrid. This sets the stage for discussing calibration effects.

2. Explain data-level methods and their calibration impact

Discuss oversampling (e.g., SMOTE) and undersampling. Explain that these methods change the prior distribution, leading to biased probability estimates that are often overconfident for the minority class.

3. Explain algorithm-level methods and their calibration impact

Cover class weighting, threshold moving, and specialized loss functions. Note that these can also distort probabilities, but some (like weighting) may preserve ranking while shifting calibration.

4. Discuss calibration evaluation and mitigation

Describe how to measure calibration (reliability diagrams, Brier score) and techniques to fix it (Platt scaling, isotonic regression, or adjusting class priors).

5. Conclude with practical recommendations

Summarize that the choice depends on the goal: if probabilities are needed, prefer methods that preserve calibration or apply post-hoc calibration; if only ranking matters, calibration may be less critical.

Key Points to Mention

  • Resampling methods (oversampling, undersampling, SMOTE) alter class priors and typically lead to miscalibration.
  • Class weighting and cost-sensitive learning can improve minority class performance but may require calibration adjustments.
  • Calibration metrics: reliability diagrams, Brier score, expected calibration error (ECE).
  • Post-hoc calibration methods: Platt scaling, isotonic regression, histogram binning.
  • Trade-off between discrimination (AUC) and calibration; some methods improve one at the expense of the other.
  • In practice, always validate calibration on a held-out set that reflects the true deployment distribution.

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

Q6

In what situations would you choose a tree-based model over a linear model?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Non-linear relationships, feature interactions, mixed data types, robustness to outliers.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by acknowledging that the choice depends on the data characteristics and problem requirements, then contrast when tree-based models excel (non-linear relationships, mixed data types, feature interactions) versus when linear models are preferable (linear relationships, interpretability, high-dimensional sparse data). Conclude with a practical example or trade-off consideration to show balanced judgment.

Pro tip: Mention that at Amazon, where scalability and interpretability often matter, you'd consider not just raw performance but also inference latency, model explainability, and maintenance cost—showing you think like an engineer, not just a data scientist.

1. Clarify the decision criteria

State that the choice depends on data nature (linear vs non-linear), feature types, dataset size, interpretability needs, and computational constraints.

2. When to choose tree-based models

Explain scenarios like non-linear relationships, complex feature interactions, mixed numerical/categorical data, and robustness to outliers without extensive preprocessing.

3. When to choose linear models

Highlight cases with linear relationships, high-dimensional sparse data (e.g., text), need for interpretability, and when computational efficiency is critical.

4. Consider trade-offs and hybrid approaches

Discuss trade-offs in interpretability, training time, and performance; mention that sometimes a linear model with feature engineering or a hybrid can be best.

5. Tie to business context

Relate the choice to business needs like explainability for stakeholders, latency requirements, or the cost of errors, especially in a company like Amazon.

Key Points to Mention

  • Non-linear relationships and feature interactions
  • Mixed data types and missing values handling
  • Interpretability and explainability requirements
  • High-dimensional sparse data (e.g., text classification)
  • Computational efficiency and scalability
  • Robustness to outliers and feature scaling

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

Q7

How do you evaluate whether a model is well-calibrated, and what can you do to improve calibration?

Product Analytics & MetricsTechnical Trade-offs
Author's notes

Reliability diagrams and Brier score came to mind first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining calibration as the alignment between predicted probabilities and observed frequencies, then describe both visual and quantitative evaluation methods. Next, discuss practical techniques to improve calibration, emphasizing trade-offs and when to apply them. Finally, tie your answer to business impact, such as decision-making thresholds and cost-sensitive applications.

Pro tip: Mention that calibration should be evaluated on a held-out validation set and that improving calibration can sometimes hurt discrimination (e.g., AUC), so it's a trade-off to manage based on the application.

1. Define Calibration

Explain that a well-calibrated model produces predicted probabilities that reflect true likelihoods (e.g., among predictions with 0.8 confidence, ~80% should be correct).

2. Evaluate Calibration

Describe methods: reliability diagrams (calibration curves), Expected Calibration Error (ECE), Maximum Calibration Error (MCE), and proper scoring rules like Brier score or log loss.

3. Identify Miscalibration Causes

Discuss common causes: model overconfidence (e.g., deep neural networks), class imbalance, distribution shift, or using accuracy-based loss instead of proper scoring rules.

4. Apply Calibration Techniques

List post-hoc methods: Platt scaling (sigmoid), isotonic regression, temperature scaling (for neural networks), and Bayesian binning into quantiles. Mention that these require a calibration set.

5. Assess Trade-offs and Business Impact

Explain that calibration may affect ranking metrics (e.g., AUC) and that the choice depends on whether the application needs reliable probabilities (e.g., risk scoring) or just ranking.

Key Points to Mention

  • Reliability diagram and Expected Calibration Error (ECE) as standard evaluation tools
  • Platt scaling and isotonic regression as post-hoc calibration methods
  • Temperature scaling for neural networks, especially in deep learning
  • The need for a separate calibration set to avoid overfitting
  • Trade-off between calibration and discrimination (e.g., AUC may decrease)
  • Business impact: calibrated probabilities enable better decision thresholds and cost-sensitive actions

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