Data Scientist interview questions & answers

20 Data Scientist interview questions with complete model answers, spanning Behavioral, Technical, System design, Product & growth, Coding. The bank holds 858 Data Scientist questions in total, tagged by round and difficulty.

BehavioralEasyData ScientistTechnical Screen

1. You’re interviewing for a Data Scientist internship on a marketing analytics team.

The full question

You’re interviewing for a Data Scientist internship on a marketing analytics team.

Tell a story about a project where you built (a) a statistical model (e.g., linear/logistic regression, GLM) and (b) a machine learning model (e.g., tree-based model, boosting, neural net).

In your answer, cover: 1) The business problem and decision the model supported. 2) The target/label definition and what “success” meant. 3) What features you used (behavioral, demographic/firmographic, marketing touchpoints, time-based features, text, etc.) and why. 4) How you handled stakeholder needs: did they only care about predictive performance, or also interpretability (which features mattered and why)? 5) What you would do differently next time (data issues, leakage, monitoring, deployment, fairness, etc.).

Model answer

Situation

During my final year at university, I led a project as part of a marketing analytics course where we aimed to improve customer retention for a subscription-based streaming service. The stakes were high because the company was experiencing a churn rate of over 20%, which significantly impacted revenue. As the project lead, my role was to develop both a statistical and a machine learning model to predict churn and provide actionable insights.

Task

My specific goal was to build models that could accurately predict which customers were likely to churn and identify the key factors influencing their decisions. The challenge was balancing predictive accuracy with interpretability to ensure stakeholders could trust and act on the insights.

Action

  • I began by defining the target variable as whether a customer would churn within the next month, with "success" meaning a reduction in churn rate by at least 5%.
  • For the statistical model, I chose logistic regression due to its interpretability, focusing on features like customer demographics, subscription history, and engagement metrics. This helped stakeholders understand the impact of each feature on churn probability.
  • For the machine learning model, I used a random forest classifier, which allowed for capturing complex interactions between features. I included behavioral data, such as viewing habits and frequency of service use, to enhance predictive power.
  • I conducted feature engineering to create time-based features, like the number of days since the last login, and marketing touchpoints, such as email engagement scores.
  • To address stakeholder needs, I presented both models' results, highlighting the trade-off between the interpretability of logistic regression and the higher accuracy of the random forest model. I provided a feature importance chart from the random forest to help stakeholders understand which factors were most influential.
  • I facilitated a workshop with the marketing team to discuss how these insights could inform targeted retention campaigns, ensuring alignment with business goals.

Result

The logistic regression model achieved an accuracy of 75%, while the random forest model reached 85%. The insights led to a targeted campaign that reduced churn by 6% in the following quarter, exceeding our initial goal. Reflecting on the project, I learned the importance of balancing model complexity with stakeholder needs. Next time, I would focus more on data monitoring and fairness to ensure long-term model reliability and ethical considerations.

BehavioralEasyData ScientistTechnical Screen

2. Behavioral (Leadership/Ownership): Describe a time when you solved a complex problem by digging into details.

The full question

Behavioral (Leadership/Ownership):

Describe a time when you solved a complex problem by digging into details.

In your answer, cover:

  • The context and why the problem was complex/ambiguous.
  • The specific signals/data you investigated and how you validated them.
  • Tradeoffs you considered and how you aligned stakeholders.
  • The actions you took, the final outcome, and what you would do differently next time.

Model answer

Situation

In my previous role as a software engineer at a mid-sized tech company, I was part of a team responsible for maintaining our customer-facing web application. One day, we started receiving numerous complaints from users about the application crashing intermittently. This was a critical issue because it directly impacted user experience and could potentially lead to a loss of customers. The complexity arose from the fact that the crashes were inconsistent and did not follow any discernible pattern, making it difficult to pinpoint the root cause.

Task

My primary goal was to identify the root cause of these crashes and implement a solution to stabilize the application. The challenge was to do this quickly to minimize user impact while ensuring the solution was robust and did not introduce new issues.

Action

  • I began by gathering all available data related to the incidents, including server logs, user reports, and application performance metrics. This helped me understand the scope and frequency of the problem.
  • I noticed that the crashes often coincided with specific server load spikes. To validate this hypothesis, I set up detailed monitoring and logging to capture more granular data around the time of each crash.
  • Upon analyzing the new data, I discovered that a particular API endpoint was being called excessively, leading to resource exhaustion. This was due to a recent code change that inadvertently introduced an infinite loop under certain conditions.
  • I communicated my findings to the team and proposed a temporary fix to throttle the API requests while we worked on a permanent solution. This involved modifying the server configuration to limit the number of simultaneous requests for the problematic endpoint.
  • I collaborated with the developer who made the recent changes to refactor the code and eliminate the loop. We conducted thorough testing to ensure the fix resolved the issue without affecting other parts of the application.
  • Throughout the process, I kept stakeholders informed, including customer support and product management, to align on priorities and manage user communication effectively.

Result

The immediate throttling solution reduced the frequency of crashes significantly, and the permanent code fix eliminated the issue entirely. As a result, user complaints dropped by 90% within a week, and customer satisfaction scores improved. This experience reinforced the importance of detailed data analysis and cross-functional collaboration in problem-solving. In the future, I would implement more proactive monitoring to catch similar issues earlier and prevent them from escalating.

BehavioralEasyData ScientistTechnical Screen

3. You computed (1) monthly % of shops using pirated themes and (2) monthly and cumulative estimated revenue loss from pirated themes.

The full question

You computed (1) monthly % of shops using pirated themes and (2) monthly and cumulative estimated revenue loss from pirated themes.

Explain how you would present these results to a Product Manager in a short readout (5–10 minutes).

Include:

  • What the headline is and what decision you want to enable.
  • Which metrics and visualizations you would show first vs. as diagnostics.
  • Key assumptions behind the revenue-loss estimate.
  • Data-quality checks and how you’d interpret extreme patterns (e.g., % jumping from ~0% to ~100%, or cumulative loss growing very fast).
  • Concrete next steps / recommendations (product, enforcement, measurement).

Model answer

Situation In my role as a data analyst at Shopify, I was tasked with analyzing the impact of pirated themes on our platform. This involved calculating the monthly percentage of shops using pirated themes and estimating both the monthly and cumulative revenue loss attributed to these themes. This analysis was crucial as it directly impacted our revenue and brand integrity, and I needed to present these findings to a Product Manager to inform strategic decisions.

Task My goal was to deliver a concise and impactful readout to the Product Manager, enabling them to make informed decisions regarding potential interventions or policy changes. The key challenge was to present complex data in a clear and actionable manner within a 5–10 minute timeframe.

Action

  • I began by crafting a headline that succinctly captured the essence of my findings: "Pirated themes are causing a significant revenue drain, with an estimated monthly loss of X% and a cumulative impact of Y%."
  • I prioritized the presentation of key metrics, starting with the monthly percentage of shops using pirated themes, followed by the estimated revenue loss. I used clear visualizations such as line graphs to depict trends over time, making it easier for the Product Manager to grasp the scale and urgency of the issue.
  • To support my revenue-loss estimates, I outlined key assumptions, such as average revenue per shop and the proportion of sales attributed to theme-related features. This transparency helped build trust in the data and allowed for informed discussions on the assumptions' validity.
  • I conducted thorough data-quality checks to ensure the accuracy of my findings. I explained how I would interpret extreme patterns, such as a sudden jump in the percentage of pirated themes, as potential data anomalies or indicators of a systemic issue requiring immediate attention.
  • Finally, I recommended concrete next steps, including enhancing theme verification processes, exploring partnerships with theme developers for better compliance, and setting up ongoing monitoring to track improvements. These actions aimed to reduce the prevalence of pirated themes and mitigate revenue loss.

Result The Product Manager appreciated the clarity and depth of the analysis, which led to the initiation of a cross-functional task force to address the issue. My recommendations were adopted, resulting in a 15% reduction in the use of pirated themes over the next quarter. Reflecting on this experience, I learned the importance of presenting data-driven insights in a way that is both accessible and actionable, ultimately driving strategic decisions that align with business goals.

BehavioralEasyData ScientistTechnical Screen

4. You ran an experiment.

The full question

You ran an experiment. The north star metric (NSM) is profit per order.

Observed results

  • Average order volume increased in treatment vs control.
  • Profit per order decreased (statistically and/or practically meaningfully).

Task

Should you roll out the change? Explain your decision process.

Requirements

In your answer, cover:

  • Why optimizing the NSM matters vs secondary metrics.
  • What additional checks you would run (segment analysis, guardrails, novelty effects, heterogeneous treatment effects).
  • When (if ever) you would still consider launching (e.g., if total profit increases, long-term effects, strategic goals).
  • A clear final recommendation and next steps.

Model answer

Situation In my role as a product manager at Instacart, I recently ran an experiment aimed at increasing the average order volume. Our north star metric (NSM) was profit per order, which is crucial for the company's long-term sustainability. The experiment showed that while the average order volume increased in the treatment group compared to the control, the profit per order decreased significantly. This posed a challenge as it directly impacted our NSM, which is a primary indicator of our business health.

Task My task was to decide whether to roll out the change despite the decrease in profit per order. The key constraint was balancing the immediate impact on our NSM with potential long-term benefits or strategic goals.

Action

  • I began by conducting a detailed segment analysis to understand if specific customer segments were driving the decrease in profit per order. This involved breaking down the data by demographics, order size, and frequency.
  • Next, I checked for any novelty effects that might have influenced the initial results, ensuring that the observed changes were not just temporary spikes due to the newness of the experiment.
  • I also evaluated heterogeneous treatment effects to see if the change had different impacts across various customer groups, which could inform a more targeted rollout strategy.
  • I set up guardrails to monitor other critical metrics such as customer satisfaction and retention rates, ensuring that any rollout would not negatively affect these areas.
  • After gathering these insights, I facilitated a discussion with key stakeholders, including finance and operations, to assess the broader implications of the experiment results. We considered scenarios where total profit might increase over time due to higher order volumes, even if profit per order was lower initially.
  • Based on the analysis and discussions, I recommended a phased rollout. This approach would allow us to monitor the long-term effects on total profit and adjust the strategy as needed.

Result The decision to proceed with a phased rollout was well-received by the team. It allowed us to capture increased order volumes while closely monitoring profit trends. Over the next quarter, we observed a gradual increase in total profit, validating our strategic approach. This experience reinforced the importance of a data-driven decision-making process and the need to balance short-term metrics with long-term strategic goals.

CodingEasyData ScientistCoding screen

5. Given a pandas DataFrame df with columns ‘Date’, ‘Sales’, and ‘Customer_Rating’, write a Python code snippet to clean this DataFrame.

The full question

Given a pandas DataFrame df with columns ‘Date’, ‘Sales’, and ‘Customer_Rating’, write a Python code snippet to clean this DataFrame. Assume there are missing values in ‘Customer_Rating’ and duplicate rows across all columns. Remove duplicates and replace missing values in ‘Customer_Rating’ with the average rating.

Model answer

The flow

  1. Clarify inputs & output shape: Understand the DataFrame structure and the requirements for cleaning.
  2. Brute force first: Implement straightforward solutions for removing duplicates and handling missing values.
  3. Optimize: Utilize pandas built-in functions to efficiently perform the operations.
  4. State complexity: Consider the time complexity of operations, especially with large datasets.
  5. Test the edges: Ensure the solution handles edge cases like all values missing or no duplicates.

The answer

1. Clarify inputs & output shape

  • We have a DataFrame df with columns Date, Sales, and Customer_Rating.
  • The task is to remove duplicate rows and fill missing values in Customer_Rating with the average rating.

2. Brute force first

  • Start by identifying duplicate rows and removing them.
  • Calculate the average of Customer_Rating and use it to fill missing values.

3. Optimize

  • Use pandas functions like drop_duplicates() and fillna() to efficiently clean the DataFrame.
import pandas as pd

# Sample DataFrame
# df = pd.DataFrame({
#     'Date': [...],
#     'Sales': [...],
#     'Customer_Rating': [...]
# })

# Remove duplicate rows
cleaned_df = df.drop_duplicates()

# Calculate the mean of Customer_Rating, ignoring NaN values
average_rating = cleaned_df['Customer_Rating'].mean()

# Fill missing values in Customer_Rating with the average rating
cleaned_df['Customer_Rating'].fillna(average_rating, inplace=True)
  • Approach:
  • drop_duplicates() removes all duplicate rows based on all columns.
  • mean() calculates the average of Customer_Rating, ignoring NaN values.
  • fillna() replaces NaN values with the calculated average.
  • Complexity: The time complexity is approximately $O(n)$ for both removing duplicates and filling NaN values, where $n$ is the number of rows in the DataFrame.

4. Test the edges

  • Ensure the solution works when all Customer_Rating values are missing, or when there are no duplicates.

Why this works

  • Testing understanding: The interviewer is assessing your ability to use pandas for data cleaning tasks.
  • Efficiency: Using pandas built-in functions ensures operations are performed efficiently on potentially large datasets.
  • Edge cases: A strong answer considers edge cases, such as all values missing or no duplicates, ensuring robustness.
  • Weak answers: Failing to handle missing values correctly or not removing duplicates would indicate a lack of attention to detail or understanding of pandas capabilities.
CodingEasyData ScientistTechnical Screen

6. You are given a binary classifier’s outputs on a dataset: y_true: array of true labels in ({0,1}) y_score: array of predicted scores/probabilities…

The full question

You are given a binary classifier’s outputs on a dataset:

  • y_true: array of true labels in ({0,1})
  • y_score: array of predicted scores/probabilities (higher means more likely positive)

Tasks

  1. Define precision and recall.
  2. Describe how to compute the precision–recall curve by sweeping a decision threshold over y_score.
  3. Implement (in pseudocode or Python) a function that returns PR curve points:
  • Output arrays: thresholds, precision, recall
  1. Mention at least two edge cases/pitfalls (e.g., ties in scores, no predicted positives at a threshold, extreme class imbalance).

Optional: Explain how to compute Average Precision / AUPRC and what the baseline means.

Model answer

import numpy as np

def precision_recall_curve(y_true, y_score):
    # Sort scores and corresponding true labels in descending order
    desc_score_indices = np.argsort(y_score)[::-1]
    y_true = np.array(y_true)[desc_score_indices]
    y_score = np.array(y_score)[desc_score_indices]

    # Initialize variables
    thresholds = []
    precision = []
    recall = []
    tp = 0  # True positives
    fp = 0  # False positives
    fn = np.sum(y_true)  # False negatives initially all positives

    # Iterate through scores to calculate precision and recall
    for i in range(len(y_score)):
        if i == 0 or y_score[i] != y_score[i - 1]:
            thresholds.append(y_score[i])
            precision.append(tp / (tp + fp) if (tp + fp) > 0 else 1.0)
            recall.append(tp / (tp + fn) if (tp + fn) > 0 else 0.0)

        if y_true[i] == 1:
            tp += 1
            fn -= 1
        else:
            fp += 1

    # Add the last point at threshold 0
    thresholds.append(0)
    precision.append(tp / (tp + fp) if (tp + fp) > 0 else 1.0)
    recall.append(tp / (tp + fn) if (tp + fn) > 0 else 0.0)

    return thresholds, precision, recall

# Example usage
y_true = [0, 1, 1, 0, 1]
y_score = [0.1, 0.4, 0.35, 0.8, 0.7]
thresholds, precision, recall = precision_recall_curve(y_true, y_score)
print("Thresholds:", thresholds)
print("Precision:", precision)
print("Recall:", recall)
  • Precision is the ratio of true positives to the sum of true positives and false positives. It measures the accuracy of positive predictions.
  • Recall is the ratio of true positives to the sum of true positives and false negatives. It measures the ability to find all positive samples.
  • To compute the precision-recall curve, sort y_score in descending order and iterate over it. For each unique score, calculate precision and recall, updating true positives, false positives, and false negatives accordingly.

Complexity:

  • Time: O(n log n) due to sorting, where n is the number of samples.
  • Space: O(n) for storing sorted indices and result arrays.

Edge Cases/Pitfalls:

  1. Ties in scores: Ensure that precision and recall are calculated correctly when multiple instances have the same score.
  2. No predicted positives: Handle cases where no samples are predicted as positive at a certain threshold, which can lead to division by zero in precision calculation.

Average Precision / AUPRC:

  • Average Precision (AP) is the area under the precision-recall curve. It summarizes the precision-recall trade-off across thresholds. The baseline for AP is the proportion of positive samples in the dataset.
CodingEasyData ScientistTechnical Screen

7. Two players play independent games of table tennis.

The full question

Two players play independent games of table tennis.

  • Player A wins each game with probability (p) (constant across games).
  • They play a best-of-5 match (first to 3 wins).
  • Let (X) be the number of games played until the match ends (so (X\in{3,4,5})).

Tasks

1) Compute (\theta = \Pr(X=5)). 2) Write a simulation (Monte Carlo) approach to estimate (\theta). 3) Follow-up: given (M) simulated matches, how would you build a confidence interval for (\theta)?

Model answer

// Function to compute the probability that a match goes to 5 games
function probabilityOfFiveGames(p) {
  // Probability that the match goes to 5 games
  // This happens if both players win 2 games each in the first 4 games
  const prob = 6 * Math.pow(p, 2) * Math.pow(1 - p, 2);
  return prob;
}

// Monte Carlo simulation to estimate the probability of a match going to 5 games
function simulateMatches(numMatches, p) {
  let fiveGameMatches = 0;

  for (let i = 0; i < numMatches; i++) {
    let winsA = 0;
    let winsB = 0;
    let gamesPlayed = 0;

    while (winsA < 3 && winsB < 3) {
      gamesPlayed++;
      if (Math.random() < p) {
        winsA++;
      } else {
        winsB++;
      }
    }

    if (gamesPlayed === 5) {
      fiveGameMatches++;
    }
  }

  return fiveGameMatches / numMatches;
}

// Function to build a confidence interval for the estimated probability
function confidenceInterval(numMatches, p, confidenceLevel = 0.95) {
  const thetaEstimate = simulateMatches(numMatches, p);
  const z = 1.96; // z-score for 95% confidence
  const marginOfError = z * Math.sqrt((thetaEstimate * (1 - thetaEstimate)) / numMatches);

  return [thetaEstimate - marginOfError, thetaEstimate + marginOfError];
}

// Example usage
const p = 0.5; // Probability that player A wins a game
const numMatches = 10000; // Number of simulated matches
console.log("Probability of 5 games (analytical):", probabilityOfFiveGames(p));
console.log("Probability of 5 games (simulation):", simulateMatches(numMatches, p));
console.log("95% Confidence Interval:", confidenceInterval(numMatches, p));
  • Analytical Calculation: The probability that a match goes to 5 games is calculated by considering the scenarios where both players win exactly 2 games each in the first 4 games. This is given by \(6 \times p^2 \times (1-p)^2\), where 6 is the number of ways to arrange 2 wins for each player in 4 games.
  • Monte Carlo Simulation: Simulate a large number of matches, counting how many go to 5 games. For each match, simulate games until one player wins 3 games. Count matches where exactly 5 games are played.
  • Confidence Interval: Use the normal approximation for the binomial distribution to calculate the confidence interval for the estimated probability. The margin of error is calculated using the standard error and the z-score for the desired confidence level.

Complexity:

  • Time: \(O(M)\) for the simulation, where \(M\) is the number of matches.
  • Space: \(O(1)\), constant space usage.
CodingEasyData ScientistCoding screen

8. Describe a scenario where you would write a Python script to process and analyze raw text data.

The full question

Describe a scenario where you would write a Python script to process and analyze raw text data. What steps would you take in your script?

Model answer

The flow

  1. Clarify inputs & output shape: Define the format of the raw text data and the expected output.
  2. Brute force first: Write a simple script to read and process the text data.
  3. Optimize: Improve the script for efficiency and scalability.
  4. State complexity: Analyze the time and space complexity of the script.
  5. Test the edges: Ensure the script handles edge cases and unexpected inputs.

The answer

Clarify inputs & output shape

  • The raw text data is a collection of text files, each containing multiple lines of text.
  • The goal is to analyze the frequency of words and output a summary report in CSV format.

Brute force first

  • Start by writing a Python script that opens each text file and reads its contents.
  • Use a dictionary to count the occurrences of each word across all files.
import os
import csv
from collections import defaultdict

# Directory containing text files
directory = 'text_data/'

# Dictionary to store word frequencies
word_count = defaultdict(int)

# Read and process each file
for filename in os.listdir(directory):
    if filename.endswith('.txt'):
        with open(os.path.join(directory, filename), 'r') as file:
            for line in file:
                # Tokenize the line into words
                words = line.strip().split()
                for word in words:
                    # Convert to lowercase and count
                    word_count[word.lower()] += 1

# Write the word frequencies to a CSV file
with open('word_frequencies.csv', 'w', newline='') as csvfile:
    writer = csv.writer(csvfile)
    writer.writerow(['Word', 'Frequency'])
    for word, count in word_count.items():
        writer.writerow([word, count])

Optimize

  • Use more efficient data structures or libraries such as collections.Counter for counting.
  • Implement parallel processing if dealing with a large number of files.

State complexity

  • Time complexity: $O(n)$, where $n$ is the total number of words across all files.
  • Space complexity: $O(m)$, where $m$ is the number of unique words.

Test the edges

  • Test with files containing special characters, numbers, or empty lines.
  • Ensure the script handles cases where the directory is empty or files are missing.

Why this works

  • Interviewer is testing: Ability to process text data, write efficient code, and handle edge cases.
  • Sanity check: Ensures that the candidate can handle common issues in text processing, such as case sensitivity and special characters.
  • Weak answers fail: If a candidate doesn't optimize for large datasets or fails to handle edge cases, the solution won't scale or be robust.
Product & growthMediumData ScientistAnalytics / experimentation round

9. What’s the difference between A/A and A/B tests?

Model answer

The flow

  1. Define the Hypothesis & Metrics: Clearly articulate the purpose of the test and the metrics to be measured.
  2. Determine Unit of Randomization: Decide on the level at which randomization will occur (e.g., user, session).
  3. Calculate Power & Sample Size: Ensure the test is statistically powered to detect meaningful differences.
  4. Run the Test & Guard Against Peeking: Execute the test while avoiding biases from early data peeking.
  5. Analyze Results with Guardrails: Interpret results with statistical rigor and predefined guardrails.

The answer

Hypothesis & Metrics

  • A/A Testing: The hypothesis is that there should be no significant difference between the two groups as both are exposed to the same variant (control).
  • A/B Testing: The hypothesis is that the new variant (B) will perform better than the control (A) on predefined metrics, such as conversion rate.

Unit of Randomization

  • Both tests typically randomize at the user level to ensure each user is only exposed to one variant.

Power & Sample Size

  • A/A Testing: Used to validate the experimental setup, ensuring randomization and measurement are correct. Sample size should be large enough to detect any unexpected differences.
  • A/B Testing: Sample size is calculated based on the expected effect size, power, and significance level to detect meaningful differences.

Run the Test & Guard Against Peeking

  • A/A Testing: Run to completion to validate the test setup without expecting any differences.
  • A/B Testing: Run until the predetermined sample size is reached, avoiding interim analysis to prevent biases.

Analyze Results with Guardrails

  • A/A Testing: Check for any significant differences; if found, investigate potential issues in randomization or measurement.
  • A/B Testing: Analyze the results using statistical tests to determine if the observed differences are significant, ensuring guardrails like confidence intervals are respected.

Why this works

  • Understanding of Purpose: The interviewer is testing the candidate's understanding of the purpose and application of A/A versus A/B tests.
  • Validation of Setup: A strong answer highlights how A/A tests validate the experimental setup, ensuring the reliability of subsequent A/B tests.
  • Statistical Rigor: Emphasizes the importance of statistical rigor in both types of tests, including proper sample size calculation and avoiding peeking.
  • Common Pitfalls: Weak answers may confuse the purposes of A/A and A/B tests or fail to address the importance of validating the test environment with A/A testing.
Product & growthMediumData ScientistAnalytics / experimentation round

10. How would you design an A/B test to measure the effect of a new homepage layout on conversion?

Model answer

The flow

  1. Hypothesis & Metric: Define the hypothesis and identify the primary and secondary metrics.
  2. Unit of Randomization: Decide the unit of randomization (e.g., user, session).
  3. Power & Sample Size: Calculate the necessary sample size to detect a significant effect.
  4. Run & Guard Against Peeking: Execute the test while preventing premature data analysis.
  5. Read Result with Guardrails: Analyze the results with statistical rigor and interpret the findings.

The answer

1. Hypothesis & Metric

  • Hypothesis: The new homepage layout will increase the conversion rate compared to the current layout.
  • Primary Metric: Conversion rate (defined as the percentage of users who complete a purchase).
  • Secondary Metrics: Bounce rate, average time on page, and click-through rate on key elements.

2. Unit of Randomization

  • Randomize at the user level to ensure each user sees only one version of the homepage, avoiding cross-exposure.

3. Power & Sample Size

  • Calculate the sample size using a power analysis. Assume a baseline conversion rate of 5% and aim to detect a 10% relative increase.
  • Use a significance level (alpha) of 0.05 and a power of 0.8.
  • Sample size formula: $$ n = \left(\frac{Z_{1-\alpha/2} + Z_{1-\beta}}{\Delta} \right)^2 \times \frac{p(1-p)}{\Delta^2} $$
  • Plugging in values: $n \approx 16,000$ users per group.

4. Run & Guard Against Peeking

  • Run the test for a pre-determined period or until the sample size is reached.
  • Implement a data analysis plan to avoid peeking at results prematurely, which could lead to false conclusions.

5. Read Result with Guardrails

  • Analyze the results using statistical tests (e.g., chi-square test for conversion rates).
  • Check for statistical significance and practical significance.
  • Recommendation: If the new layout significantly improves conversion without negatively impacting secondary metrics, recommend rolling out the change.

Why this works

  • Testing Hypothesis: The interviewer is assessing your ability to formulate a clear hypothesis and identify relevant metrics.
  • Sample Size Calculation: Demonstrates understanding of statistical power and the importance of adequate sample size.
  • Avoiding Bias: Guarding against peeking shows awareness of biases that can invalidate results.
  • Interpreting Results: A strong answer includes both statistical and practical significance, ensuring the change is beneficial.
  • Common Pitfalls: Weak answers may overlook secondary metrics, fail to calculate sample size correctly, or ignore the risk of peeking.
Product & growthMediumData ScientistAnalytics / experimentation round

11. How would you approach designing an A/B test?

Model answer

The flow

  1. Hypothesis & Metric: Define the hypothesis and identify key metrics.
  2. Unit of Randomization: Determine the unit of randomization (e.g., user, session).
  3. Power/Sample Size: Calculate the required sample size to achieve statistical power.
  4. Run & Guard Against Peeking: Execute the test and implement measures to prevent peeking.
  5. Read the Result with Guardrails: Analyze the results while applying statistical guardrails.

The answer

1. Hypothesis & Metric

  • Hypothesis: Introducing a new feature will increase user engagement by 10%.
  • Metric: Primary metric is the average session duration per user.

2. Unit of Randomization

  • Unit: Randomize at the user level to ensure independent observations and mitigate spillover effects.

3. Power/Sample Size

  • Calculation: Assume a baseline average session duration of 5 minutes with a standard deviation of 1.5 minutes. To detect a 10% increase with 80% power and a significance level of 0.05, use the formula: $$ n = \left( \frac{Z_{1-\alpha/2} + Z_{1-\beta}}{\Delta/\sigma} \right)^2 $$ where $\Delta = 0.5$ minutes (10% of 5 minutes), $\sigma = 1.5$.
  • Result: Approximately 1,000 users per group are required.

4. Run & Guard Against Peeking

  • Execution: Run the test for 4 weeks to collect enough data.
  • Guard: Implement a fixed stopping rule and avoid interim analysis to prevent Type I errors.

5. Read the Result with Guardrails

  • Analysis: Use a t-test to compare the means of the control and treatment groups.
  • Guardrails: Check for balance in covariates and ensure no significant differences in pre-test metrics.
  • Recommendation: If the p-value < 0.05, conclude the new feature significantly increases engagement.

Why this works

  • Hypothesis & Metric: Tests the candidate's ability to clearly define a testable hypothesis and relevant metrics.
  • Unit of Randomization: Ensures understanding of randomization to avoid biases and confounding variables.
  • Power/Sample Size: Evaluates the candidate's ability to perform statistical calculations for adequate power.
  • Run & Guard Against Peeking: Tests knowledge of common pitfalls in A/B testing such as peeking.
  • Read the Result with Guardrails: Assesses the candidate's ability to interpret results correctly, applying statistical rigor.
  • Weakness: A weak answer might fail to define a clear hypothesis, ignore sample size calculations, or misinterpret statistical results.
Product & growthMediumData ScientistAnalytics / experimentation round

12. A/B Test Results Show a 2% Increase in Conversions.

The full question

A/B Test Results Show a 2% Increase in Conversions. What Factors Would You Examine Before Recommending Implementation?

Model answer

The flow

  1. Hypothesis & metric: Define the hypothesis and the key metric to measure.
  2. Unit of randomization: Determine the unit of randomization for the A/B test.
  3. Power/sample size: Calculate the required sample size to achieve statistical power.
  4. Run & guard against peeking: Execute the test while preventing peeking at interim results.
  5. Read the result with guardrails: Analyze the results with statistical guardrails to validate findings.
  6. Recommendation: Make a recommendation based on the analysis of results.

The answer

1. Hypothesis & metric

  • Hypothesis: Implementing the new feature will increase the conversion rate by 2%.
  • Key metric: Conversion rate, defined as the number of conversions divided by the total number of visitors.

2. Unit of randomization

  • Randomize at the user level to ensure each user has an equal chance of being in either the control or treatment group.

3. Power/sample size

  • Calculate the sample size needed to detect a 2% increase with 80% power and a significance level of 0.05.
  • Assuming a baseline conversion rate of 10%, the required sample size per group is approximately 8,000 users.

4. Run & guard against peeking

  • Ensure the test runs for a sufficient time to collect the necessary sample size without checking interim results to avoid bias.

5. Read the result with guardrails

  • Analyze the results using statistical tests (e.g., chi-square test) to confirm the 2% increase is statistically significant.
  • Check for any anomalies or external factors that could have influenced the results, such as seasonality or marketing campaigns.

6. Recommendation

  • If the results are statistically significant and no confounding factors are identified, recommend implementing the new feature.
  • If not, suggest further investigation or additional testing.

Why this works

  • Statistical validity: Ensures the increase in conversions is not due to random chance by calculating the appropriate sample size and using statistical tests.
  • Guardrails: Protects against biases and errors by preventing peeking and considering external factors.
  • Comprehensive analysis: A strong answer considers both statistical significance and practical significance, ensuring the recommendation is well-founded.
  • Weak answers: Often fail to account for confounding variables, do not calculate sample sizes correctly, or make recommendations without statistical validation.
System designEasyData ScientistOnsite

13. You are a Data Scientist at a food-delivery marketplace such as DoorDash or Uber Eats.

The full question

You are a Data Scientist at a food-delivery marketplace such as DoorDash or Uber Eats. Your team focuses on bike couriers in dense cities, where delivery outcomes depend heavily on geography, weather, merchant operations, courier supply, and customer demand.

Leadership asks: What should we optimize for, and how would you improve biker delivery performance?

Constraints & Assumptions

  • Treat this as a three-sided marketplace problem involving customers, couriers, and merchants.
  • Assume bike couriers operate in dense urban zones where hills, bridges, high-rise buildings, pedestrian areas, parking or locking constraints, and weather can meaningfully affect delivery time.
  • Do not optimize a single metric in isolation if it creates safety, earnings, merchant, or customer-experience harm.
  • You may propose product, operations, routing, dispatch, merchant-experience, or incentive changes, but each should be measurable.
  • Focus on an analysis and experimentation plan that can handle confounding from weather, zone, time of day, demand shocks, and courier mix.

Clarifying Questions to Ask

  • What is the business priority: customer reliability, courier earnings, marketplace efficiency, merchant quality, or a balanced portfolio?
  • Are we trying to improve all bike deliveries or a specific segment such as downtown peak hours, bad weather, long pickup waits, or short-distance orders?
  • What data do we already collect on courier location, route choice, pickup wait, merchant prep, weather, and customer promise times?
  • Are there safety, compliance, or courier fairness constraints that limit incentives or routing recommendations?
  • Can we randomize by courier, zone, merchant, or zone-time block?

Part 1 - Define the Objective

Propose a clear objective for "better" bike delivery. Explain what outcome you would optimize and why it is aligned with the marketplace.

Part 2 - Build the Metrics Framework

Define primary metrics, diagnostic metrics, and guardrails. Include formulas where helpful and cover customer, courier, merchant, and marketplace perspectives.

Part 3 - Identify Data, Features, and Risks

List the data and features needed to understand biker delivery performance, and call out data quality risks.

Part 4 - Propose Levers and Validation Plan

Suggest actionable ideas to test or roll out, then outline an experimentation or causal plan that can separate real impact from confounding.

Model answer

Part 1 - Define the Objective

Objective: Optimize for "Delivery Time Reliability" while ensuring safety and earnings for couriers.

Outcome to Optimize:

  • Delivery Time Consistency: Aim to reduce the variance in delivery times across different conditions (e.g., weather, time of day, and urban geography).

Alignment with Marketplace:

  • Enhancing delivery time reliability improves customer satisfaction, leading to repeat orders.
  • Consistent delivery times can help merchants manage inventory and staffing better.
  • Couriers benefit from predictable earnings through optimized routes and reduced idle time.

---

Part 2 - Build the Metrics Framework

Primary Metrics:

  1. Average Delivery Time (ADT): - Formula: \( \text{ADT} = \frac{\sum \text{Delivery Times}}{\text{Number of Deliveries}} \)
  2. Delivery Time Variance (DTV): - Formula: \( \text{DTV} = \frac{\sum (\text{Delivery Time} - \text{ADT})^2}{\text{Number of Deliveries}} \)

Diagnostic Metrics:

  • On-Time Delivery Rate (OTDR): Percentage of deliveries completed within the promised time.
  • Courier Earnings per Hour (CEPH): Measures the financial health of couriers.

Guardrails:

  • Safety Incidents Rate: Track any increase in accidents or near-misses.
  • Merchant Satisfaction Score: Ensure merchants are not negatively impacted by delivery changes.

---

Part 3 - Identify Data, Features, and Risks

Data Needed:

  • Courier Data: Location, route choice, delivery times, and earnings.
  • Merchant Data: Order preparation times, order volume, and customer ratings.
  • Customer Data: Order history, delivery expectations, and satisfaction ratings.
  • Environmental Data: Weather conditions, traffic patterns, and urban geography.

Features to Extract:

  • Route Complexity: Number of intersections, hills, and pedestrian zones.
  • Weather Conditions: Rain, snow, temperature, and wind speed.
  • Time of Day: Peak vs. off-peak hours.

Data Quality Risks:

  • Incomplete or inaccurate location data from couriers.
  • Delays in weather data updates impacting real-time decision-making.
  • Potential biases in customer ratings based on external factors.

---

Part 4 - Propose Levers and Validation Plan

Actionable Ideas:

  1. Dynamic Routing Adjustments: Use real-time weather and traffic data to adjust routes for couriers.
  2. Incentive Programs: Implement bonuses for couriers during peak demand times or adverse weather conditions.
  3. Merchant Training: Provide best practices for faster order preparation based on historical data.

Experimentation Plan:

  • A/B Testing: Randomly assign couriers to either the new routing algorithm or the existing one to measure differences in delivery time and customer satisfaction.
  • Causal Inference: Use regression analysis to control for confounding variables like weather and time of day, isolating the impact of changes made.
  • Longitudinal Studies: Track performance over time to assess the sustainability of improvements and ensure no negative impacts on safety or earnings.

By implementing this structured approach, we can effectively optimize bike delivery performance while balancing the needs of customers, couriers, and merchants.

System designEasyData ScientistTechnical Screen

14. You are interviewing for a Data Scientist role on a marketing/growth team.

The full question

You are interviewing for a Data Scientist role on a marketing/growth team. Sales has limited outreach capacity, so the business wants a lead-scoring system that ranks or scores incoming leads (a user or account arriving through ads, email, organic, etc.) so Sales/Marketing can prioritize who to contact.

Assume you have a historical dataset of leads with a lead_id, a created_at timestamp, features available at scoring time (acquisition channel/campaign/geo/device, firmographics such as company size and industry, behavioral signals such as pages viewed, pricing-page hits, demo requests, email engagement), and one or more outcome labels (e.g. converted within a defined window, and optionally time_to_convert_days).

Design an end-to-end approach. Be explicit about assumptions (conversion window, label definition, scoring cadence) and call out key pitfalls and edge cases.

  1. Define the prediction target (label) and the prediction time (when the score is computed). Address how you handle leads that are too recent to have observed the outcome window.
  2. Propose feature sets and data sources, and explain how you would handle feature availability and leakage.
  3. Propose both a statistical (baseline) model and a more advanced machine-learning model, and explain the interpretability/performance tradeoffs.
  4. The stakeholder may either only care about predictive performance, or require understanding which features are important and why. Explain what you would deliver in each scenario.
  5. Explain what multicollinearity is, why it matters (or doesn't) for different model families, how you would detect it, and how you would mitigate it.
  6. Define how you would evaluate the model: a primary metric (and why), diagnostic metrics/plots, and guardrails (fairness, stability, operational constraints). Tie metrics to business constraints such as top-K capacity, lift, calibration, and revenue.
  7. Describe how you would pick an operating threshold / routing policy to turn scores into actions.
  8. Discuss key risks — class imbalance, selection bias (sales touches are not random), fairness, and drift — and how you would monitor and iterate.
  9. Describe how you would deploy and monitor the score in production and how you would update it over time.

Model answer

1. Prediction Target and Time

  • Prediction Target (Label):
  • The target label will be whether a lead converted within a defined conversion window (e.g., 30 days).
  • Optionally, we can include time_to_convert_days to provide additional insights.
  • Prediction Time:
  • Scores will be computed at the time of lead generation.
  • For leads that are too recent to have observed the outcome window, we will assign a default score (e.g., average score of historical leads) until sufficient data is available.

2. Feature Sets and Data Sources

  • Feature Sets:
  • Acquisition Channel: Channel through which the lead arrived (e.g., ads, email).
  • Firmographics: Company size, industry, etc.
  • Behavioral Signals: Pages viewed, demo requests, email engagement.
  • Handling Feature Availability and Leakage:
  • Ensure features are only derived from data available at the time of scoring to prevent leakage.
  • Use historical data to train models but avoid using future information (e.g., conversion status) during scoring.

3. Statistical and Machine Learning Models

  • Statistical Model:
  • Logistic Regression as a baseline model.
  • Interpretability: Easy to understand and explain coefficients.
  • Advanced Machine Learning Model:
  • Random Forest or Gradient Boosting Machines (GBM).
  • Performance Trade-offs: Higher accuracy but less interpretability compared to logistic regression.

4. Deliverables Based on Stakeholder Needs

  • Predictive Performance Focus:
  • Deliver the model with performance metrics (AUC, accuracy) and predictions.
  • Understanding Feature Importance:
  • Provide feature importance scores (e.g., SHAP values) alongside the model to explain which features drive predictions.

5. Multicollinearity

  • Definition:
  • Multicollinearity occurs when two or more features are highly correlated, leading to unreliable coefficient estimates.
  • Importance:
  • Matters for linear models (e.g., logistic regression) but less critical for tree-based models (e.g., Random Forest).
  • Detection:
  • Use Variance Inflation Factor (VIF) to identify multicollinearity.
  • Mitigation:
  • Remove or combine correlated features to reduce redundancy.

6. Model Evaluation

  • Primary Metric:
  • AUC-ROC for overall performance, as it balances sensitivity and specificity.
  • Diagnostic Metrics/Plots:
  • Confusion matrix, precision-recall curve, and feature importance plots.
  • Guardrails:
  • Monitor fairness (e.g., equal opportunity), stability (e.g., model drift), and operational constraints (e.g., top-K capacity).

7. Operating Threshold / Routing Policy

  • Threshold Selection:
  • Use ROC curve analysis to select a threshold that balances precision and recall based on business needs.
  • Consider business implications of false positives vs. false negatives.

8. Key Risks

  • Class Imbalance:
  • Address using techniques like SMOTE or adjusting class weights.
  • Selection Bias:
  • Ensure that the dataset represents the entire lead population, not just those touched by sales.
  • Fairness:
  • Regularly audit model predictions across different demographic groups.
  • Drift:
  • Monitor model performance over time and retrain as necessary.

9. Deployment and Monitoring

  • Deployment:
  • Use a CI/CD pipeline to automate model deployment and updates.
  • Monitoring:
  • Implement logging to track model performance and lead conversion rates.
  • Set up alerts for performance degradation and retrain models periodically based on new data.
System designEasyData ScientistTechnical Screen

15. A product tracks activity using user_id from login events, and computes MAU as: MAU (L30D) on date d = number of distinct user_id with at least one…

The full question

A product tracks activity using user_id from login events, and computes MAU as:

  • MAU (L30D) on date d = number of distinct user_id with at least one login in the window [d-29, d] (inclusive).

Data change event

On a single day T, the company performs a one-time rehash of all user IDs:

  • For dates < T, events use the old user_id_old.
  • For dates ≥ T, events use the new user_id_new.
  • Each real person gets exactly one new ID (a 1-to-1 remapping), but your metric pipeline does not have the mapping between old and new IDs.

Questions

1) For dates whose L30D window overlaps both sides of T, how can this rehash bias the computed MAU if you naïvely count distinct user_id? 2) What is the maximum possible MAU overestimate (as a percentage) and the minimum possible MAU overestimate (as a percentage), relative to the true number of distinct real users in the window? 3) Operationally, how would you redesign tracking/warehouse modeling to make MAU robust to this type of ID change?

Model answer

1. Requirements & scale

Functional Requirements:

  • Track login events using user_id.
  • Compute Monthly Active Users (MAU) as the number of distinct user_id with at least one login in the last 30 days.
  • Handle a one-time rehash of user_id on a specific date T.

Non-Functional Requirements:

  • Ensure accuracy in MAU computation despite user_id rehashing.
  • Maintain system scalability to handle large volumes of login data.

Estimates:

  • Assume 1 million users with an average of 1 login per day.
  • Daily login events: 1 million.
  • Storage: If each event requires 100 bytes (including metadata), daily storage is approximately 100 MB.
  • Over a 30-day window, this results in 3 GB of storage.

2. High-level architecture

flowchart TD
    subgraph Client
        A[User Device]
    end

    subgraph Edge/CDN
        B[CDN]
    end

    subgraph Load Balancer
        C[Load Balancer]
    end

    subgraph API / Services
        D[Login Service]
        E[MAU Calculation Service]
    end

    subgraph Datastores
        F["Event Store (NoSQL)"]
        G["User Mapping Store (SQL)"]
    end

    subgraph Cache
        H[Redis Cache]
    end

    subgraph Workers
        I[Batch Processor]
    end

    A -->|Login Event| B
    B --> C
    C --> D
    D -->|Store Event| F
    E -->|Fetch Events| F
    E -->|Fetch Mapping| G
    E -->|Cache Results| H
    I -->|Process Events| E
Diagram

3. API design

  • POST /login: Record a login event with user_id.
  • GET /mau: Retrieve the MAU for a specified date range.

4. Data model & storage

Datastores:

  • Event Store (NoSQL): Used for storing login events. Chosen for its scalability and ability to handle high write throughput.
  • User Mapping Store (SQL): Stores the mapping between old and new user_id. Chosen for its strong consistency guarantees.

Key Tables:

  • LoginEvents: {user_id, timestamp}
  • UserMapping: {user_id_old, user_id_new}

Partition Key:

  • LoginEvents partitioned by user_id to distribute load evenly.

5. Deep dive

The core challenge is ensuring accurate MAU computation across the user_id rehash. Without the mapping, distinct counts will be inflated for windows overlapping date T.

sequenceDiagram
    participant MAUService as MAU Calculation Service
    participant EventStore as Event Store
    participant MappingStore as User Mapping Store
    participant Cache as Redis Cache

    MAUService->>EventStore: Fetch login events for [d-29, d]
    MAUService->>MappingStore: Fetch user_id mapping for date range
    MAUService->>Cache: Check cached MAU
    alt Cache Hit
        Cache-->>MAUService: Return cached MAU
    else Cache Miss
        MAUService->>MAUService: Compute distinct user_id
        MAUService->>Cache: Cache computed MAU
    end
Diagram

6. Scale, bottlenecks & trade-offs

Replication and Sharding:

  • The Event Store should be sharded by user_id to handle large volumes of data efficiently.
  • The User Mapping Store should be replicated across multiple nodes to ensure availability and fault tolerance.

Caching:

  • Use Redis to cache computed MAU results to reduce computation overhead for frequently queried date ranges.

Single Points of Failure:

  • Ensure load balancers and key services are redundant to prevent single points of failure.

Trade-offs:

  • Consistency vs. Availability: Opt for eventual consistency in the Event Store to improve availability and write throughput.
  • Push vs. Pull: Use a pull-based approach for MAU computation to allow flexibility in handling data rehash scenarios.

By implementing a robust user mapping mechanism and leveraging caching, the system can accurately compute MAU even in the presence of user_id rehashing, ensuring minimal bias and operational resilience.

System designEasyData ScientistTechnical Screen

16. You work at a ridesharing company and want to measure the impact of a new membership feature on rides-per-user (RPU).

The full question

You work at a ridesharing company and want to measure the impact of a new membership feature on rides-per-user (RPU). Across the parts below you will measure this effect under three different evidentiary situations: a switchback experiment, an observational launch with no experiment, and a randomized experiment with non-compliance.

For each measurement approach, you are expected to state the key assumptions, name the likely pitfalls, and propose at least one robustness or sensitivity check.

Constraints & Assumptions

  • The outcome of interest is rides-per-user (RPU); in Part C you also estimate impact on profit-per-user (PPU), a derived metric (e.g. revenue per user minus cost per user).
  • The marketplace has two-sided interference: a user's experience (price, ETA, availability) depends on other users and on the supply of drivers, so naive user-level randomization can leak across units. Exception: in Part B you may assume supply is unlimited, so supply constraints do not confound the outcome through availability.
  • Treatment in Part A is the membership experience/eligibility being switched on or off at the (city × time) level; in Parts B and C treatment is an individual user actually holding membership.
  • You have access to standard pre-treatment user history (past rides, spend, tenure, app activity, geography) and city-day operational signals (weather, surge, marketing spend).

Clarifying Questions to Ask

  • What exactly is the decision the measurement will inform — a global launch/no-launch call, or sizing the expected lift for forecasting?
  • Is membership reversible (a per-trip benefit that can be toggled) or a sticky enrollment state that persists once a user joins? This determines whether a switchback is even valid.
  • What is the minimum detectable effect and budget (number of cities, weeks of runway) we are working with?
  • How is RPU defined — over what window, over which denominator (all eligible users, active users, or members)?
  • Is the estimand of interest the effect on everyone eligible (ATE) or on the users who actually take up membership (ATT / effect on members)?

Part A — Switchback experimentation

You run a switchback experiment with randomization at (day × city) granularity.

  1. Propose a practical switchback design: what unit is randomized, the assignment scheme over time, and the duration.
  2. Explain why you generally should not take the raw aggregated city-day results and run a vanilla two-sample t-test.
  3. Describe an analysis approach that simultaneously accounts for time trends / seasonality, city-level heterogeneity, autocorrelation induced by switchbacks, and covariate adjustment.

Part B — No A/B test available (observational measurement)

Assume the membership feature was launched without an A/B test, and assume supply is unlimited (so availability does not confound the outcome).

  1. How would you estimate the causal impact of membership on RPU using propensity score matching (PSM), or a closely related propensity-score method?
  2. How would you assess whether your matching/weighting is "good enough" to trust the estimate?

Part C — A/B test exists but with non-compliance

Now assume you ran a user-level randomized experiment, but not everyone assigned to treatment actually takes up membership (one-sided or two-sided non-compliance).

  1. How would you estimate the causal effect on RPU using the Complier Average Causal Effect (CACE / LATE)?
  2. How would you compute a confidence interval for (a) the impact on RPU and (b) the impact on profit-per-user (PPU), a derived metric?

Model answer

1. Requirements & scale

Functional Requirements:

  • Measure the impact of a membership feature on rides-per-user (RPU).
  • Analyze three scenarios: switchback experiment, observational launch, and randomized experiment with non-compliance.

Non-Functional Requirements:

  • Ensure statistical validity and reliability of results.
  • Maintain user privacy and data security.

Back-of-the-envelope estimates:

  • QPS (Queries Per Second): Assume 100 cities, each with 1000 users, generating 10 rides/day.
  • Total rides = 100 cities 1000 users 10 rides = 1,000,000 rides/day.
  • Storage: Assuming each ride record is 1KB, total storage = 1,000,000 rides * 1KB = ~1TB/day.
  • Bandwidth: Each ride generates ~100KB of data (including metadata), leading to ~100GB/day.

2. High-level architecture

flowchart TD
    subgraph Client
        A["Mobile App"]
    end

    subgraph Edge/CDN
        B["Content Delivery Network"]
    end

    subgraph LoadBalancer
        C["Load Balancer"]
    end

    subgraph API_Services
        D["API Gateway"]
        E["Membership Service"]
        F["Analytics Service"]
    end

    subgraph Cache
        G["In-Memory Cache"]
    end

    subgraph Datastores
        H["SQL Database"]
        I["NoSQL Database"]
    end

    subgraph MessageQueue
        J["Message Queue"]
    end

    subgraph Workers
        K["Data Processing Worker"]
    end

    A --> B
    B --> C
    C --> D
    D --> E
    D --> F
    E --> G
    F --> G
    G --> H
    G --> I
    F --> J
    J --> K
Diagram

3. API design

  • GET /membership/status: Check membership eligibility and status.
  • POST /membership/activate: Activate membership for a user.
  • GET /analytics/rpu: Retrieve RPU metrics for analysis.

4. Data model & storage

  • Chosen Datastores:
  • SQL for structured data (user profiles, membership status).
  • NoSQL for unstructured data (ride history, operational signals).
  • Key Tables:
  • Users: user_id, membership_status, rides_taken.
  • Rides: ride_id, user_id, timestamp, cost.
  • Partition/Shard Key:
  • Partition by user_id for user-related data, and by city_id for ride data.

5. Deep dive

Part A — Switchback experimentation:

  1. Design: - Randomize at the city-day level. - Alternate between treatment (membership active) and control (membership inactive) every week for 4 weeks.
  2. Why not vanilla t-test: - Raw aggregated results ignore time trends, seasonality, and city-level differences, leading to biased estimates.
  3. Analysis Approach: - Use a mixed-effects model to account for: - Time trends (fixed effects). - City-level heterogeneity (random effects). - Autocorrelation (ARIMA model). - Covariate adjustment (include user history as covariates).
sequenceDiagram
    participant User
    participant MembershipService
    participant AnalyticsService

    User->>MembershipService: Request membership status
    MembershipService-->>User: Return status
    User->>MembershipService: Activate membership
    MembershipService-->>AnalyticsService: Log membership activation
    AnalyticsService-->>MembershipService: Update RPU metrics
Diagram

6. Scale, bottlenecks & trade-offs

  • Replication: Use multiple cities to replicate results.
  • Sharding: Shard data by user_id and city_id to improve query performance.
  • Caching: Implement caching for frequently accessed data (e.g., RPU metrics).
  • Single Points of Failure: Ensure redundancy in critical services (e.g., Membership Service).
  • Trade-offs:
  • CAP Theorem: Prioritize availability over consistency during peak times.
  • Push vs Pull: Use push notifications for membership updates to users.
  • SQL vs NoSQL: Use SQL for transactional data and NoSQL for analytics to balance performance and flexibility.
TechnicalEasyData ScientistOnsite

17. You are interviewing for a Data Scientist role and are given access to Uber / Uber Eats data.

The full question

You are interviewing for a Data Scientist role and are given access to Uber / Uber Eats data. Answer the following about confounding in causal inference:

  1. Define confounding in the context of estimating causal effects from observational data. Explain what a confounder is and why it can bias an observed relationship between an exposure and an outcome.
  2. Give a concrete Uber-related example (avoid generic demographic examples like age/sex). Your example should clearly identify:
  • the treatment / exposure (X),
  • the outcome (Y), and
  • the confounder (Z) that affects both X and Y.

Explain intuitively the direction of the bias (how it could manufacture a false effect or hide a real one).

  1. Describe at least two practical ways you would detect and/or mitigate confounding in an analysis (in the design or the modeling), and state what assumptions each method requires.

Model answer

1. Define Confounding

Confounding occurs in causal inference when an external variable, known as a confounder, influences both the treatment/exposure and the outcome, potentially leading to a biased estimation of the causal effect. A confounder is a variable that is correlated with both the independent variable (treatment/exposure) and the dependent variable (outcome). This correlation can create a spurious association between the treatment and the outcome, either exaggerating or masking the true causal relationship.

2. Concrete Uber-Related Example

  • Treatment/Exposure (X): The number of promotional discounts offered to drivers.
  • Outcome (Y): The total number of rides completed by drivers.
  • Confounder (Z): Weather conditions.

In this example, weather conditions can act as a confounder because they influence both the number of promotional discounts offered and the number of rides completed. For instance, during bad weather, Uber might increase promotional discounts to encourage drivers to work, while the same weather conditions might naturally lead to more ride requests as people prefer not to walk or drive themselves. This can create a false impression that the promotional discounts alone are causing an increase in rides, when in fact, the weather is influencing both.

Direction of Bias: If not accounted for, the analysis might overestimate the effect of promotional discounts on ride completions, as the increase in rides could be partly due to adverse weather conditions rather than the discounts themselves.

3. Detecting and Mitigating Confounding

  1. Stratification: - Method: Divide the data into strata or groups based on the confounder (e.g., different weather conditions) and analyze the relationship between the exposure and outcome within each stratum. - Assumptions: Assumes that within each stratum, the confounder is evenly distributed, allowing for a clearer view of the causal relationship between the treatment and outcome.
  2. Multivariable Regression: - Method: Include the confounder as a covariate in a regression model to adjust for its effect when estimating the relationship between the exposure and outcome. - Assumptions: Assumes that the relationship between the confounder and both the exposure and outcome is linear and that there are no interactions between the confounder and the exposure.

Both methods aim to isolate the causal effect of the treatment by accounting for the influence of the confounder, thus providing a more accurate estimate of the causal relationship.

TechnicalEasyData ScientistTechnical screen

18. Facebook has a content team that labels pieces of content on the platform as spam or not spam.

The full question

Facebook has a content team that labels pieces of content on the platform as spam or not spam. 90% of them are diligent raters and will label 20% of the content as spam and 80% as non-spam. The remaining 10% are non-diligent raters and will label 0% of the content as spam and 100% as non-spam. Assume the pieces of content are labeled independently from one another, for every rater. Given that a rater has labeled 4 pieces of content as good, what is the probability that they are a diligent rater?

Model answer

The flow

  1. Identify the distributions: Recognize the problem as a Bayesian probability question.
  2. Write the formula: Use Bayes' Theorem to calculate the desired probability.
  3. Compute the likelihoods: Calculate the probability of the observed data given each type of rater.
  4. Apply Bayes' Theorem: Substitute the known probabilities into the formula.
  5. Compute the posterior probability: Solve for the probability that the rater is diligent given the observed data.
  6. Interpret the result: Discuss implications and limitations of the result.

The answer

1. Identify the distributions

  • We have two types of raters: diligent and non-diligent.
  • Diligent raters label 20% as spam and 80% as non-spam.
  • Non-diligent raters label 0% as spam and 100% as non-spam.

2. Write the formula

  • We use Bayes' Theorem: $$ P(D | G) = \frac{P(G | D) \cdot P(D)}{P(G)} $$ where:
  • $P(D | G)$ is the probability that the rater is diligent given 4 pieces labeled as good.
  • $P(G | D)$ is the probability of labeling 4 pieces as good given the rater is diligent.
  • $P(D)$ is the prior probability of a rater being diligent.
  • $P(G)$ is the total probability of labeling 4 pieces as good.

3. Compute the likelihoods

  • $P(G | D) = (0.8)^4 = 0.4096$
  • $P(G | \neg D) = (1)^4 = 1$

4. Apply Bayes' Theorem

  • $P(D) = 0.9$, the probability of a rater being diligent.
  • $P(\neg D) = 0.1$, the probability of a rater being non-diligent.
  • $P(G) = P(G | D) \cdot P(D) + P(G | \neg D) \cdot P(\neg D)$ $$ P(G) = 0.4096 \cdot 0.9 + 1 \cdot 0.1 = 0.46864 $$

5. Compute the posterior probability

  • Substitute into Bayes' Theorem: $$ P(D | G) = \frac{0.4096 \cdot 0.9}{0.46864} \approx 0.786 $$

6. Interpret the result

  • The probability that the rater is diligent given they labeled 4 pieces as good is approximately 78.6%.
  • This high probability suggests that labeling all pieces as good is more likely done by a diligent rater.
  • The assumption of independence and the specific labeling behavior of raters are crucial for this result.

Why this works

  • Testing Bayesian reasoning: The question assesses understanding of Bayes' Theorem and its application.
  • Sanity check: A strong answer checks the reasonableness of the result (e.g., high probability aligns with diligent behavior).
  • Common pitfalls: Weak answers might ignore the prior probabilities or miscalculate likelihoods, leading to incorrect conclusions.
  • Assumptions clarity: A strong answer clearly states assumptions, like independence of labels and fixed rater behavior.
TechnicalEasyData ScientistTechnical Screen

19. You are analyzing repeated flips of a (possibly unfair) coin.

The full question

You are analyzing repeated flips of a (possibly unfair) coin.

Setup

Let the probability of Heads be (p) (unknown in general). Assume flips are independent and identically distributed.

Part A — Expected value for an unfair coin

Define a random variable (X) for a single flip:

  • (X = 1) if the flip is Heads
  • (X = 0) if the flip is Tails
  1. Compute (\mathbb{E}[X]).
  2. (Optional but common follow-up) Compute (\mathrm{Var}(X)).

Part B — “Getting a 3” using a geometric distribution

Now flip the coin repeatedly until the first Head appears.

Let (T) be the number of flips needed to get the first Head (so (T\in{1,2,3,\dots})).

  1. Write the distribution of (T) and identify it.
  2. Compute (\mathbb{P}(T=3)) in terms of (p).
  3. For a fair coin ((p=0.5)), compute the numerical value of (\mathbb{P}(T=3)).
  4. Compute (\mathbb{E}[T]).

Part C — Is the coin fair? (p-value reasoning)

Suppose you ran this “flip-until-first-Head” experiment once and observed (T=3).

You want to test:

  • (H_0: p=0.5) (fair coin)
  • (H_1: p<0.5) (coin is biased toward Tails; Heads are rarer)
  1. Propose a reasonable p-value for this one observation using an appropriate tail probability under (H_0).
  2. Briefly explain what is and is not learnable from a single observation, and what you would do instead to make the test meaningful (e.g., repeat the experiment (n) times).

Model answer

Part A — Expected value for an unfair coin

  1. Compute \(\mathbb{E}[X]\):
  • The expected value \(\mathbb{E}[X]\) for a random variable \(X\) that takes the value 1 with probability \(p\) (Heads) and 0 with probability \(1-p\) (Tails) is calculated as follows: \[ \mathbb{E}[X] = 1 \cdot p + 0 \cdot (1-p) = p \]
  1. Compute \(\mathrm{Var}(X)\):
  • The variance \(\mathrm{Var}(X)\) of a random variable \(X\) is given by: \[ \mathrm{Var}(X) = \mathbb{E}[X^2] - (\mathbb{E}[X])^2 \]
  • Since \(X^2 = X\) (because \(X\) is either 0 or 1), we have: \[ \mathbb{E}[X^2] = \mathbb{E}[X] = p \]
  • Therefore, the variance is: \[ \mathrm{Var}(X) = p - p^2 = p(1-p) \]

Part B — “Getting a 3” using a geometric distribution

  1. Distribution of \(T\):
  • \(T\) follows a geometric distribution with parameter \(p\), denoted as \(T \sim \text{Geom}(p)\). This distribution models the number of Bernoulli trials needed to get the first success (Head).
  1. Compute \(\mathbb{P}(T=3)\):
  • The probability that the first Head appears on the third flip is: \[ \mathbb{P}(T=3) = (1-p)^2 \cdot p \]
  1. For a fair coin (\(p=0.5\)), compute \(\mathbb{P}(T=3)\):
  • Substituting \(p = 0.5\) into the probability formula: \[ \mathbb{P}(T=3) = (1-0.5)^2 \cdot 0.5 = 0.25 \cdot 0.5 = 0.125 \]
  1. Compute \(\mathbb{E}[T]\):
  • The expected value of a geometric distribution \(\text{Geom}(p)\) is: \[ \mathbb{E}[T] = \frac{1}{p} \]

Part C — Is the coin fair? (p-value reasoning)

  1. Propose a reasonable p-value:
  • To test \(H_0: p=0.5\) against \(H_1: p<0.5\), we calculate the tail probability under \(H_0\) for observing \(T=3\) or more: \[ \mathbb{P}(T \geq 3) = \sum_{k=3}^{\infty} \mathbb{P}(T=k) = (1-0.5)^2 = 0.25 \]
  • This probability represents the p-value for the test.
  1. Explanation and further steps:
  • What is learnable: From a single observation, we can only compute a p-value, which indicates how extreme the observation is under the null hypothesis. However, it does not provide conclusive evidence about the fairness of the coin.
  • What to do instead: To make the test meaningful, repeat the experiment \(n\) times to gather more data. Calculate the proportion of trials where \(T=3\) or more, and use this empirical distribution to perform a more robust hypothesis test. This approach increases the statistical power of the test and provides a more reliable conclusion.
TechnicalEasyData ScientistOnsite

20. Before the onsite, you completed a take-home project analyzing an A/B test (you can assume typical product experimentation data: assignment, exposu…

The full question

Before the onsite, you completed a take-home project analyzing an A/B test (you can assume typical product experimentation data: assignment, exposure, user events, and outcome metrics).

During the onsite, you must present slides and answer deep-dive questions.

What you should prepare

  1. Summarize the experiment goal, design, and key assumptions.
  2. Validate experiment integrity and data quality (what checks do you run?).
  3. Estimate the treatment effect on pre-specified metrics.
  4. Discuss interpretation and limitations (confounding risks, interference, multiple testing, seasonality).
  5. Provide a clear ship/no-ship recommendation and next steps.

Interviewer follow-ups to expect

  • What would you do if you see a sample ratio mismatch?
  • How do you pick primary vs guardrail metrics?
  • How do you handle many metrics or repeated looks at the data?
  • What if average impact is neutral but a segment improves a lot?

Model answer

1. Experiment Summary

  • Goal: Determine if a new feature increases user engagement on PayPal's platform.
  • Design: Randomized controlled trial with two groups: control (no feature) and treatment (new feature).
  • Key Assumptions:
  • Random assignment ensures comparable groups.
  • Sufficient sample size for statistical power.
  • No interference between users (SUTVA).

2. Validating Experiment Integrity and Data Quality

  • Randomization Check: Verify that the assignment to control and treatment groups is random and balanced.
  • Sample Ratio Mismatch: Check if the proportion of users in each group matches expectations. Investigate any discrepancies.
  • Data Completeness: Ensure all expected data points (assignment, exposure, events) are present.
  • Outlier Detection: Identify and assess the impact of outliers on the results.

3. Estimating Treatment Effect

  • Calculate the difference in key metrics (e.g., engagement rate) between treatment and control groups.
  • Use statistical tests (e.g., t-tests) to determine if observed differences are significant.
  • Adjust for any covariates if necessary to refine estimates.

4. Interpretation and Limitations

  • Confounding Risks: Consider external factors that might influence results, such as concurrent promotions.
  • Interference: Ensure no cross-group contamination, such as users discussing the feature.
  • Multiple Testing: Apply corrections (e.g., Bonferroni) if multiple hypotheses are tested.
  • Seasonality: Account for time-based variations in user behavior that might affect results.

5. Recommendation and Next Steps

  • Ship/No-Ship Decision: Recommend shipping if the treatment effect is positive and significant, considering business goals.
  • Next Steps:
  • Further segmentation analysis to identify user groups with differential impacts.
  • Plan for a phased rollout to monitor real-world performance.
  • Continuous monitoring of key metrics post-launch to ensure sustained impact.

Interviewer Follow-ups

  • Sample Ratio Mismatch: Investigate potential causes such as technical errors in user assignment or data collection issues.
  • Primary vs. Guardrail Metrics: Choose primary metrics that align with business goals (e.g., engagement) and guardrail metrics to ensure no adverse effects (e.g., user churn).
  • Handling Many Metrics: Use a hierarchical testing approach to prioritize metrics and control false discovery rates.
  • Segment Improvement: If a segment shows significant improvement, consider targeted feature rollouts or further analysis to understand underlying factors.

Practice these out loud, don't memorise them

Reading an answer is not the same as being able to give one under pressure. ChannelPulse plays the interviewer, asks the follow-ups, and scores each answer with feedback and a model answer so you can hear the gap between what you said and what lands.

Get ChannelPulse Browse all questions