← Uber Interview Insights

Uber·Data Scientist·Technical Phone Screen·Senior

Senior
Jul 2026

Summary

Uber DS technical screen, two parts back to back. The SQL problem was gnarly and the Python section had a twist I didn't fully see coming. Felt okay leaving but not confident.

Questions Asked (3)

Q1

Write a SQL query to compute 48-hour unique CTR for a specific campaign broken down by variant. Deduplicate sends to the earliest send per user per campaign on or after a given date, exclude internal user accounts, and define CTR as distinct users with at least one click within 48 hours of their send time divided by distinct users sent. Return campaign, variant, send counts, unique clickers, and CTR. Also return a single row showing the absolute lift between test and control, and optionally include the counts needed to compute a 95% confidence interval for that lift downstream.

A/B Testing & ExperimentationProduct Analytics & MetricsData Modeling
Author's notes

This one took me a while to untangle.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and business definitions (e.g., what constitutes a send, click, internal account, and the date filter). Then structure the query using CTEs: first deduplicate sends to the earliest per user per campaign after the given date, filter out internal users, join clicks within 48 hours, and aggregate per variant. Finally, compute CTR and use window functions or a self-join to calculate the absolute lift between test and control, optionally including counts for confidence interval calculation.

Pro tip: Mention that you would validate the 48-hour window logic by checking edge cases (e.g., clicks exactly at 48 hours) and ensure that the deduplication uses the earliest send per user per campaign, not per variant, to avoid skewing the experiment. Also, note that for confidence intervals, you'd likely use a two-proportion z-test and provide the necessary counts (e.g., successes and trials per variant).

1. Clarify requirements and schema

Ask about table structures, definitions of send, click, internal accounts, and the date filter. Confirm that CTR is based on distinct users and that the 48-hour window is from send time.

2. Deduplicate sends and filter

Use a CTE with ROW_NUMBER() partitioned by user and campaign, ordered by send time, to select the earliest send per user per campaign on or after the given date. Exclude internal accounts.

3. Identify unique clickers within 48 hours

Join the deduplicated sends to clicks on user and campaign, where click time is between send time and send time + 48 hours. Use DISTINCT to count unique users who clicked.

4. Aggregate per variant and compute CTR

Group by campaign and variant to get send counts and unique clickers. Compute CTR as unique clickers divided by send counts.

5. Calculate lift and prepare for confidence interval

Use a self-join or window functions to compute the absolute lift between test and control. Include counts (e.g., successes and trials) for each variant to enable downstream confidence interval calculation.

Key Points to Mention

  • Deduplication logic: earliest send per user per campaign, not per variant, to avoid multiple exposures.
  • 48-hour window: click time >= send time AND click time < send time + INTERVAL '48 hours' (or <= depending on definition).
  • Exclusion of internal accounts: filter using a flag or email domain.
  • CTR definition: distinct users with at least one click / distinct users sent.
  • Absolute lift: difference in CTR between test and control variants.
  • Confidence interval: provide counts (e.g., number of users sent and number of unique clickers) for each variant to compute a two-proportion z-test.

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

Q2

Given a pandas DataFrame with true labels, predicted probabilities, and sample weights, write code to: plot the precision-recall curve, find the threshold that maximizes weighted F1 using the sample weights, and compute precision at the top 1% of the population by predicted score with deterministic tie-breaking.

Product Analytics & MetricsTechnical Trade-offsAlgorithms & Data Structures
Author's notes

The PR curve part was fine, sklearn makes it easy.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data schema and metric definitions, then outline a vectorized pandas/numpy solution that leverages sklearn's precision_recall_curve and custom threshold search. Emphasize deterministic tie-breaking and weighted F1 computation, and discuss trade-offs between exact and approximate methods for large datasets.

Pro tip: Mention that you would validate the threshold on a holdout set and consider the business impact of precision at top 1%, as Uber often cares about high-precision interventions. Also, use numpy's argsort with stable kind for deterministic tie-breaking.

1. Clarify requirements and data schema

Confirm column names for true labels, predicted probabilities, and sample weights. Ask about the expected size of the DataFrame and whether ties in predicted scores are common.

2. Plot precision-recall curve

Use sklearn.metrics.precision_recall_curve with sample weights to compute precision and recall at various thresholds, then plot using matplotlib. Note that precision_recall_curve does not directly support sample weights, so you may need to compute weighted precision and recall manually.

3. Find threshold maximizing weighted F1

Compute weighted F1 for each threshold by combining weighted precision and recall. Use numpy to vectorize the calculation and find the threshold with the maximum F1, handling ties by choosing the smallest threshold or as specified.

4. Compute precision at top 1% with deterministic tie-breaking

Sort the DataFrame by predicted score descending, using a stable sort to break ties deterministically (e.g., by original index). Select the top 1% of samples, compute weighted precision (sum of weights for true positives divided by sum of weights for selected samples).

5. Discuss scalability and validation

Mention that for large datasets, approximate methods or sampling may be needed. Suggest validating the chosen threshold on a holdout set and considering business metrics beyond F1.

Key Points to Mention

  • Weighted precision and recall: use sample weights in TP, FP, FN calculations.
  • sklearn's precision_recall_curve does not support sample weights directly; need custom implementation.
  • Deterministic tie-breaking: use stable sort (e.g., mergesort) or sort by (score, index) to ensure reproducibility.
  • Top 1% precision: define population as all samples, select top 1% by score, compute weighted precision.
  • Trade-offs: exact vs approximate methods for large data, and business implications of threshold choice.
  • Validation: use cross-validation or holdout to avoid overfitting the threshold.

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

Q3

Explain why a model can have a high ROC-AUC (around 0.86) but a very low PR-AUC (around 0.18) at 1% class prevalence. Which metric would you optimize for a marketing click-through rate use case?

Product Analytics & MetricsA/B Testing & ExperimentationTechnical Trade-offs
Author's notes

ROC-AUC uses the full negative set in its denominator so at 1% prevalence you have a massive negative class that makes it easy to look good even if your positive precision is garbage.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the mathematical relationship between ROC-AUC and PR-AUC under class imbalance, emphasizing how the large number of true negatives inflates ROC-AUC while PR-AUC focuses on the positive class. Then, for the marketing CTR use case, argue that PR-AUC is more informative because it directly measures performance on the rare positive class (clicks), and discuss how business costs and benefits might further guide metric selection.

Pro tip: Mention that in highly imbalanced settings, ROC-AUC can be misleadingly high even for a poor model, and that PR-AUC's baseline equals the prevalence (1%), so 0.18 is actually 18x better than random. This shows you understand the practical implications and can communicate them to stakeholders.

1. Define the metrics and their focus

Explain that ROC-AUC evaluates the trade-off between true positive rate and false positive rate across all thresholds, while PR-AUC evaluates the trade-off between precision and recall for the positive class.

2. Explain the impact of class imbalance

With 1% prevalence, the number of negatives is 99 times the positives. ROC-AUC remains high because the false positive rate is diluted by the large number of true negatives, whereas PR-AUC is sensitive to false positives and drops sharply.

3. Illustrate with a concrete example

For instance, if the model identifies 100 true positives and 500 false positives, the false positive rate is only 500/9900 ≈ 5%, but precision is 100/600 ≈ 17%, leading to low PR-AUC.

4. Connect to the marketing CTR use case

In CTR prediction, the positive class (clicks) is rare and the business cares about precision (avoiding wasted impressions) and recall (capturing clicks). PR-AUC directly reflects these trade-offs, while ROC-AUC can be overly optimistic.

5. Recommend the metric to optimize

Advocate for optimizing PR-AUC (or a related metric like precision@k or lift) because it aligns with business goals, but also consider the specific costs of false positives and false negatives to choose the final metric.

Key Points to Mention

  • Class imbalance: 1% prevalence means 99% negatives, which inflates ROC-AUC due to the large number of true negatives.
  • PR-AUC baseline is the prevalence (1%), so 0.18 indicates the model is 18 times better than random, while ROC-AUC baseline is 0.5.
  • ROC-AUC is threshold-independent and measures overall separability, but it can be misleading when the positive class is rare.
  • PR-AUC focuses on the positive class and is more sensitive to false positives, making it better for imbalanced problems.
  • In marketing CTR, the cost of false positives (wasted ad spend) and false negatives (missed clicks) should guide metric choice, but PR-AUC is generally preferred.
  • Alternatives like precision@k, recall@k, or F1 score can be used if a specific operating point is needed.

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