← Google Interview Insights

Google·Data Scientist·Onsite - System Design / Architecture·Senior

Senior
Jun 2026

Summary

A Google data scientist interview that was basically one massive ML system design question covering the full lifecycle of a purchase prediction model. Dense, technical, and they clearly wanted to see if you could hold all the moving parts in your head at once.

Questions Asked (8)

Q1

Design an end-to-end pipeline to predict (1) whether a user will spend anything in the next 7 days and (2) how much they'll spend, using event and order data up to a fixed cutoff date.

System DesignTechnical Trade-offsData Modeling
Author's notes

This is a two-headed model problem and I kept wanting to collapse it into one, which was the wrong instinct.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer as a two-stage system: first a binary classifier for spend propensity, then a regressor for spend amount, both using features engineered from event and order data up to the cutoff. Emphasize temporal validation, feature consistency, and business alignment (e.g., expected value = P(spend) * E[amount]).

Pro tip: Mention that you would use a two-part model (hurdle model) to handle zero-inflation and avoid predicting negative spend, and that you'd validate with a time-based split to mimic production.

1. Clarify Requirements and Define Success

Confirm the prediction horizon (7 days), cutoff date, and business use case (e.g., targeting, budgeting). Define success metrics: AUC/PR-AUC for classification, MAE/RMSE for regression, and possibly expected calibration error.

2. Data Collection and Feature Engineering

Use event and order data up to the cutoff. Create user-level features: recency, frequency, monetary (RFM), session counts, product views, cart adds, past spend trends, and time since last purchase. Ensure all features are computed only from data before the cutoff to avoid leakage.

3. Modeling Approach

Train a binary classifier (e.g., logistic regression, GBM) for spend propensity, and a regressor (e.g., linear regression, GBM) for spend amount among spenders. Consider a two-part model or multi-task learning. Handle class imbalance and zero-inflation.

4. Validation and Evaluation

Use time-based validation (e.g., train on earlier data, validate on later data before cutoff). Evaluate classification with AUC/PR-AUC and calibration; evaluate regression with MAE/RMSE on positive spenders. Also assess combined expected value.

5. Deployment and Monitoring

Deploy as a batch or real-time pipeline. Monitor feature drift, prediction drift, and model performance over time. Set up retraining cadence and A/B testing for business impact.

Key Points to Mention

  • Temporal validation to prevent data leakage and mimic production
  • Feature engineering from event and order data (RFM, behavioral signals)
  • Handling class imbalance and zero-inflated spend amounts
  • Two-part model (hurdle model) for propensity and amount
  • Business metric: expected spend = P(spend) * E[amount | spend]
  • Monitoring and retraining strategy for deployed model

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

Q2

How do you prevent data leakage given a training cutoff of 2025-08-31, and what are two concrete features that seem predictive but are actually leaky, and how would you fix them?

Data ModelingTechnical Trade-offsProduct Analytics & Metrics
Author's notes

The refund_time example was basically handed to us in the prompt, so I used it but also came up with a second one: last_session_duration computed from a session that started before cutoff but ended after.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining data leakage and its impact on model validity, then outline a systematic prevention strategy that includes temporal validation, feature auditing, and pipeline safeguards. Emphasize the importance of aligning all data processing with the training cutoff date and provide two concrete examples of leaky features with clear fixes. Conclude by discussing how to monitor and maintain leakage prevention in production.

Pro tip: Demonstrate awareness that leakage often stems from subtle data dependencies, such as using future data in aggregations or target encoding. Mention that automated tools like feature stores with point-in-time correctness can help enforce temporal integrity.

1. Define Data Leakage and Its Risks

Explain what data leakage is and why it's critical to prevent, especially with a training cutoff. Highlight how leakage leads to overly optimistic performance and poor generalization.

2. Prevention Strategies

Describe methods to prevent leakage, such as strict temporal splits, using only data available before the cutoff, and implementing point-in-time correctness in feature engineering.

3. Identify Leaky Features

Provide two concrete examples of features that seem predictive but are leaky. For each, explain why it's leaky and how to fix it.

4. Implement Fixes and Validate

Detail the fixes for the leaky features, such as recomputing features using only past data or removing them. Emphasize validation using temporal cross-validation.

5. Monitor and Maintain

Discuss ongoing monitoring to detect leakage in production, such as tracking feature distributions and performance over time, and establishing a culture of leakage awareness.

Key Points to Mention

  • Temporal validation: use time-based splits and ensure all features are computed only from data prior to the cutoff.
  • Point-in-time correctness: when joining data, ensure that only information available at the time of prediction is used.
  • Example leaky feature 1: 'future purchase count' – using the number of purchases a user makes after the cutoff to predict churn; fix by using only historical purchase counts.
  • Example leaky feature 2: 'target encoding computed on full data' – encoding categorical variables using the target mean over the entire dataset; fix by computing encoding within each training fold or using only past data.
  • Automated safeguards: use feature stores with time-travel capabilities, and implement data versioning and lineage tracking.
  • Monitoring: set up alerts for sudden performance drops or feature drift that may indicate leakage.

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

Q3

Walk through your time-based cross-validation strategy for this problem. Why not use standard k-fold?

Technical Trade-offsA/B Testing & Experimentation
Author's notes

Standard k-fold leaks future into past, full stop.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining why standard k-fold fails for time-dependent data—it leaks future information into training. Then describe your time-based cross-validation strategy, such as expanding window or sliding window, and justify your choice based on the problem's temporal structure and business constraints. Finally, discuss how you evaluate and compare models using this approach.

Pro tip: Mention that you also consider the gap between train and validation sets to mimic real-world forecasting delay, and that you validate the CV strategy itself by checking for temporal leakage and stability of performance across folds.

1. Explain why standard k-fold is inappropriate

Highlight that random k-fold shuffles data, causing temporal leakage where future data informs past predictions, leading to overly optimistic performance estimates.

2. Describe your time-based CV strategy

Outline either expanding window (train on all past data, validate on next period) or sliding window (fixed-size training window), and explain how you choose based on data volume and concept drift.

3. Justify the choice with problem specifics

Connect the strategy to the problem's temporal granularity, seasonality, and business cycle, and mention any gap between train and validation to simulate deployment latency.

4. Discuss evaluation and model selection

Explain how you aggregate performance metrics across folds (e.g., mean and variance) and use them to select models, ensuring the CV setup mirrors the final test scenario.

5. Address potential pitfalls and validation

Mention checks for temporal leakage, such as ensuring no future data in features, and validating that performance is stable across folds to avoid overfitting to a particular time period.

Key Points to Mention

  • Temporal leakage and why it invalidates standard k-fold
  • Expanding window vs. sliding window cross-validation
  • The importance of a gap between training and validation sets
  • How to handle seasonality and concept drift in time series
  • Aggregating metrics across folds and assessing variance
  • Ensuring the CV strategy mimics the real-world deployment scenario

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

Q4

How would you handle class imbalance in the classification task, and what metrics would you use for each of the two tasks?

Product Analytics & MetricsTechnical Trade-offs
Author's notes

Went with PR-AUC for classification since the positive class is rare and ROC-AUC flatters you on imbalanced data.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the two tasks (e.g., binary vs. multiclass or detection vs. ranking) and the business context, then discuss class imbalance handling techniques and appropriate metrics for each. Emphasize that the choice of technique and metric depends on the specific task, data, and business objective, and that you would validate with cross-validation and possibly adjust decision thresholds.

Pro tip: Avoid defaulting to accuracy or oversampling without justification; instead, tie your metric choice to the business cost of false positives vs. false negatives, and mention that you would monitor both offline and online metrics post-deployment.

1. Clarify the tasks and context

Ask clarifying questions to understand the two classification tasks, their business objectives, and the nature of the imbalance (e.g., ratio, class definitions).

2. Discuss imbalance handling techniques

Explain methods like resampling (oversampling/undersampling), synthetic data generation (SMOTE), class weighting, and algorithmic adjustments (e.g., focal loss), noting pros and cons for each task.

3. Select evaluation metrics per task

For each task, choose metrics that align with business goals: e.g., for rare event detection, use precision-recall AUC, F1, or recall at fixed precision; for balanced tasks, accuracy or ROC-AUC may suffice.

4. Validate and iterate

Describe how you would validate the approach using stratified cross-validation, and how you might adjust decision thresholds or reweight classes based on validation results.

5. Monitor and refine in production

Mention the importance of monitoring model performance over time, especially if class distributions shift, and retraining or adjusting as needed.

Key Points to Mention

  • Resampling techniques: oversampling, undersampling, SMOTE
  • Class weighting and algorithmic approaches (e.g., focal loss, cost-sensitive learning)
  • Metrics for imbalanced tasks: precision, recall, F1, PR-AUC, ROC-AUC, Matthews correlation coefficient
  • Business context: cost of false positives vs. false negatives
  • Threshold tuning and calibration
  • Stratified cross-validation and monitoring for data drift

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

Q5

Given an asymmetric cost matrix where false negatives are more expensive than false positives, how do you pick a classification threshold?

Technical Trade-offsProduct Analytics & Metrics
Author's notes

You optimize the threshold on your validation set by sweeping it and computing expected cost under the asymmetric matrix, not by maximizing F1 or accuracy.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the expected cost as a function of the threshold, incorporating the asymmetric costs of false positives and false negatives. Then, explain how to minimize this expected cost using the model's predicted probabilities and the known cost ratio. Finally, discuss practical considerations like calibration and validation.

Pro tip: Mention that the optimal threshold depends only on the cost ratio and the model's calibration, not on the class balance. Also, suggest using a cost-sensitive validation curve to select the threshold empirically.

1. Define the cost structure

Clarify the costs: let C_FN be the cost of a false negative and C_FP be the cost of a false positive. Typically, C_FN > C_FP in this scenario.

2. Formulate expected cost

For a given threshold t, the expected cost is E[Cost] = C_FN * P(FN | t) + C_FP * P(FP | t). Express these probabilities in terms of the model's predicted probabilities and the threshold.

3. Derive optimal threshold

Minimize the expected cost by setting the derivative to zero, leading to the condition: predict positive if P(y=1|x) > C_FP / (C_FP + C_FN). This is the optimal threshold.

4. Validate and adjust

Use a validation set to compute the expected cost for different thresholds and confirm the theoretical threshold. Adjust for model calibration if necessary.

Key Points to Mention

  • The optimal threshold is C_FP / (C_FP + C_FN) when costs are asymmetric.
  • This threshold minimizes the expected cost, not accuracy.
  • Model calibration is crucial: predicted probabilities should reflect true likelihoods.
  • The threshold is independent of class balance; it depends only on the cost ratio.
  • Use a cost-sensitive validation curve to empirically verify the threshold.
  • In practice, consider business constraints and uncertainty in cost estimates.

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

Q6

How would you detect and fix segment-specific regressions after model deployment, for example if the model degrades for a particular user cohort?

Root Cause AnalysisA/B Testing & ExperimentationProduct Analytics & Metrics
Author's notes

Blanked for a second here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by describing a systematic monitoring system that tracks model performance across predefined user segments, using statistical tests to detect significant deviations. Then outline a root cause analysis process to identify why the regression occurred, and finally propose targeted fixes such as retraining with segment-specific data or adjusting the model architecture.

Pro tip: Emphasize the importance of pre-deployment segment-level validation and setting up automated alerts for early detection, as catching regressions before they impact users is key. Also, mention the need to balance segment-specific fixes with overall model performance to avoid unintended consequences.

1. Segment-Level Monitoring

Implement continuous monitoring of key performance metrics (e.g., accuracy, AUC, business KPIs) for each user segment, with automated alerts for statistically significant drops.

2. Detect Regression

Use statistical process control or hypothesis testing to confirm if the drop is significant and not due to random variation, comparing against a baseline or control group.

3. Root Cause Analysis

Investigate potential causes: data drift, feature distribution shifts, label leakage, or model bias. Analyze segment-specific data and model behavior to pinpoint the issue.

4. Implement Fix

Apply targeted solutions: retrain with augmented data for the segment, add segment-specific features, adjust model thresholds, or use a separate model for that segment.

5. Validate and Monitor

A/B test the fix to ensure it improves the segment without harming overall performance, then deploy and continue monitoring to prevent future regressions.

Key Points to Mention

  • Define segments based on business relevance (e.g., demographics, geography, user behavior).
  • Use statistical tests (e.g., t-test, Mann-Whitney U) to detect significant changes.
  • Consider data drift detection tools (e.g., Kolmogorov-Smirnov test, population stability index).
  • Root causes: training-serving skew, feedback loops, or external factors (e.g., seasonality).
  • Fixes: retraining, reweighting, or model recalibration for the segment.
  • A/B testing to validate the fix and ensure no negative impact on other segments.

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

Q7

Design an offline and online evaluation plan for this model, including rollout strategy and holdback groups.

A/B Testing & ExperimentationSystem Design
Author's notes

Offline: replay evaluation on a held-out time window with the same cutoff logic.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining offline evaluation metrics and validation strategies to ensure the model is ready for online testing. Then outline a phased rollout plan with holdback groups, online metrics, and guardrails to measure causal impact. Emphasize the importance of aligning offline and online evaluations to de-risk deployment.

Pro tip: Always include a long-term holdback group to measure the model's lasting impact and detect any degradation over time. This shows strategic thinking beyond short-term wins.

1. Define Offline Evaluation

Select appropriate offline metrics (e.g., AUC, precision@k, RMSE) and validation techniques (e.g., time-based split, cross-validation) that correlate with business objectives. Ensure the offline evaluation mimics the online environment as closely as possible.

2. Design Online Experiment

Choose online metrics (e.g., CTR, conversion rate, revenue) and guardrail metrics (e.g., latency, error rate). Determine sample size, duration, and randomization unit (e.g., user, session) to detect meaningful effects.

3. Plan Rollout Strategy

Propose a phased rollout: start with a small percentage (e.g., 1-5%) to catch bugs, then gradually increase. Use a control group (holdback) to compare against the new model and monitor for regressions.

4. Establish Holdback Groups

Define holdback groups: a short-term holdback for immediate comparison and a long-term holdback (e.g., 1-5% of users) to measure sustained impact and detect novelty effects. Ensure holdback groups are representative and stable.

5. Monitor and Iterate

Set up dashboards and alerts for key metrics. Analyze results, check for statistical significance, and decide whether to launch, iterate, or roll back. Document learnings for future experiments.

Key Points to Mention

  • Offline-online metric correlation and validation
  • Randomization unit and potential network effects
  • Phased rollout with canary and gradual ramp-up
  • Holdback groups for short-term and long-term impact
  • Guardrail metrics to monitor for unintended consequences
  • Statistical power and minimum detectable effect

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

Q8

How would you set up post-deployment monitoring for this model, specifically around feature drift, label delay, and model decay?

System DesignRoot Cause AnalysisTechnical Trade-offs
Author's notes

Three separate problems that people often lump together.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing monitoring as a lifecycle problem: define what to monitor, how to detect issues, and what actions to take. Then walk through each concern—feature drift, label delay, and model decay—with specific metrics, thresholds, and mitigation strategies. Emphasize trade-offs between detection latency and false alarms, and tie everything back to business impact.

Pro tip: Propose a tiered alerting system: use statistical process control for early warnings and business KPI thresholds for critical alerts, avoiding alert fatigue. Also, mention the importance of logging raw features and predictions for offline analysis, as this is often overlooked but crucial for debugging drift.

1. Define Monitoring Objectives and Metrics

Clarify what success looks like post-deployment: model performance, business KPIs, and data quality. Select metrics for feature drift (e.g., PSI, KL divergence), label delay (e.g., time-to-label distribution), and model decay (e.g., rolling accuracy, AUC).

2. Set Up Data Collection and Infrastructure

Ensure logging of input features, predictions, and eventual labels with timestamps. Use a pipeline to compute metrics in near real-time (e.g., streaming) or batch (e.g., daily), and store them in a monitoring dashboard.

3. Establish Baselines and Thresholds

Compute baseline statistics from training/validation data and define alert thresholds based on acceptable variance and business impact. Use statistical tests (e.g., KS test) and control charts to distinguish noise from true drift.

4. Implement Alerting and Root Cause Analysis

Configure alerts for when metrics exceed thresholds, with severity levels. Include automated root cause analysis: e.g., which features drifted, whether label delay increased, or if performance dropped for specific segments.

5. Define Mitigation and Retraining Strategy

Outline actions for each alert type: e.g., for feature drift, investigate upstream data changes; for label delay, adjust evaluation windows; for model decay, trigger retraining or fallback to a simpler model. Specify retraining cadence and rollback plans.

Key Points to Mention

  • Feature drift detection methods: PSI, KL divergence, KS test, and monitoring feature distributions over time.
  • Label delay handling: track time-to-label, use proxy labels or delayed feedback loops, and adjust evaluation metrics accordingly.
  • Model decay monitoring: rolling performance metrics (e.g., accuracy, AUC) on labeled data, and concept drift detection.
  • Trade-offs: detection latency vs. false positives, complexity vs. interpretability, and automated vs. manual intervention.
  • Business impact: tie alerts to KPIs (e.g., revenue, user engagement) and prioritize based on severity.
  • Infrastructure: use of logging, dashboards (e.g., Grafana), and alerting systems (e.g., PagerDuty) for scalability.

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