← Amazon Interview Insights

Amazon·Data Scientist·Technical Phone Screen·Senior

Senior
May 2026

Summary

Brutal technical screen for a DS role at Amazon. One massive multi-part question covering basically every angle of tree-based models you can think of, from hyperparameter tuning to latency budgets to SHAP pitfalls. No outcome info available.

Questions Asked (7)

Q1

Given a binary classification problem with 1M rows, 200 features, 20% missing values, severe class imbalance (1:50), label noise, and a 20ms inference latency constraint, would you choose a Random Forest or Gradient-Boosted Trees model for production? Justify using bias-variance trade-offs, noise robustness, interaction modeling, and behavior under correlated features, and name the key risks.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

This is the kind of question where you think you know the answer immediately (GBT, obviously) and then spend the next five minutes talking yourself into a corner.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by acknowledging that the choice depends on the specific trade-offs, then systematically compare Random Forest and Gradient-Boosted Trees across the four dimensions: bias-variance, noise robustness, interaction modeling, and correlated features. Conclude with a recommendation (likely GBT for performance but with caveats) and highlight key risks like latency and label noise.

Pro tip: Mention that while GBT often wins on accuracy, the 20ms latency constraint might favor optimized implementations like LightGBM or XGBoost with histogram-based methods, and that you would consider techniques like feature hashing or model compression to meet the constraint.

1. Clarify the problem and constraints

Restate the key constraints: 1M rows, 200 features, 20% missing values, 1:50 class imbalance, label noise, and 20ms inference latency. Emphasize that latency is a hard constraint that may eliminate some models or require optimization.

2. Compare bias-variance trade-offs

Discuss that Random Forest reduces variance by averaging deep trees, while GBT reduces bias by sequentially fitting residuals. For large data, GBT can achieve lower bias and often better accuracy, but may overfit if not regularized.

3. Evaluate noise robustness and interaction modeling

Random Forest is more robust to label noise due to bagging and feature subsampling, while GBT can overfit noise unless regularized. Both model interactions, but GBT can capture higher-order interactions more effectively with enough depth.

4. Assess behavior under correlated features and missing values

Random Forest handles correlated features well by random feature selection, while GBT may be more sensitive but can still perform well with regularization. Both can handle missing values natively (e.g., XGBoost, LightGBM).

5. Make a recommendation and name risks

Recommend GBT (e.g., LightGBM) for its superior accuracy and ability to handle interactions, but note risks: latency (mitigate with optimized inference), overfitting to noise (use regularization, early stopping), and class imbalance (use scale_pos_weight or focal loss).

Key Points to Mention

  • Bias-variance: GBT reduces bias, RF reduces variance; GBT often wins on large data but risks overfitting.
  • Noise robustness: RF is more robust to label noise; GBT requires regularization (e.g., learning rate, subsampling).
  • Interaction modeling: GBT captures complex interactions better; RF can too but may need deeper trees.
  • Correlated features: RF handles better via random feature selection; GBT may be more sensitive but can be regularized.
  • Latency: 20ms constraint may favor optimized GBT implementations (LightGBM) or require model compression.
  • Class imbalance: Use techniques like scale_pos_weight, focal loss, or resampling; both models can handle with adjustments.

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

Q2

What concrete starting hyperparameters and tuning ranges would you use for both Random Forest and Gradient-Boosted Trees in this scenario? Walk through how each parameter affects bias, variance, and inference latency.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Went through the GBT side pretty confidently: learning rate around 0.05, cap n_estimators with early stopping, num_leaves over max_depth for LightGBM, subsample and colsample for regularization.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the scenario's constraints (dataset size, feature dimensionality, latency budget, and accuracy target) to ground your hyperparameter choices. Then present concrete starting values and tuning ranges for Random Forest and Gradient-Boosted Trees, explaining how each parameter influences bias, variance, and inference latency. Emphasize the trade-offs and how you would iterate based on validation performance and production requirements.

Pro tip: Tie every hyperparameter recommendation to a measurable business or engineering constraint (e.g., 'we need p99 latency under 50ms, so we cap n_estimators and max_depth'). This shows you optimize for production impact, not just model accuracy.

1. Clarify the scenario and constraints

Ask about dataset size, feature count, class balance, latency SLA, and available compute. This determines whether you prioritize accuracy or inference speed.

2. Random Forest: starting hyperparameters and tuning ranges

Propose n_estimators=100–500, max_depth=10–30 (or None with min_samples_leaf), max_features='sqrt' or 0.3–0.5, min_samples_leaf=1–5, and bootstrap=True. Explain how increasing trees reduces variance but raises latency, while depth and leaf size control bias-variance and memory.

3. Gradient-Boosted Trees: starting hyperparameters and tuning ranges

Suggest learning_rate=0.05–0.1, n_estimators=100–1000 (with early stopping), max_depth=3–8, subsample=0.7–1.0, colsample_bytree=0.7–1.0, and min_child_weight=1–10. Note that lower learning rate requires more trees (higher latency) but often better accuracy.

4. Explain parameter effects on bias, variance, and latency

For each key parameter, describe whether it primarily reduces bias (e.g., more depth, more trees in GBT) or variance (e.g., more trees in RF, subsampling), and how it impacts inference time (e.g., more trees/depth increases latency).

5. Propose a tuning strategy and production considerations

Outline a search strategy (random/grid/Bayesian) with cross-validation, then discuss how to compress models (pruning, quantization) or use early stopping to meet latency budgets.

Key Points to Mention

  • Random Forest: n_estimators, max_depth, max_features, min_samples_leaf, bootstrap
  • Gradient-Boosted Trees: learning_rate, n_estimators, max_depth, subsample, colsample_bytree, min_child_weight
  • Bias-variance trade-off: deeper trees and more boosting rounds reduce bias but increase variance; more trees in RF reduce variance
  • Inference latency: scales with number of trees and depth; GBT with many shallow trees can be slower than RF with fewer deep trees
  • Early stopping and regularization (e.g., learning rate, subsample) to prevent overfitting and control model size
  • Production constraints: latency SLA, memory footprint, and retraining frequency influence hyperparameter choices

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

Q3

How would you encode the categorical features, including high-cardinality ones with over 1,000 unique values, while preventing target leakage and keeping inference within the latency budget?

Data ModelingTechnical Trade-offs
Author's notes

Target encoding with out-of-fold estimation was my answer and I think that was right.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem context: the model type, the cardinality of categorical features, and the latency constraints. Then, propose a hybrid encoding strategy that balances performance and efficiency, such as target encoding with cross-validation for high-cardinality features and one-hot encoding for low-cardinality ones. Emphasize leakage prevention through proper validation and discuss latency considerations like precomputed encodings and efficient data structures.

Pro tip: Demonstrate awareness of Amazon's scale by mentioning that for high-cardinality features, you might use hashing or frequency encoding as a fallback if target encoding proves too slow or risky. Also, highlight the importance of monitoring encoding drift in production.

1. Clarify requirements and constraints

Ask about the model type (e.g., linear vs. tree-based), the number of categorical features, their cardinalities, and the specific latency budget. This ensures your solution is tailored to the actual needs.

2. Choose encoding methods by cardinality

For low-cardinality features, use one-hot encoding; for high-cardinality features, consider target encoding, frequency encoding, or hashing. Explain the trade-offs of each in terms of performance and latency.

3. Prevent target leakage

Use out-of-fold target encoding (e.g., K-fold cross-validation) to compute encodings, and ensure that the encoding is computed only on training data and applied to validation/test data. Mention smoothing to handle rare categories.

4. Optimize for inference latency

Precompute encodings and store them in a lookup table (e.g., a hash map) for fast retrieval. For hashing, use a fixed-size vector to bound memory and computation. Consider model simplification if latency is critical.

5. Validate and monitor

Evaluate the impact of encoding on model performance and latency through offline experiments and online A/B tests. Set up monitoring for encoding drift and fallback strategies for unseen categories.

Key Points to Mention

  • Target encoding with cross-validation to prevent leakage
  • Smoothing techniques for target encoding to handle rare categories
  • Hashing trick for high-cardinality features to bound dimensionality
  • Frequency encoding as a leakage-free alternative
  • Precomputed lookup tables for low-latency inference
  • Trade-offs between model complexity, latency, and performance

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

Q4

With a 1:50 class imbalance, how do you handle it across training, metric selection, threshold setting, and probability calibration?

Product Analytics & MetricsTechnical Trade-offs
Author's notes

PR-AUC over ROC-AUC for this imbalance ratio, scale_pos_weight for GBT, class_weight for RF.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer around the ML lifecycle: training, metric selection, threshold setting, and calibration. Emphasize that each stage requires different techniques and that the business objective (e.g., cost of false positives vs. false negatives) should drive decisions. Highlight trade-offs and validation strategies.

Pro tip: Always tie your approach back to the business metric—e.g., expected cost or profit—and show how you'd validate improvements with a holdout set or A/B test. This demonstrates product thinking and avoids over-engineering.

1. Training: Address imbalance

Use techniques like class weighting, resampling (oversample minority, undersample majority), or synthetic data generation (SMOTE) to prevent the model from ignoring the minority class. Consider algorithmic approaches like focal loss or ensemble methods.

2. Metric selection: Choose appropriate metrics

Avoid accuracy; use precision-recall AUC, F1, or Matthews correlation coefficient. Align with business costs by defining a custom metric if needed.

3. Threshold setting: Optimize for business objective

Tune the decision threshold on a validation set to maximize the business metric (e.g., profit). Use cost-sensitive analysis to find the optimal threshold.

4. Probability calibration: Ensure reliable probabilities

Apply calibration methods like Platt scaling or isotonic regression if the model's probabilities are used for ranking or decision-making. Validate with reliability diagrams and Brier score.

5. Validation and iteration

Use stratified cross-validation and monitor performance on holdout data. Iterate on the pipeline as needed, ensuring no data leakage.

Key Points to Mention

  • Class weighting and resampling techniques (SMOTE, undersampling)
  • Precision-Recall AUC and F1 score over accuracy
  • Cost-sensitive threshold optimization
  • Platt scaling and isotonic regression for calibration
  • Stratified cross-validation and holdout validation
  • Business metric alignment (e.g., expected cost/profit)

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

Q5

Lay out a full 60-minute experiment plan covering data splits, preprocessing, hyperparameter tuning schedule, and leakage detection guardrails. Include a fallback if training runs over time.

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

This one I actually felt decent about.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer as a timed plan with clear phases: data splitting, preprocessing, tuning, and validation. Emphasize leakage detection at each step and include a concrete fallback strategy for time overruns. Show awareness of Amazon's scale and bias for action by prioritizing a working baseline early.

Pro tip: Mention that you would set a hard timebox for each phase and use early stopping or a reduced search space if time is tight, ensuring you always have a deployable model. This demonstrates pragmatism and risk management.

1. Data Splitting and Preprocessing

Allocate 60-70% for training, 15-20% for validation, and 15-20% for test, ensuring temporal or group splits to prevent leakage. Perform preprocessing (e.g., scaling, encoding) within a pipeline fitted only on training data.

2. Hyperparameter Tuning Schedule

Use a random search or Bayesian optimization with a time budget of 20-30 minutes, leveraging early stopping and parallel trials. Start with a small search space and expand if time permits.

3. Leakage Detection Guardrails

Implement checks such as verifying no overlap between train and validation/test sets, monitoring for target leakage via feature importance, and using cross-validation with grouped splits. Log any anomalies.

4. Fallback Strategy for Time Overruns

If tuning exceeds the time limit, fall back to a default model (e.g., logistic regression or a simple tree) trained on the baseline features. Alternatively, reduce the search space or use a pre-trained model.

5. Final Validation and Reporting

Evaluate the best model on the held-out test set, report metrics with confidence intervals, and document the experiment plan and any deviations. Ensure reproducibility.

Key Points to Mention

  • Use of stratified or temporal splits to avoid data leakage
  • Pipeline-based preprocessing to prevent fit on validation/test data
  • Time-boxed hyperparameter tuning with early stopping
  • Leakage detection via feature importance and correlation checks
  • Fallback to a simple model or reduced search space if time runs out
  • Documentation of the experiment and reproducibility

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

Q6

In what scenarios would Random Forest outperform Gradient-Boosted Trees for this dataset, and vice versa? Factor in missing value handling, monotonic constraints, correlated features, and distribution shift.

Technical Trade-offsAdaptability & Ambiguity
Author's notes

RF wins under heavy distribution shift and when you need stability fast with minimal tuning.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer by comparing Random Forest and Gradient-Boosted Trees across the four specified dimensions: missing value handling, monotonic constraints, correlated features, and distribution shift. For each dimension, explain when one model outperforms the other, and tie it back to the dataset characteristics and business context. Conclude with a practical recommendation on how to choose or combine models.

Pro tip: Emphasize that the choice depends on the specific trade-offs in your dataset and that you would validate with cross-validation and possibly ensemble both models. Mention that Amazon values scalable, production-ready solutions, so consider computational efficiency and maintainability.

1. Missing Value Handling

Discuss how Random Forest can handle missing values natively (e.g., surrogate splits) while Gradient-Boosted Trees often require imputation. Highlight that if missingness is informative, RF might capture it better, but GBT with proper imputation can also perform well.

2. Monotonic Constraints

Explain that Gradient-Boosted Trees support monotonic constraints, which are useful when domain knowledge dictates a monotonic relationship between features and target. Random Forest does not natively support this, so GBT is preferable when such constraints are important.

3. Correlated Features

Compare how both models handle correlated features. Random Forest is more robust due to feature bagging, while GBT can overfit if correlations are not handled. However, GBT with regularization can also manage correlations well.

4. Distribution Shift

Analyze performance under distribution shift. Random Forest may be more stable due to averaging, while GBT can adapt better if retrained but may be more sensitive to shift. Discuss techniques like importance weighting or domain adaptation.

5. Overall Recommendation

Synthesize the trade-offs and recommend a model based on the dataset's specific characteristics, possibly suggesting an ensemble or a test to decide. Mention that empirical evaluation is key.

Key Points to Mention

  • Random Forest's native missing value handling via surrogate splits vs. GBT's need for imputation.
  • Gradient-Boosted Trees' support for monotonic constraints and its importance in regulated or domain-driven scenarios.
  • Random Forest's robustness to correlated features due to bagging and random feature selection.
  • GBT's potential for higher accuracy but sensitivity to hyperparameters and overfitting with correlated features.
  • Random Forest's stability under distribution shift vs. GBT's adaptability when retrained.
  • The importance of empirical validation and considering computational resources and scalability.

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

Q7

How would you generate and validate feature importances, run partial dependence and ICE analyses, and apply SHAP, while accounting for pitfalls from correlated features and potential leakage? Also, how do you ensure the model meets the 20ms per-example latency requirement at inference?

Technical Trade-offsSystem Design
Author's notes

Permutation importance over gain-based importance under correlation, that part I knew cold.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by outlining a robust pipeline for feature importance and interpretation that includes correlation checks, leakage detection, and model-agnostic methods like SHAP and partial dependence. Then, address the latency requirement by discussing model optimization techniques and infrastructure choices. Emphasize the trade-offs between interpretability and performance, and how you would validate both.

Pro tip: Mention that you would use SHAP's TreeExplainer for tree-based models due to its efficiency, and for correlated features, you would cluster features and compute importance at the cluster level to avoid misleading attributions. Also, for latency, consider model quantization or distillation, and always benchmark with realistic data.

1. Data and Model Preparation

Ensure data quality by checking for leakage (e.g., temporal leakage, target leakage) and handling correlated features via clustering or regularization. Train a baseline model and evaluate its performance.

2. Feature Importance and Interpretation

Compute feature importances using permutation importance and SHAP values, being mindful of correlations. Use partial dependence and ICE plots to understand feature effects, and validate findings with domain knowledge.

3. Addressing Pitfalls

For correlated features, use grouped importance or SHAP interaction values. For leakage, perform rigorous validation (e.g., time-based splits) and check for suspiciously high importance of certain features.

4. Latency Optimization

Optimize model for 20ms latency by selecting efficient algorithms (e.g., LightGBM), reducing feature dimensionality, and using techniques like quantization or pruning. Deploy with optimized inference engines (e.g., ONNX Runtime) and monitor latency.

5. Validation and Monitoring

Validate interpretability and latency through offline benchmarks and online A/B tests. Set up monitoring for model drift and latency violations, and iterate as needed.

Key Points to Mention

  • Permutation importance vs. SHAP: trade-offs and when to use each
  • Handling correlated features: clustering, grouping, or using SHAP interaction values
  • Detecting and preventing leakage: temporal validation, feature auditing
  • Partial dependence and ICE: interpretation and limitations with correlated features
  • Latency optimization techniques: model selection, quantization, pruning, hardware acceleration
  • Benchmarking and monitoring: realistic data, end-to-end latency, production constraints

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