← Google Interview Insights

Google·Data Scientist·Technical Phone Screen·Senior

SeniorPrefer not to say
Jul 2026Remote

Summary

Tough technical screen for a DS role at Google. Six questions, all ML heavy, and they really wanted you to go deep on the math and tradeoffs rather than just name-drop algorithms. Left feeling like I'd passed maybe four of the six cleanly.

Questions Asked (6)

Q1

Define binary logistic regression from scratch: write out the probability model, derive the log-loss and its gradients with respect to the weights and bias, and explain why the loss function is convex and what that means for optimization.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Felt okay on the model definition and gradient derivation but stumbled a bit explaining convexity in a way that felt satisfying.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the binary logistic regression model: the probability of the positive class as a sigmoid function of the linear combination of weights and bias. Then derive the log-loss (binary cross-entropy) from maximum likelihood estimation, compute its gradients with respect to weights and bias, and prove convexity by showing the Hessian is positive semidefinite. Finally, explain that convexity guarantees a unique global minimum, making optimization via gradient descent reliable and efficient.

Pro tip: Emphasize that the convexity of log-loss ensures no local minima, which is crucial for scalable optimization in large-scale settings like Google's. Also, mention that while logistic regression is convex, regularization (L1/L2) can affect optimization but preserves convexity.

1. Define the probability model

Write the logistic function: P(y=1|x) = σ(w·x + b) = 1/(1+exp(-(w·x+b))). Explain that it models the probability of the positive class.

2. Derive the log-loss

Using maximum likelihood, write the likelihood for N independent samples and take the negative log to get the binary cross-entropy loss: L(w,b) = -Σ [y_i log(σ(z_i)) + (1-y_i) log(1-σ(z_i))], where z_i = w·x_i + b.

3. Compute gradients

Derive gradients: ∂L/∂w = Σ (σ(z_i) - y_i) x_i and ∂L/∂b = Σ (σ(z_i) - y_i). Show that they have a simple, interpretable form.

4. Prove convexity

Show that the Hessian of L with respect to (w,b) is positive semidefinite: H = Σ σ(z_i)(1-σ(z_i)) [x_i;1][x_i;1]^T. Since σ(z)(1-σ(z)) ≥ 0, H is PSD, so L is convex.

5. Explain implications for optimization

Convexity means any local minimum is global, so gradient descent (or variants) converges to the global optimum. This guarantees reliable and efficient training, especially important for large-scale data.

Key Points to Mention

  • Sigmoid function and its properties (output in (0,1), derivative σ'(z)=σ(z)(1-σ(z))).
  • Log-loss derivation from maximum likelihood estimation (MLE).
  • Gradient expressions: ∇_w L = X^T (σ(Xw+b) - y), ∇_b L = sum(σ(z_i) - y_i).
  • Hessian is positive semidefinite because it's a weighted sum of outer products with nonnegative weights.
  • Convexity ensures no local minima, so gradient-based methods find global optimum.
  • Practical implications: scalability, convergence guarantees, and the effect of regularization (still convex).

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

Q2

Compare L1 and L2 regularization in logistic regression across sparsity, multicollinearity, decision boundary geometry, and probability calibration. When does elastic net make more sense than using either one alone?

Technical Trade-offsData Modeling
Author's notes

The sparsity and multicollinearity parts were fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer by comparing L1 and L2 across the four dimensions, then explain when elastic net combines their strengths. Use concrete examples and connect to practical implications like feature selection, model stability, and calibration.

Pro tip: Emphasize that regularization choice should be driven by the problem's goals—sparsity for interpretability, L2 for stability with correlated features, and elastic net for high-dimensional data with grouped features. Mention that probability calibration can be affected by regularization strength and should be validated separately.

1. Define L1 and L2 regularization

Briefly explain that L1 adds a penalty proportional to the absolute value of coefficients, while L2 adds a penalty proportional to the square of coefficients.

2. Compare sparsity and multicollinearity

Discuss how L1 induces sparsity by driving some coefficients to zero, while L2 shrinks coefficients but keeps them non-zero, which helps with multicollinearity by distributing weights among correlated features.

3. Analyze decision boundary and calibration

Explain that L1 can lead to axis-aligned boundaries due to sparsity, while L2 produces smoother boundaries; both can affect probability calibration, with stronger regularization often leading to under-confident predictions.

4. Introduce elastic net and its use cases

Describe elastic net as a combination of L1 and L2 penalties, and explain that it is beneficial when there are multiple correlated features or when you want both sparsity and stability.

5. Summarize trade-offs and recommendations

Conclude with practical guidance: use L1 for feature selection, L2 for multicollinearity, and elastic net when both are needed, especially in high-dimensional settings.

Key Points to Mention

  • L1 regularization (Lasso) performs feature selection by producing sparse solutions.
  • L2 regularization (Ridge) handles multicollinearity by shrinking coefficients and reducing variance.
  • Decision boundaries: L1 tends to produce piecewise linear boundaries aligned with axes, while L2 yields smoother boundaries.
  • Probability calibration: Regularization can bias predicted probabilities; L1 may lead to more extreme probabilities due to sparsity, while L2 tends to shrink towards the mean.
  • Elastic net combines L1 and L2 penalties, useful when features are correlated or when the number of features exceeds the number of samples.
  • Elastic net often outperforms Lasso when there are grouped features, as it can select entire groups.

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

Q3

Under what conditions does logistic regression tend to outperform a random forest? Think about decision boundary linearity, high-dimensional sparse features, small sample sizes with many features, and situations where calibrated probabilities matter.

Technical Trade-offsData Modeling
Author's notes

This one I actually liked.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer by contrasting logistic regression and random forest across the four dimensions mentioned: linearity of decision boundaries, high-dimensional sparsity, small sample sizes, and probability calibration. For each dimension, explain why logistic regression has an advantage, and acknowledge when random forest might still be preferable. Conclude with a practical recommendation based on the problem context.

Pro tip: Emphasize that logistic regression is not just a model but a statistical framework that provides interpretable coefficients and well-calibrated probabilities by default, which is crucial in regulated industries or when decisions require risk scores. Mention that random forest's probability estimates are often biased and require calibration techniques like Platt scaling or isotonic regression.

1. Linear Decision Boundaries

Explain that logistic regression assumes a linear relationship between features and log-odds, making it ideal when the true decision boundary is approximately linear. Random forest, being a non-parametric ensemble, may overfit or require more data to approximate linear boundaries, leading to worse performance in such cases.

2. High-Dimensional Sparse Features

Discuss that logistic regression, especially with L1 or L2 regularization, handles high-dimensional sparse data (e.g., text) effectively by learning a weight per feature. Random forest, which splits on feature thresholds, struggles with sparse features because many splits yield little information gain and the model may not capture linear combinations.

3. Small Sample Sizes with Many Features

Highlight that logistic regression with regularization can perform well in small-sample, high-dimensional settings by shrinking coefficients and avoiding overfitting. Random forest, with its many trees and deep splits, is prone to overfitting when data is limited, though it can be tuned.

4. Calibrated Probabilities

Point out that logistic regression naturally outputs well-calibrated probabilities (assuming the model is correctly specified), which is critical for decision-making under uncertainty. Random forest probabilities are often miscalibrated, especially with imbalanced data, and require post-hoc calibration.

5. Practical Considerations and Trade-offs

Summarize that logistic regression is preferred when interpretability, linearity, sparsity, small samples, and calibrated probabilities are important. However, random forest may outperform when interactions and non-linearities dominate, and sufficient data is available. Always validate with cross-validation.

Key Points to Mention

  • Logistic regression assumes linearity in log-odds, which is advantageous when the true relationship is linear.
  • Regularization (L1/L2) in logistic regression helps with high-dimensional sparse data and small sample sizes.
  • Random forest can capture non-linearities and interactions but may overfit with small data and struggle with sparse features.
  • Logistic regression provides inherently calibrated probabilities, while random forest often requires calibration.
  • Interpretability: logistic regression coefficients are directly interpretable, which is valuable in many business contexts.
  • Empirical validation: always compare models using proper cross-validation and metrics like AUC, log-loss, and calibration plots.

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

Q4

Your model is overfitting. Walk through concrete remedies specific to logistic regression, random forests, and gradient boosting separately. Also describe how you'd detect overfitting beyond just looking at accuracy.

Technical Trade-offsRoot Cause Analysis
Author's notes

The detection part is what separates people here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining overfitting and emphasizing that remedies are model-specific. Then, for each model type, outline concrete techniques: for logistic regression, focus on regularization and feature selection; for random forests, discuss hyperparameter tuning and pruning; for gradient boosting, cover learning rate, early stopping, and tree constraints. Finally, explain detection methods beyond accuracy, such as learning curves, cross-validation, and appropriate metrics.

Pro tip: Demonstrate maturity by acknowledging that overfitting is a trade-off and that the goal is to generalize well, not just to reduce training error. Mention that you would use a validation set and monitor both training and validation performance to guide adjustments.

1. Define overfitting and its causes

Briefly explain what overfitting is and why it occurs, setting the stage for model-specific remedies.

2. Remedies for logistic regression

Discuss regularization (L1/L2), feature selection, and simplifying the model to reduce variance.

3. Remedies for random forests

Cover hyperparameter tuning (e.g., max_depth, min_samples_leaf, max_features), increasing the number of trees, and pruning.

4. Remedies for gradient boosting

Explain learning rate reduction, early stopping, tree constraints (max_depth, min_child_weight), and subsampling.

5. Detection beyond accuracy

Describe methods like learning curves, cross-validation, and metrics such as precision, recall, F1, AUC, and calibration.

Key Points to Mention

  • Regularization techniques (L1/L2) for logistic regression
  • Hyperparameter tuning for random forests (max_depth, min_samples_leaf, max_features)
  • Early stopping and learning rate for gradient boosting
  • Learning curves to visualize training vs validation performance
  • Cross-validation to assess generalization
  • Metrics beyond accuracy: precision, recall, F1, AUC, and calibration

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

Q5

Contrast random forests and gradient boosting across bias-variance tradeoffs, sensitivity to noisy features, hyperparameter sensitivity, handling of missing values natively, and training versus inference cost. Give a real-world scenario where each clearly beats the other.

Technical Trade-offsSystem Design
Author's notes

Pretty standard comparison question but the 'missing values natively' angle caught me slightly off guard since I associate that more with XGBoost specifically.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer by first contrasting random forests and gradient boosting on each dimension (bias-variance, noise sensitivity, hyperparameter sensitivity, missing values, cost), then provide a concrete real-world scenario where each excels. Emphasize the fundamental difference: random forests build independent trees to reduce variance, while gradient boosting builds sequential trees to reduce bias.

Pro tip: Mention that random forests are more robust out-of-the-box and require less tuning, making them ideal for quick baselines, while gradient boosting often wins competitions but demands careful hyperparameter tuning and can overfit noisy data. Also, note that XGBoost and LightGBM handle missing values natively, but scikit-learn's implementations do not.

1. Bias-Variance Tradeoff

Explain that random forests average many deep, independent trees to reduce variance (low bias, higher variance than boosting but still low), while gradient boosting sequentially corrects errors of weak learners (shallow trees) to reduce bias (low bias, but can have higher variance if not regularized).

2. Noise Sensitivity and Hyperparameter Sensitivity

Discuss that random forests are less sensitive to noisy features and hyperparameters due to bagging and feature subsampling, whereas gradient boosting can overfit noise and is highly sensitive to learning rate, number of trees, and tree depth.

3. Missing Values and Cost

Highlight that random forests (e.g., scikit-learn) do not natively handle missing values, while gradient boosting implementations like XGBoost and LightGBM do. For cost, random forests are parallelizable and fast to train but can be memory-heavy at inference; gradient boosting trains sequentially (slower) but often has faster inference with fewer trees.

4. Real-World Scenarios

Provide one scenario where random forests clearly win (e.g., a quick baseline on a noisy dataset with many irrelevant features, like customer churn prediction with messy data) and one where gradient boosting wins (e.g., a Kaggle competition or a high-stakes prediction task like click-through rate prediction where every bit of accuracy matters and data is clean).

Key Points to Mention

  • Random forests reduce variance by averaging independent trees; gradient boosting reduces bias by sequentially fitting residuals.
  • Random forests are robust to noisy features and hyperparameters; gradient boosting is sensitive and requires careful tuning (learning rate, n_estimators, max_depth).
  • Native missing value handling: XGBoost/LightGBM handle missing values; random forests in scikit-learn do not (require imputation).
  • Training cost: random forests parallelizable (fast training); gradient boosting sequential (slower training). Inference cost: random forests may be slower due to many deep trees; gradient boosting often faster with fewer trees.
  • Real-world scenario for random forests: quick baseline on noisy, high-dimensional data with missing values (e.g., fraud detection with limited tuning).
  • Real-world scenario for gradient boosting: structured data competitions or production systems where accuracy is critical and data is clean (e.g., ranking, CTR prediction).

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

Q6

Case study: you have 50k rows, 10k sparse binary features, 1% positive class rate, and significant temporal drift in the data. Design an end-to-end pipeline for both a logistic regression with elastic net and a tree-based model. Cover feature processing, regularization choices, time-based cross-validation, threshold selection, probability calibration, and how you'd fairly compare the two approaches. Call out the specific pitfalls you'd avoid.

Data ModelingTechnical Trade-offsSystem Design
Author's notes

This was the hardest one and honestly where I felt most exposed.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer around a unified pipeline that handles sparsity, class imbalance, and temporal drift, then branch into model-specific choices for regularization and calibration. Emphasize time-based validation and fair comparison via identical splits and metrics suited to imbalanced data.

Pro tip: Always use time-based splits and calibrate probabilities before thresholding; this avoids leakage and ensures your threshold is meaningful for the business metric.

1. Data splitting and temporal validation

Split data chronologically into train, validation, and test sets to mimic real-world deployment. Use expanding-window or sliding-window cross-validation on the training set to respect temporal order and detect drift.

2. Feature processing for sparsity and drift

For logistic regression, use sparse representations and scale numerical features if any; for trees, no scaling needed. Consider feature hashing for high dimensionality and monitor feature distributions over time to detect drift.

3. Model training with regularization

For logistic regression, use elastic net with L1 ratio tuned via time-based CV to handle sparsity and correlated features. For tree-based models, use depth constraints, min samples per leaf, and regularization (e.g., lambda) to prevent overfitting on sparse data.

4. Probability calibration and threshold selection

Calibrate probabilities using Platt scaling or isotonic regression on a temporally held-out set. Select the threshold that optimizes the business metric (e.g., F1, precision@k) on validation data, not test data.

5. Fair comparison and drift monitoring

Compare models on the same temporal test set using metrics robust to imbalance (e.g., PR-AUC, recall at fixed precision). Evaluate calibration quality (e.g., Brier score) and monitor performance over time to assess drift resilience.

Key Points to Mention

  • Use time-based splits and cross-validation to avoid data leakage and account for temporal drift.
  • For logistic regression, elastic net combines L1 (sparsity) and L2 (correlated features) regularization; tune the l1_ratio.
  • For tree-based models, control complexity via max_depth, min_samples_leaf, and regularization to avoid overfitting on sparse data.
  • Calibrate probabilities (Platt scaling/isotonic) before thresholding, especially for imbalanced data.
  • Select threshold based on validation performance and business metric, not default 0.5.
  • Compare models using PR-AUC, recall at fixed precision, and calibration metrics; avoid accuracy due to class imbalance.

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