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 ScientistTechnical Screen

13. 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

14. Shopify is launching a Shopify App Store where merchants can browse/install apps built by third-party developers (some paid, some free).

The full question

Shopify is launching a Shopify App Store where merchants can browse/install apps built by third-party developers (some paid, some free). You are the Data Scientist supporting the launch.

1) Define success

Propose a success measurement framework with:

  • Primary (north-star) metric(s)
  • Input/leading metrics (activation, engagement)
  • Diagnostic metrics (funnel rates, segment cuts)
  • Guardrails (latency, merchant churn, refunds/chargebacks, spam/fraud, support burden)

Be explicit about whose success you’re optimizing for (merchants, developers, Shopify) and how you’d balance tradeoffs.

2) Data + instrumentation

Specify what data you’d need and where it comes from.

  • List key event streams (e.g., clickstream/browse/search, install/uninstall, subscription/billing, app usage, support tickets).
  • Propose a minimal data model (example fact/dimension tables) that would support the metrics.

Assume events arrive in near-real-time; define any time windowing (e.g., daily in UTC) and identity rules (merchant_id, app_id, developer_id, session_id).

3) Experimentation plan

Design at least one experiment to improve App Store outcomes (e.g., ranking algorithm, pricing surfaces, recommendation modules, onboarding prompts). Include:

  • Unit of randomization (merchant vs session), eligibility, and duration
  • Primary/secondary/guardrail metrics
  • Key threats to validity (network effects, interference, novelty effects, selection bias)
  • How you’d analyze (e.g., CUPED, stratification) and make a ship/no-ship decision

---

Part B — Data interpretation + visualization: traffic spike with worse funnel

You’re given a dataset with 3 years of daily metrics for the App Store. You notice:

  • A

Model answer

1. Requirements & scale

Functional Requirements:

  • Merchants can browse and search for apps.
  • Merchants can install/uninstall apps.
  • Apps can be free or paid.
  • Developers can submit apps for listing.
  • Payment processing for paid apps.

Non-Functional Requirements:

  • High availability and low latency for browsing and installation.
  • Secure payment processing.
  • Scalability to handle increasing numbers of apps and users.
  • Robust fraud detection and prevention.

Scale Estimates:

  • Assume 100,000 merchants, 10,000 apps, and 1,000,000 daily page views.
  • Average session duration: 5 minutes.
  • QPS (Queries Per Second) for browsing: 1,000 QPS.
  • Storage: Assuming each app listing is 1KB, total storage for app metadata is 10MB.
  • Bandwidth: Assuming 1MB per session, total daily bandwidth is approximately 1TB.

2. High-level architecture

flowchart TD
    subgraph Client
        A[Merchant]
        B[Developer]
    end

    subgraph Edge/CDN
        C[CDN]
    end

    subgraph Load Balancer
        D[Load Balancer]
    end

    subgraph API / Services
        E[App Service]
        F[Payment Service]
        G[Search Service]
    end

    subgraph Cache
        H[Redis Cache]
    end

    subgraph Datastores
        I["SQL DB (App Metadata)"]
        J["NoSQL DB (App Usage)"]
        K["Blob Storage (App Assets)"]
    end

    subgraph Message Queue
        L[Kafka]
    end

    subgraph Workers
        M[Fraud Detection Worker]
    end

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

3. API design

  • GET /apps: Retrieve a list of apps for browsing.
  • POST /apps: Submit a new app for listing.
  • GET /apps/{id}: Retrieve details of a specific app.
  • POST /apps/{id}/install: Install an app for a merchant.
  • POST /apps/{id}/uninstall: Uninstall an app for a merchant.
  • POST /payments: Process payment for a paid app.

4. Data model & storage

Datastores:

  • SQL Database for app metadata (e.g., MySQL).
  • NoSQL Database for app usage data (e.g., MongoDB).
  • Blob Storage for app assets (e.g., AWS S3).

Key Tables:

  • App: app_id, name, developer_id, price, category, rating.
  • MerchantApp: merchant_id, app_id, install_date, status.
  • Developer: developer_id, name, contact_info.
  • Transaction: transaction_id, merchant_id, app_id, amount, status.

Partition Key:

  • App: app_id
  • MerchantApp: merchant_id

5. Deep dive

The core of the Shopify App Store is the app browsing and installation process. This involves efficiently retrieving app listings and managing installations.

sequenceDiagram
    participant M as Merchant
    participant S as App Service
    participant C as Cache
    participant DB as SQL DB

    M->>S: GET /apps
    S->>C: Check cache for app list
    alt Cache hit
        C-->>S: Return app list
    else Cache miss
        S->>DB: Query app list
        DB-->>S: Return app list
        S->>C: Update cache with app list
    end
    S-->>M: Return app list

    M->>S: POST /apps/{id}/install
    S->>DB: Record installation
    DB-->>S: Confirm installation
    S-->>M: Installation success
Diagram

6. Scale, bottlenecks & trade-offs

Scalability:

  • Use horizontal scaling for the API layer and databases.
  • Implement caching (e.g., Redis) to reduce database load.

Bottlenecks:

  • Database write operations during peak installation times.
  • Payment processing latency.

Trade-offs:

  • Consistency vs. Availability: Prioritize availability for browsing, but ensure consistency for transactions.
  • Push vs. Pull: Use pull-based updates for app listings to minimize unnecessary data transfer.
  • SQL vs. NoSQL: Use SQL for structured app metadata and NoSQL for flexible app usage data.

Replication and Sharding:

  • Use database replication for high availability.
  • Shard databases by merchant_id to distribute load.

Guardrails:

  • Implement rate limiting to prevent abuse.
  • Monitor latency and error rates to maintain performance.
  • Use fraud detection mechanisms to protect against chargebacks and spam.
System designEasyData ScientistTechnical Screen

15. You want to launch a new pricing model that incentivizes shoppers to place/pick up more orders during rush hours in a two-sided marketplace (supply…

The full question

You want to launch a new pricing model that incentivizes shoppers to place/pick up more orders during rush hours in a two-sided marketplace (supply and demand interact). You suspect network effects / interference: changing prices for some users may affect availability, ETAs, or acceptance rates for others.

Task

Design an experiment to evaluate the new pricing model.

Constraints

  • A standard user-level A/B test may be invalid due to spillovers (interference) across users.
  • The marketplace has heterogeneous geographies with different baselines.

Requirements

Your design should include:

  1. Unit of randomization and why (e.g., geo/market-level).
  2. How you will choose treatment/control markets (e.g., matched pairs / lookalikes).
  3. Primary metric (north star) and a set of diagnostic + guardrail metrics.
  4. How you handle bias/confounding (seasonality, pre-trends, market differences).
  5. Ramp plan, duration, and how you’ll estimate power/MDE at a high level.
  6. Risks: spillovers across nearby markets, partial compliance, concurrent changes.

Output

Provide a clear experimental plan and analysis approach (e.g., difference-in-differences).

Model answer

1. Requirements & scale

Functional Requirements:

  • Implement a new pricing model to incentivize shoppers during rush hours.
  • Evaluate the impact of the pricing model on order volume, ETAs, and acceptance rates.
  • Ensure the experiment accounts for network effects and interference.

Non-Functional Requirements:

  • Maintain system reliability and availability during the experiment.
  • Ensure data integrity and accurate measurement of metrics.

Scale Estimates:

  • Assume 1 million daily active users (DAU) with peak usage during rush hours.
  • Estimate 100,000 orders per hour during peak times, leading to approximately 28 orders per second (QPS).
  • Storage needs for experiment data: Assuming 1 KB per order, approximately 100 MB per day.

2. High-level architecture

flowchart TD
    subgraph Client
        A[User App]
    end

    subgraph Edge/CDN
        B[CDN]
    end

    subgraph Load Balancer
        C[Load Balancer]
    end

    subgraph API / Services
        D[Pricing Service]
        E[Order Service]
    end

    subgraph Cache
        F[Redis]
    end

    subgraph Datastores
        G[SQL Database]
        H[NoSQL Database]
    end

    subgraph Message Queue
        I[Kafka]
    end

    subgraph Workers
        J[Analytics Worker]
    end

    A -->|Order Request| B
    B --> C
    C --> D
    D -->|Fetch Pricing| F
    F --> D
    D -->|Apply Pricing| E
    E -->|Store Order| G
    E -->|Log Order| I
    I --> J
    J -->|Analyze Data| H
Diagram

3. API design

  • POST /orders: Create a new order with applied pricing.
  • GET /pricing: Retrieve current pricing model details.
  • POST /analytics: Submit analytics data for experiment evaluation.

4. Data model & storage

Datastores:

  • SQL Database: Used for storing order details, ensuring ACID transactions.
  • NoSQL Database: Used for storing experiment analytics data, supporting flexible schema and high write throughput.
  • Redis: Used for caching pricing data to reduce latency.

Key Tables:

  • Orders: order_id, user_id, pricing_model, timestamp, order_details.
  • PricingModels: model_id, description, rush_hour_multiplier.
  • Analytics: entry_id, market_id, metric_name, value, timestamp.

Partition Key:

  • For Orders: order_id to ensure even distribution.
  • For Analytics: market_id to facilitate market-level analysis.

5. Deep dive

The core of this experiment is managing and analyzing the pricing model's impact across different markets while mitigating spillover effects.

sequenceDiagram
    participant User
    participant PricingService
    participant OrderService
    participant AnalyticsWorker

    User->>PricingService: Request Pricing
    PricingService->>Redis: Fetch Cached Pricing
    Redis-->>PricingService: Return Pricing
    PricingService-->>User: Return Pricing Model

    User->>OrderService: Place Order with Pricing
    OrderService->>SQL Database: Store Order Details
    OrderService->>Kafka: Log Order Event

    AnalyticsWorker->>Kafka: Consume Order Event
    AnalyticsWorker->>NoSQL Database: Store Analytics Data
Diagram

6. Scale, bottlenecks & trade-offs

Replication and Sharding:

  • SQL Database: Use master-slave replication for read scalability and high availability.
  • NoSQL Database: Employ sharding based on market_id to handle high write throughput and facilitate market-level analysis.

Caching:

  • Use Redis to cache pricing data, reducing load on the Pricing Service and minimizing latency.

Single Points of Failure:

  • Ensure redundancy in Load Balancer and Redis to prevent single points of failure.

Trade-offs:

  • Consistency vs. Availability: Prioritize availability in NoSQL for analytics data, accepting eventual consistency.
  • Push vs. Pull: Use a pull model for analytics data processing to allow for batch processing and reduce system load during peak times.

Risks:

  • Spillovers: Mitigate by randomizing at the market level and using difference-in-differences analysis.
  • Partial Compliance: Monitor and adjust for users not adhering to the pricing model.
  • Concurrent Changes: Isolate the experiment from other changes in the system to ensure accurate attribution of effects.
System designEasyData ScientistTechnical Screen

16. You work on a fintech product with these existing tables (UTC timestamps).

The full question

You work on a fintech product with these existing tables (UTC timestamps). You may only use these tables/columns; if a metric cannot be measured directly, you must propose a defensible proxy using available data.

Tables

users

  • user_id BIGINT PRIMARY KEY
  • create_date TIMESTAMP
  • (optional if present) country VARCHAR

transactions

  • transaction_id BIGINT PRIMARY KEY
  • user_id BIGINT REFERENCES users(user_id)
  • transaction_time TIMESTAMP
  • product VARCHAR -- includes values like 'crypto', and may include 'ultra' if the plan is represented as a product
  • amount_gbp NUMERIC(18,2)
  • status VARCHAR -- 'completed' / 'declined'
  • (optional if present) ip_country VARCHAR

activity

  • user_id BIGINT REFERENCES users(user_id)
  • event_time TIMESTAMP
  • product VARCHAR -- may include 'ultra'
  • event_type VARCHAR -- 'view' / 'click'

Scenario A: Ultra subscription launch (open-ended)

A new Ultra subscription plan launches. In a 1-month evaluation window after launch: 1) Define what “success” means with a primary metric, diagnostic metrics, and guardrail metrics. 2) Describe key risks to validity (e.g., seasonality, marketing campaigns, selection bias) and how you’d mitigate them. 3) Write example SQL (or pseudo-SQL) to compute your chosen metrics using only the tables above.

Scenario B: FinCrime—identify suspicious transactions (open-ended)

You partner with the Financial Crime team to flag suspicious behavior. 1) Propose a rule-based detection approach that turns “suspicious” into actionable, testable rules using available data. 2) Write example SQL (or pseudo-SQL) that outputs su

Model answer

1. Requirements & scale

Functional Requirements:

  • Scenario A: Ultra Subscription Launch
  • Measure the success of the Ultra subscription plan launch.
  • Define primary, diagnostic, and guardrail metrics.
  • Evaluate the metrics within a 1-month window.
  • Scenario B: FinCrime Detection
  • Identify and flag suspicious transactions.
  • Implement rule-based detection using existing data.

Non-Functional Requirements:

  • High availability and consistency, especially for financial transactions.
  • Scalability to handle increasing user and transaction volumes.
  • Low latency for real-time transaction processing and analysis.

Scale Estimates:

  • Assume 1 million users, with 10% subscribing to the Ultra plan.
  • Average of 5 transactions per user per month.
  • Estimated 500,000 transactions per month.
  • Assume each transaction record is approximately 200 bytes, resulting in 100 MB of transaction data per month.

2. High-level architecture

flowchart TD
    subgraph Client
        A[User Devices]
    end

    subgraph Edge/CDN
        B[CDN]
    end

    subgraph Load Balancer
        C[Load Balancer]
    end

    subgraph API / Services
        D[API Gateway]
        E[Transaction Service]
        F[User Service]
    end

    subgraph Cache
        G[Redis Cache]
    end

    subgraph Datastores
        H["SQL DB (PostgreSQL)"]
    end

    subgraph Message Queue
        I[Kafka]
    end

    subgraph Workers
        J[Analytics Worker]
        K[Fraud Detection Worker]
    end

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

3. API design

  • GET /transactions/{user_id}: Retrieve transactions for a user.
  • POST /transactions: Create a new transaction.
  • GET /users/{user_id}: Retrieve user details.
  • POST /subscriptions: Subscribe a user to the Ultra plan.

4. Data model & storage

Datastore Choice:

  • SQL Database (PostgreSQL): Chosen for its ACID compliance, which is critical for financial transactions.

Key Tables:

  • Users Table: user_id as the primary key.
  • Transactions Table: transaction_id as the primary key, user_id as a foreign key.
  • Activity Table: user_id as a foreign key.

Partitioning Strategy:

  • Partition the transactions table by transaction_time for efficient time-based queries.

5. Deep dive

Scenario A: Ultra Subscription Launch

  • Primary Metric: Number of Ultra subscriptions.
  • Diagnostic Metrics: User engagement (views/clicks on Ultra), conversion rate from views to subscriptions.
  • Guardrail Metrics: Churn rate of existing users, transaction failures.

SQL Example:

-- Primary Metric: Count of Ultra subscriptions
SELECT COUNT(*) AS ultra_subscriptions
FROM transactions
WHERE product = 'ultra' AND transaction_time BETWEEN '2023-01-01' AND '2023-01-31';

-- Diagnostic Metric: Conversion rate
SELECT 
    (SELECT COUNT(*) FROM transactions WHERE product = 'ultra' AND transaction_time BETWEEN '2023-01-01' AND '2023-01-31')::float /
    (SELECT COUNT(*) FROM activity WHERE product = 'ultra' AND event_type = 'view' AND event_time BETWEEN '2023-01-01' AND '2023-01-31') AS conversion_rate;

Scenario B: FinCrime Detection

  • Rule-Based Approach: Flag transactions over a certain amount or from suspicious countries.

SQL Example:

-- Suspicious transactions: High amount or from specific countries
SELECT transaction_id, user_id, amount_gbp, ip_country
FROM transactions
WHERE (amount_gbp > 10000 OR ip_country IN ('CountryX', 'CountryY'))
AND status = 'completed';

6. Scale, bottlenecks & trade-offs

  • Replication: Use database replication for high availability and read scalability.
  • Sharding: Consider sharding the transactions table by user_id for horizontal scaling.
  • Caching: Implement Redis caching for frequently accessed user and transaction data to reduce database load.
  • Single Points of Failure: Ensure redundancy in the load balancer and database layers to prevent downtime.
  • Trade-offs: Prioritize consistency over availability for financial transactions (CAP theorem). Use asynchronous processing for non-critical analytics to reduce latency.
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