← TikTok Interview Insights

TikTok·Data Scientist·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026Remote

Summary

TikTok data scientist technical screen, heavy on applied ML evaluation theory. The whole thing was basically one long question about a classifier operating on an imbalanced dataset, broken into four parts. Left feeling like I'd done okay on parts one and two but probably fumbled the derivation at the end.

Questions Asked (4)

Q1

Given a calibrated classifier with 1% positive class prevalence and a held-out set of 10,000 examples, compute Precision, Recall, and F1 at two different thresholds (0.50 and 0.20) using the provided confusion matrix counts.

Product Analytics & MetricsTechnical Trade-offs
Author's notes

This part was fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the confusion matrix counts at each threshold (TP, FP, FN, TN) and confirm the total of 10,000 examples. Then compute precision, recall, and F1 using their standard formulas, and compare the results to discuss the trade-off between precision and recall when lowering the threshold.

Pro tip: Always state the formulas explicitly and interpret the metrics in the context of the 1% prevalence—this shows you understand that high accuracy can be misleading and that precision/recall are more informative for imbalanced data.

1. Extract confusion matrix counts

From the provided confusion matrix at each threshold, identify TP, FP, FN, TN. Verify that the sum equals 10,000 and that the number of actual positives (TP+FN) is 100 (1% of 10,000).

2. Compute precision and recall

Calculate precision = TP / (TP + FP) and recall = TP / (TP + FN) for each threshold. Show the calculations clearly.

3. Compute F1 score

Calculate F1 = 2 * (precision * recall) / (precision + recall) for each threshold. If precision and recall are both zero, F1 is zero.

4. Compare and interpret

Compare the metrics across thresholds (0.50 vs 0.20). Discuss how lowering the threshold typically increases recall but decreases precision, and what that means for the business context (e.g., TikTok content moderation).

Key Points to Mention

  • Definition and formulas for precision, recall, and F1 score.
  • The impact of class imbalance (1% prevalence) on metric interpretation.
  • The trade-off between precision and recall when adjusting the threshold.
  • The importance of choosing the right metric based on business objectives (e.g., minimizing false negatives vs false positives).
  • Verification that the confusion matrix counts sum to the total number of examples.
  • Potential next steps: plotting precision-recall curve or computing AUC-PR.

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

Q2

Using a cost matrix where a false positive costs 1 and a false negative costs 20, calculate the expected total cost at each threshold and determine which threshold is cheaper.

Technical Trade-offsProduct Analytics & Metrics
Author's notes

At 0.50: cost = 40*1 + 40*20 = 40 + 800 = 840.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the threshold range and the underlying score distributions (or confusion matrices) at each threshold. Then compute expected cost as FP*1 + FN*20 for each threshold, and identify the minimum. If distributions are not given, state assumptions and demonstrate the calculation with a hypothetical example.

Pro tip: Emphasize that the optimal threshold depends on the cost ratio (20:1) and the model's ROC curve; a common mistake is to default to 0.5, but here you should shift the threshold lower to reduce costly false negatives.

1. Clarify inputs and assumptions

Ask for or state the score distributions for positive and negative classes, or the confusion matrix at each threshold. If not provided, assume a simple example (e.g., uniform distributions) to illustrate the method.

2. Define expected cost formula

Expected cost = (Number of false positives) * 1 + (Number of false negatives) * 20. Alternatively, use rates: cost = FP_rate * P(negative) * 1 + FN_rate * P(positive) * 20.

3. Compute cost at each threshold

For each threshold, determine FP and FN counts (or rates) from the distributions, then plug into the formula. Create a table of threshold vs. cost.

4. Identify the minimum cost threshold

Compare the costs across thresholds and select the one with the lowest expected total cost. Explain why it makes sense given the 20:1 cost asymmetry.

5. Validate and discuss trade-offs

Mention that the optimal threshold minimizes expected cost, not accuracy. Discuss how changing the cost ratio would shift the threshold, and note any practical constraints (e.g., business rules).

Key Points to Mention

  • Expected cost formula: FP * cost_FP + FN * cost_FN
  • Cost asymmetry: false negatives are 20x more expensive, so threshold should be lower than 0.5 to catch more positives
  • Use of ROC curve or precision-recall curve to find optimal threshold
  • Importance of base rates (class imbalance) in cost calculation
  • Threshold selection should align with business objective (e.g., minimizing costly misses)
  • Sensitivity analysis: how optimal threshold changes with different cost ratios

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

Q3

Why can ROC-AUC be misleading on a heavily imbalanced dataset, and why is PR-AUC a better choice? Use the numbers from the confusion matrices to build a quick intuition.

Product Analytics & MetricsTechnical Trade-offsA/B Testing & Experimentation
Author's notes

My answer here was decent conceptually but I struggled to make the numeric intuition crisp.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining ROC-AUC and PR-AUC, then explain how class imbalance affects each metric differently. Use a concrete confusion matrix example with numbers to illustrate why ROC-AUC can remain high while PR-AUC drops, showing that PR-AUC better reflects performance on the minority class. Conclude with when to use each metric and the implications for model selection.

Pro tip: Emphasize that in imbalanced settings, the baseline for PR-AUC is the prevalence of the positive class, so a PR-AUC of 0.1 might be meaningful if prevalence is 0.01, whereas ROC-AUC's baseline is always 0.5. This nuance shows deep understanding and avoids misinterpreting PR-AUC values.

1. Define the metrics

Briefly define ROC-AUC as the area under the ROC curve (TPR vs. FPR) and PR-AUC as the area under the precision-recall curve. Mention that ROC-AUC is threshold-independent and measures overall separability, while PR-AUC focuses on the positive class.

2. Explain the impact of imbalance

Explain that with heavy imbalance, the large number of true negatives can inflate the FPR denominator, making ROC-AUC look good even if the model performs poorly on the positive class. PR-AUC, however, ignores true negatives and directly measures precision and recall for the positive class.

3. Illustrate with a confusion matrix example

Use a concrete example: suppose 1000 samples, 990 negatives, 10 positives. A model that predicts all negatives has TPR=0, FPR=0, but ROC-AUC is undefined (or 0.5 if we consider random). Better: a model with 5 TP, 5 FN, 50 FP, 940 TN. Compute TPR=0.5, FPR=0.05, so ROC point is (0.05,0.5). ROC-AUC might be high (e.g., 0.9) if other thresholds perform well, but precision=5/55≈0.09, recall=0.5, so PR-AUC is low. Show that high ROC-AUC doesn't guarantee good precision.

4. Compare PR-AUC and ROC-AUC

Highlight that PR-AUC is more sensitive to improvements in the minority class because it doesn't get 'diluted' by true negatives. ROC-AUC can be overly optimistic when negatives dominate. Also note that PR-AUC's baseline is the positive class prevalence, so it's a more informative baseline.

5. Conclude with practical recommendations

State that for imbalanced datasets, PR-AUC is preferred when the positive class is the focus (e.g., fraud detection, click-through rate prediction). ROC-AUC can still be useful for comparing models if the class distribution is not extreme, but PR-AUC gives a clearer picture of performance on the minority class.

Key Points to Mention

  • ROC-AUC uses True Positive Rate (Recall) and False Positive Rate, which is FP/(FP+TN). With many negatives, FPR remains low even with many false positives.
  • PR-AUC uses Precision (TP/(TP+FP)) and Recall (TP/(TP+FN)), focusing solely on the positive class and ignoring true negatives.
  • In imbalanced data, a high number of true negatives can make ROC-AUC appear high even if precision is low.
  • The baseline for PR-AUC is the prevalence of the positive class (e.g., 0.01), while for ROC-AUC it's 0.5.
  • PR-AUC is more informative when the cost of false positives is high or when the positive class is rare.
  • Use confusion matrix numbers to compute TPR, FPR, precision, and recall to illustrate the discrepancy.

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

Q4

Derive the optimal probability threshold t* for a cost-sensitive decision using a perfectly calibrated model, expressed in terms of the false positive cost, false negative cost, and the class prior.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

This is where I got shaky.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the expected cost as a function of the threshold, using the calibrated probabilities and the class prior. Then minimize this expected cost by taking the derivative and solving for the threshold, which yields a simple ratio of costs. Finally, express the threshold in terms of the given costs and prior, and discuss any assumptions or practical considerations.

Pro tip: Emphasize that the optimal threshold depends only on the cost ratio and the class prior, not on the model's calibration beyond being perfectly calibrated. This shows you understand the decision-theoretic foundation and can separate model quality from decision rules.

1. Define the expected cost

Write the expected cost of predicting positive vs. negative for a given instance, using the calibrated probability p(y=1|x) and the costs C_FP and C_FN. Incorporate the class prior if needed to express the probability in terms of the model output.

2. Set up the threshold condition

The optimal decision is to predict positive if the expected cost of predicting positive is less than or equal to that of predicting negative. This yields an inequality involving the probability and the costs.

3. Solve for the probability threshold

Rearrange the inequality to isolate the probability p(y=1|x). The threshold t* is the value of p at which the two expected costs are equal.

4. Express in terms of costs and prior

If the model outputs are calibrated probabilities, then t* is directly the probability threshold. If the model outputs a score that is a monotonic function of the probability, adjust accordingly. Use the class prior to relate the probability to the likelihood ratio if necessary.

5. State the final formula and discuss implications

Present the final expression: t* = C_FP / (C_FP + C_FN) when the model is perfectly calibrated and the prior is already incorporated in the calibration. If the prior is separate, the threshold on the likelihood ratio or on the calibrated probability may include the prior. Clarify the assumptions.

Key Points to Mention

  • Expected cost minimization framework for decision making
  • The role of calibrated probabilities in threshold selection
  • The formula t* = C_FP / (C_FP + C_FN) for balanced costs or when prior is incorporated
  • How the class prior affects the threshold if the model is calibrated to the true posterior
  • The distinction between probability threshold and score threshold
  • Practical considerations: cost estimation, model calibration, and business impact

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