← Amazon Interview Insights

Amazon·Data Scientist·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Amazon DS interview that was basically a two-hour SQL and causal inference gauntlet. The main question was a massive difference-in-differences setup with household spillover exclusions, propensity score matching, and a Python component all baked into one prompt. Not a casual screen.

Questions Asked (3)

Q1

Given a schema with users, reminders, CSAT scores, and session data, write SQL to build a user-week panel for a difference-in-differences analysis around first reminder exposure. Requirements include defining each user's first reminder date as their treatment date, keeping only an 8-week window around that date, excluding users whose household has an earlier-treated member, and outputting weekly aggregates of CSAT, session minutes, and purchases alongside treatment indicators.

A/B Testing & ExperimentationData ModelingProduct Analytics & Metrics
Author's notes

This was the bulk of the interview.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and assumptions, then outline a step-by-step SQL plan that builds the user-week panel. Emphasize the importance of correctly defining treatment timing, applying the exclusion criteria, and aggregating metrics at the user-week level while maintaining the panel structure for difference-in-differences analysis.

Pro tip: Mention that you would validate the panel by checking for balanced pre/post periods and ensuring no spillover effects from excluded households. Also, consider using window functions to efficiently compute first reminder dates and household-level exclusions.

1. Understand the schema and define treatment

Identify the tables and columns needed: users, reminders, CSAT scores, session data, and purchases. Define the treatment date as each user's first reminder date using a MIN aggregation or window function.

2. Apply exclusion criteria

Exclude users whose household has an earlier-treated member. This requires joining users to households, finding the minimum first reminder date per household, and filtering out users whose own first reminder date is not the household minimum.

3. Create the 8-week window around treatment

For each treated user, generate a series of weeks from 4 weeks before to 3 weeks after the treatment date (or 8 weeks total). Use a date dimension or generate_series to create the weekly panel.

4. Aggregate weekly metrics

Join the weekly panel with CSAT, session, and purchase data, aggregating metrics per user per week. Ensure that weeks with no data are filled with zeros or nulls as appropriate.

5. Output the panel with treatment indicators

Include columns for user_id, week relative to treatment, treatment indicator (1 if post-treatment, 0 otherwise), and the aggregated metrics. This structure supports difference-in-differences analysis.

Key Points to Mention

  • Define treatment date as the first reminder date per user, using MIN() or ROW_NUMBER().
  • Exclude users from households with an earlier-treated member to avoid contamination.
  • Create a balanced panel with 8 weeks per user (e.g., -4 to +3 weeks relative to treatment).
  • Aggregate CSAT, session minutes, and purchases at the user-week level, handling missing data appropriately.
  • Include a treatment indicator (post vs. pre) and possibly a control group if available.
  • Use window functions and CTEs for efficient and readable SQL.

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

Q2

Using the user-week panel you built, write a query that computes group-level pre and post means for treated and control users, then derives the 2x2 difference-in-differences estimate.

A/B Testing & ExperimentationProduct Analytics & Metrics
Author's notes

Straightforward once the panel exists.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the panel structure and treatment/control assignment, then write a SQL query that aggregates user-week data into four cells (treated/control × pre/post) and computes the difference-in-differences. Emphasize that the DiD estimate is the interaction between time and treatment, and discuss assumptions like parallel trends.

Pro tip: Mention that you would check for pre-treatment parallel trends and consider clustering standard errors at the user level to account for repeated observations, which is crucial for valid inference in panel data.

1. Clarify data structure and assumptions

Confirm the user-week panel schema, treatment assignment, and pre/post period definitions. State the parallel trends assumption and that treatment is randomly assigned.

2. Aggregate to group-level means

Write a subquery or CTE that computes average outcome for each group (treated/control) and period (pre/post), yielding four mean values.

3. Compute the 2x2 DiD estimate

Calculate the difference in means for treated (post - pre), the difference for control (post - pre), and then subtract the control difference from the treated difference to get the DiD estimate.

4. Validate and interpret

Check that the query returns the expected four cells and that the DiD estimate aligns with manual calculation. Discuss statistical significance and potential confounders.

Key Points to Mention

  • Difference-in-differences formula: (Y_treated_post - Y_treated_pre) - (Y_control_post - Y_control_pre)
  • Parallel trends assumption and how to test it using pre-period data
  • Use of SQL aggregation functions (AVG, CASE WHEN) to create the 2x2 table
  • Clustering standard errors at the user level to handle repeated measures
  • Potential issues: unbalanced panels, missing data, and treatment effect heterogeneity
  • Interpretation of the DiD estimate as the causal effect of treatment under assumptions

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

Q3

In Python, outline code to estimate propensity scores using logistic regression on baseline covariates like device, country, and pre-period usage, then perform 1:1 nearest-neighbor matching with a caliper of 0.05 and report standardized mean differences before and after matching.

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

I defaulted to sklearn for the logit and wrote a manual nearest-neighbor loop, which felt clunky.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the problem: propensity scores estimate the probability of treatment given covariates, used to balance groups in observational studies. Then walk through the code steps: fit logistic regression, compute scores, perform 1:1 nearest-neighbor matching with a caliper, and assess balance via standardized mean differences (SMD) before and after. Emphasize validation of overlap and balance, and mention trade-offs like caliper choice and matching without replacement.

Pro tip: Always check the distribution of propensity scores and overlap before matching; if there's poor overlap, consider trimming or using alternative methods like IPTW. Also, report SMD for all covariates, not just the ones in the model, to ensure balance.

1. Fit propensity score model

Use logistic regression with treatment as outcome and baseline covariates (device, country, pre-period usage) as predictors. Encode categorical variables appropriately (e.g., one-hot encoding) and check for multicollinearity.

2. Compute propensity scores and assess overlap

Predict probabilities for all units. Plot histograms of scores for treated and control groups to check common support. Consider trimming if overlap is poor.

3. Perform 1:1 nearest-neighbor matching with caliper

For each treated unit, find the closest control unit in propensity score within a caliper of 0.05. Use matching without replacement to avoid reuse. Implement via libraries like `sklearn` or custom code.

4. Evaluate balance using standardized mean differences (SMD)

Calculate SMD for each covariate before and after matching. SMD = (mean_treated - mean_control) / pooled_std. Aim for SMD < 0.1 after matching to indicate good balance.

5. Report and interpret results

Present SMD before and after matching in a table or plot. Discuss any remaining imbalance and potential sensitivity analyses (e.g., different calipers, matching with replacement).

Key Points to Mention

  • Propensity score definition and purpose in causal inference
  • Logistic regression for binary treatment and covariate encoding
  • Caliper matching and its role in reducing bias
  • Standardized mean difference formula and threshold (e.g., <0.1)
  • Checking common support and overlap
  • Trade-offs: matching with/without replacement, caliper size, and sample size loss

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