← Google Interview Insights

Google·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Google data scientist interview that went deep on model selection for a binary classification problem with limited data. The whole conversation revolved around logistic regression vs. tree-based ensembles, regularization, and overfitting. More theoretical than I expected for a DS role.

Questions Asked (5)

Q1

What is logistic regression and what loss function does it use?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Covered log loss and the sigmoid output, felt okay about it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start with a clear, concise definition of logistic regression as a linear model for binary classification that outputs probabilities via the sigmoid function. Then explain that it is trained by minimizing the negative log-likelihood (log loss), and briefly connect this to cross-entropy and maximum likelihood estimation. Finally, mention why this loss is appropriate and how it relates to the sigmoid output.

Pro tip: Emphasize that logistic regression is a probabilistic model, not just a classifier, and that the log loss is derived from maximum likelihood estimation under a Bernoulli assumption. This shows depth and connects to broader ML principles.

1. Define logistic regression

State that logistic regression is a linear model for binary classification that models the probability of the positive class using the sigmoid function applied to a linear combination of inputs.

2. Explain the sigmoid function

Describe how the sigmoid function maps any real-valued linear score to a probability between 0 and 1, enabling probabilistic interpretation.

3. Introduce the loss function

State that the loss function is the negative log-likelihood (log loss or binary cross-entropy), which penalizes incorrect predictions based on the predicted probability.

4. Connect to maximum likelihood

Explain that minimizing log loss is equivalent to maximizing the likelihood of the observed data under a Bernoulli distribution, which is the statistical foundation.

5. Discuss properties and alternatives

Mention that log loss is convex, ensuring a unique global minimum, and contrast with squared error which is non-convex for logistic regression.

Key Points to Mention

  • Logistic regression models the log-odds of the positive class as a linear function of inputs.
  • The sigmoid function outputs probabilities between 0 and 1.
  • The loss function is negative log-likelihood (log loss or binary cross-entropy).
  • Log loss is derived from maximum likelihood estimation under a Bernoulli distribution.
  • Log loss is convex, which guarantees convergence to the global minimum with gradient-based optimization.
  • Squared error is not suitable because it leads to a non-convex optimization problem for logistic regression.

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

Q2

Under what conditions might logistic regression outperform a random forest?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

This is where things got interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by acknowledging that both models have strengths and weaknesses, then focus on scenarios where logistic regression's assumptions and simplicity give it an edge. Structure your answer around data characteristics, interpretability, and computational constraints, and mention that the choice depends on the specific problem and data.

Pro tip: Emphasize that logistic regression is often preferred when the relationship between features and log-odds is approximately linear and the dataset is small or sparse, but always validate with cross-validation since random forest can capture complex interactions that logistic regression misses.

1. Data Size and Dimensionality

Discuss how logistic regression can outperform random forest when the dataset is small (fewer samples) or has high dimensionality (many features), as random forest may overfit or require more data to generalize well.

2. Linear Decision Boundary

Explain that if the true decision boundary is linear in the feature space (or in log-odds), logistic regression will be more accurate and efficient, while random forest may struggle to extrapolate or model linear relationships smoothly.

3. Interpretability and Inference

Highlight that logistic regression provides interpretable coefficients and p-values, which are crucial in regulated industries or when understanding feature importance is key; random forest is more of a black box.

4. Computational Efficiency and Scalability

Mention that logistic regression is faster to train and predict, especially on large-scale sparse data (e.g., text classification), and requires less memory, making it preferable in real-time or resource-constrained environments.

5. Regularization and Overfitting

Point out that with proper regularization (L1/L2), logistic regression can handle overfitting well in high-dimensional settings, whereas random forest may need careful tuning of hyperparameters to avoid overfitting.

Key Points to Mention

  • Small sample size or high-dimensional sparse data (e.g., text with bag-of-words)
  • Linear relationship between features and log-odds of the outcome
  • Need for interpretability and statistical inference (coefficients, odds ratios)
  • Computational efficiency: faster training and prediction, lower memory footprint
  • Regularization techniques (L1/L2) to prevent overfitting in logistic regression
  • Random forest's strength in capturing non-linear interactions and handling mixed data types

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

Q3

Explain L1 and L2 regularization and what each one does to the model.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

L1 drives coefficients to exactly zero, L2 shrinks them but keeps them around.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining regularization as a technique to prevent overfitting by adding a penalty to the loss function. Then explain L1 (Lasso) and L2 (Ridge) penalties, their mathematical forms, and their effects on model coefficients. Finally, discuss practical implications and when to use each.

Pro tip: Mention that L1 can be used for feature selection due to sparsity, while L2 is better for handling multicollinearity and improving generalization. Also, note that Elastic Net combines both.

1. Define Regularization

Explain that regularization adds a penalty term to the loss function to discourage complex models and reduce overfitting.

2. Explain L1 Regularization

Describe L1 as adding the sum of absolute weights to the loss. It leads to sparse solutions, effectively performing feature selection.

3. Explain L2 Regularization

Describe L2 as adding the sum of squared weights to the loss. It shrinks coefficients towards zero but doesn't eliminate them, helping with multicollinearity.

4. Compare Effects on Model

Contrast the effects: L1 yields sparse models and can zero out irrelevant features; L2 yields smoother models and distributes weight among correlated features.

5. Discuss Practical Considerations

Mention when to use each: L1 for feature selection, L2 for generalization, and Elastic Net for combining benefits. Also note hyperparameter tuning (lambda).

Key Points to Mention

  • Regularization prevents overfitting by penalizing large coefficients.
  • L1 (Lasso) adds absolute value penalty; promotes sparsity and feature selection.
  • L2 (Ridge) adds squared penalty; shrinks coefficients and handles multicollinearity.
  • Geometric interpretation: L1 diamond vs L2 circle, leading to different solutions.
  • Elastic Net combines L1 and L2 penalties.
  • Hyperparameter lambda controls regularization strength; needs tuning via cross-validation.

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

Q4

How would you detect overfitting in logistic regression and what would you do about it?

Technical Trade-offsRoot Cause Analysis
Author's notes

Went with train vs.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining overfitting in the context of logistic regression, then explain how to detect it using validation curves, learning curves, and performance metrics. Finally, discuss remedies such as regularization, feature selection, and cross-validation, emphasizing the trade-offs involved.

Pro tip: Mention that logistic regression can overfit even with few features if the data is separable, and that regularization strength should be tuned via cross-validation rather than set arbitrarily.

1. Define overfitting in logistic regression

Explain that overfitting occurs when the model captures noise in the training data, leading to high variance and poor generalization to unseen data.

2. Detect overfitting

Use techniques like comparing training and validation performance (e.g., accuracy, log-loss, AUC), plotting learning curves, and checking for perfect separation or extremely large coefficients.

3. Diagnose causes

Identify potential causes such as too many features relative to samples, multicollinearity, or separable data that leads to infinite coefficients.

4. Apply remedies

Implement regularization (L1/L2), reduce feature dimensionality via feature selection or PCA, collect more data, or use cross-validation to tune hyperparameters.

5. Validate and monitor

After applying fixes, re-evaluate using cross-validation and monitor performance on a holdout set to ensure overfitting is mitigated without underfitting.

Key Points to Mention

  • Regularization techniques (L1 Lasso, L2 Ridge) and their role in penalizing large coefficients
  • Cross-validation for reliable performance estimation and hyperparameter tuning
  • Learning curves to visualize bias-variance trade-off
  • Feature selection methods to reduce model complexity
  • The issue of perfect separation in logistic regression and its effect on coefficient estimates
  • Metrics like AUC-ROC, precision-recall, and log-loss for imbalanced data

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

Q5

Compare random forests and gradient boosting across bias, variance, interpretability, and when you'd pick one over the other.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Random forests reduce variance through bagging and averaging, boosting reduces bias by sequentially correcting errors, which means it can overfit more if you're not careful with learning rate and tree depth.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer by first defining both algorithms and their core differences, then systematically compare them across the four dimensions: bias, variance, interpretability, and practical use cases. Conclude with a decision framework for when to choose each, emphasizing that the choice depends on data characteristics, computational resources, and business needs.

Pro tip: Mention that gradient boosting often wins competitions but random forests are more robust to hyperparameter choices and noisy data—showing you understand the practical trade-offs beyond just theory. Also, note that interpretability can be enhanced with SHAP values for both, but random forests are inherently simpler to explain.

1. Define and Contrast Core Mechanisms

Briefly explain that random forests build independent trees on bootstrapped samples and average them (bagging), while gradient boosting builds trees sequentially to correct previous errors (boosting). This sets the foundation for the comparison.

2. Compare Bias and Variance

Discuss how random forests primarily reduce variance by averaging many decorrelated trees, while gradient boosting reduces bias by sequentially fitting residuals, though it can overfit if not tuned. Mention that both can achieve low bias with enough trees, but boosting often has lower bias.

3. Evaluate Interpretability

Explain that random forests are generally more interpretable due to feature importance and simpler structure, while gradient boosting models are more complex and require techniques like SHAP for interpretation. Note that both are less interpretable than single decision trees.

4. Discuss Practical Selection Criteria

Outline when to pick each: random forests for noisy data, quick baselines, or when interpretability is key; gradient boosting for maximum predictive performance, structured/tabular data, and when you can invest in tuning. Mention XGBoost/LightGBM as popular implementations.

5. Summarize with a Decision Framework

Conclude with a concise rule of thumb: start with random forest for robustness and speed, then try gradient boosting if you need higher accuracy and can tune. Emphasize that the choice depends on the specific problem and constraints.

Key Points to Mention

  • Random forests use bagging (parallel trees) and reduce variance; gradient boosting uses boosting (sequential trees) and reduces bias.
  • Gradient boosting often achieves higher accuracy but is more prone to overfitting and requires careful hyperparameter tuning (learning rate, tree depth, etc.).
  • Random forests are more robust to hyperparameters and noisy data, making them a good baseline.
  • Interpretability: random forests offer feature importance and are easier to explain; gradient boosting requires post-hoc methods like SHAP.
  • Computational considerations: random forests can be parallelized easily; gradient boosting is sequential and may be slower to train.
  • Practical implementations: scikit-learn for both, but XGBoost/LightGBM/CatBoost are preferred for gradient boosting due to speed and performance.

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