← Nextdoor Interview Insights

Nextdoor·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Nextdoor ML Engineer interview that was essentially a full coding exercise: given a raw DataFrame, implement data prep, train a model from scratch with numpy, evaluate it, and then field a bunch of concept questions. No sklearn allowed, which is where things got real.

Questions Asked (8)

Q1

Given a pandas DataFrame with numeric and categorical features and a target column, how would you handle missing values, encode categoricals, split the data, and standardize features without using any ML libraries?

Technical Trade-offsData ModelingAlgorithms & Data Structures
Author's notes

The no-sklearn constraint hit harder than expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Walk through a clean, reproducible pipeline: first inspect and handle missing values with simple imputation (mean/median for numeric, mode or constant for categorical), then encode categoricals (one-hot for low cardinality, ordinal for ordered), split the data before fitting any transformations to avoid leakage, and finally standardize numeric features using training-set statistics. Emphasize that all steps are implemented with pure pandas/numpy and that the same statistics are applied to validation/test sets.

Pro tip: Always split the data before computing imputation or standardization statistics, and store those statistics (e.g., means, medians, categories) so you can apply the exact same transformations to new data at inference time. This shows you understand data leakage and production readiness.

1. Inspect and handle missing values

Identify missing values per column, then impute numeric columns with mean/median and categorical columns with mode or a constant like 'Missing'. Do this after splitting to avoid leakage.

2. Encode categorical features

Use one-hot encoding for low-cardinality nominal features and ordinal encoding for ordered categories. Handle unseen categories in test data by mapping them to a default or ignoring them.

3. Split the data

Split into train/validation/test sets (e.g., 60/20/20) using a random shuffle with a fixed seed. Ensure the split is stratified if the target is imbalanced.

4. Standardize numeric features

Compute mean and standard deviation on the training set only, then apply (x - mean) / std to train, validation, and test sets. Store these statistics for later use.

5. Assemble the final feature matrix

Concatenate the standardized numeric features and encoded categorical features into a single array or DataFrame, ensuring consistent column order across all splits.

Key Points to Mention

  • Data leakage: fit imputation and standardization only on training data
  • Handling unseen categories in test data (e.g., using a default category or ignoring)
  • Choice of imputation strategy (mean vs median vs mode) and its impact on distributions
  • One-hot encoding vs ordinal encoding and when to use each
  • Stratified splitting for imbalanced target variables
  • Storing transformation statistics for production inference

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

Q2

Implement logistic regression or linear regression from scratch using numpy, including gradient descent training and a prediction function.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is the kind of thing you think you remember until you're staring at a blank cell.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem setup and assumptions, then outline the mathematical formulation and implementation plan. Write clean, vectorized NumPy code with gradient descent, and explain how you would validate and optimize the model.

Pro tip: Mention that you would add L2 regularization and use vectorized operations for efficiency, and discuss how to handle numerical stability (e.g., log-sum-exp trick for logistic regression).

1. Clarify requirements and assumptions

Ask whether to implement linear or logistic regression, and confirm the input format, loss function, and optimization method. State assumptions about data (e.g., no missing values, features scaled).

2. Derive the math and define the model

Write down the hypothesis function (linear: Xw + b; logistic: sigmoid(Xw + b)) and the loss function (MSE for linear, cross-entropy for logistic). Derive the gradients with respect to weights and bias.

3. Implement training with gradient descent

Initialize weights (e.g., zeros or small random), then iteratively update weights using the gradients and a learning rate. Use vectorized NumPy operations for efficiency and include a convergence check (e.g., loss change threshold).

4. Implement prediction function

For linear regression, return Xw + b; for logistic regression, return the sigmoid output and optionally threshold at 0.5 for class labels. Ensure the function works for both single samples and batches.

5. Validate and discuss trade-offs

Test on a small synthetic dataset, compare with scikit-learn, and discuss trade-offs: batch vs stochastic gradient descent, regularization, feature scaling, and convergence speed.

Key Points to Mention

  • Vectorization: use NumPy matrix operations to avoid loops and speed up computation.
  • Gradient descent variants: batch, stochastic, and mini-batch, and their impact on convergence and scalability.
  • Regularization: L1/L2 to prevent overfitting, and how to incorporate it into the gradient.
  • Numerical stability: for logistic regression, use the log-sum-exp trick to avoid overflow in the loss.
  • Evaluation metrics: for linear regression (MSE, R²), for logistic regression (accuracy, precision/recall, AUC-ROC).
  • Feature engineering: importance of scaling and handling categorical variables.

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

Q3

What evaluation metrics would you choose for a regression task versus a binary classification task, and how would you detect and address overfitting?

Product Analytics & MetricsTechnical Trade-offs
Author's notes

Straightforward to talk through.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by contrasting the evaluation metrics for regression and binary classification, emphasizing how the choice depends on the business objective and data characteristics. Then, discuss overfitting detection through learning curves and validation techniques, and address mitigation strategies like regularization and early stopping. Tie your answer to real-world examples, ideally from Nextdoor's domain, to show practical insight.

Pro tip: Mention that for Nextdoor, where local relevance and user engagement are key, metrics like MAE for regression (e.g., predicting neighbor interactions) and PR-AUC for classification (e.g., spam detection) are often more informative than generic ones. Also, highlight that overfitting detection should be continuous, not just a one-time check.

1. Clarify the task and business context

Briefly explain that metric selection depends on the problem's goal, data distribution, and business impact. For Nextdoor, consider metrics that reflect user value, such as engagement or trust.

2. Choose regression metrics

Discuss common regression metrics like MSE, RMSE, MAE, and R-squared, and when to use each. For example, MAE is robust to outliers, while RMSE penalizes large errors more.

3. Choose binary classification metrics

Cover metrics like accuracy, precision, recall, F1, ROC-AUC, and PR-AUC, explaining their trade-offs. Emphasize that for imbalanced data, PR-AUC and F1 are often preferred over accuracy.

4. Detect overfitting

Describe techniques like monitoring training vs. validation loss, using learning curves, and employing cross-validation. Mention that a large gap between training and validation performance indicates overfitting.

5. Address overfitting

List strategies such as regularization (L1/L2), dropout, early stopping, data augmentation, and simplifying the model. Also, consider increasing training data or using ensemble methods.

Key Points to Mention

  • Regression metrics: MSE, RMSE, MAE, R-squared, and their sensitivity to outliers.
  • Classification metrics: accuracy, precision, recall, F1, ROC-AUC, PR-AUC, and their suitability for imbalanced data.
  • Overfitting detection: learning curves, validation curves, and cross-validation techniques.
  • Overfitting mitigation: regularization, early stopping, dropout, data augmentation, and model simplification.
  • Business context: aligning metrics with Nextdoor's goals, such as local relevance and user engagement.
  • Practical trade-offs: e.g., precision vs. recall in fraud detection, or MAE vs. RMSE in predicting user activity.

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

Q4

Explain the bias-variance tradeoff and how it relates to model complexity.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Classic.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining bias and variance clearly, then explain how they trade off as model complexity changes. Use a concrete example like polynomial regression to illustrate the U-shaped test error curve, and connect it to practical model selection strategies.

Pro tip: Mention that the tradeoff is not just theoretical—it directly informs decisions like regularization strength, early stopping, and ensemble methods, which are critical in production ML systems at scale.

1. Define bias and variance

Bias is error from overly simplistic assumptions (underfitting); variance is error from sensitivity to training data fluctuations (overfitting).

2. Explain the tradeoff with model complexity

As model complexity increases, bias decreases but variance increases, and vice versa. The goal is to find the sweet spot that minimizes total error.

3. Illustrate with a concrete example

Use polynomial regression: low-degree underfits (high bias), high-degree overfits (high variance), and the validation error forms a U-shape.

4. Connect to practical techniques

Discuss how regularization, cross-validation, and ensembling (e.g., bagging reduces variance, boosting reduces bias) help manage the tradeoff.

5. Relate to real-world impact

Emphasize that understanding this tradeoff guides model selection, hyperparameter tuning, and deployment decisions to balance accuracy and robustness.

Key Points to Mention

  • Bias-variance decomposition of expected test error
  • Underfitting vs. overfitting and their symptoms
  • U-shaped validation/test error curve as complexity increases
  • Regularization (L1/L2) as a bias-variance control mechanism
  • Ensemble methods: bagging reduces variance, boosting reduces bias
  • Cross-validation for estimating generalization error

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

Q5

How does L1 regularization differ from L2, and what does each one do to the loss objective?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

L1 adds absolute value of weights, L2 adds squared weights.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining L1 and L2 regularization as penalty terms added to the loss function, then contrast their mathematical forms and resulting effects on model weights. Explain how L1 promotes sparsity while L2 promotes small, distributed weights, and tie this to practical implications like feature selection and overfitting prevention.

Pro tip: Mention that L1 regularization is equivalent to a Laplace prior and L2 to a Gaussian prior on the weights, showing deeper Bayesian understanding. Also, note that L1 can be solved via proximal gradient methods, while L2 has a closed-form solution in linear regression (ridge).

1. Define regularization and its purpose

Briefly explain that regularization adds a penalty to the loss to prevent overfitting by constraining model complexity.

2. State the mathematical forms

Write the loss objective with L1 (λ∑|w_i|) and L2 (λ∑w_i^2) penalties, highlighting the difference in norms.

3. Explain the effect on weights

Describe how L1 drives some weights exactly to zero (sparsity) while L2 shrinks weights smoothly toward zero but rarely to exactly zero.

4. Connect to optimization and geometry

Mention that L1 corresponds to a diamond-shaped constraint region leading to sparse solutions at vertices, while L2 corresponds to a circular region leading to small but non-zero weights.

5. Discuss practical implications

Highlight use cases: L1 for feature selection and interpretability, L2 for handling correlated features and improving generalization; mention elastic net as a combination.

Key Points to Mention

  • L1 adds absolute value penalty; L2 adds squared penalty.
  • L1 induces sparsity (feature selection), L2 induces weight decay.
  • Geometric interpretation: L1 constraint region is a diamond, L2 is a circle.
  • Bayesian interpretation: L1 ~ Laplace prior, L2 ~ Gaussian prior.
  • Optimization: L1 is non-differentiable at zero, requiring subgradient or proximal methods; L2 is differentiable.
  • Elastic net combines both penalties for correlated features.

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

Q6

How would you handle class imbalance in a binary classification problem?

Technical Trade-offsData Modeling
Author's notes

Talked about resampling, class weights, and changing the decision threshold.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem context and the evaluation metric, since the right technique depends on whether you care about ranking, calibrated probabilities, or hard labels. Then walk through a structured set of options—data-level, algorithm-level, and evaluation-level—and explain how you'd validate the choice with a proper baseline and cross-validation.

Pro tip: Don't jump straight to SMOTE; first ask whether the imbalance reflects the true deployment distribution. If it does, resampling can distort calibrated probabilities, so it's often better to keep the distribution and tune the decision threshold or use class weights.

1. Clarify the problem and metric

Ask about the class ratio, the business cost of false positives vs. false negatives, and whether the model needs calibrated probabilities or just rankings. This determines whether you optimize for AUC, PR-AUC, F1, or a cost-sensitive metric.

2. Establish a baseline

Train a simple model with no imbalance handling and evaluate with the chosen metric to quantify the problem. This prevents over-engineering and gives a reference point for measuring improvement.

3. Choose a strategy

Consider data-level methods (oversampling, undersampling, SMOTE variants), algorithm-level methods (class weights, focal loss, cost-sensitive learning), and threshold tuning. Select based on data size, noise, and whether probability calibration matters.

4. Validate rigorously

Use stratified cross-validation and apply any resampling only within training folds to avoid leakage. Compare models on a held-out set using the agreed metric and check for overfitting to the minority class.

5. Monitor and iterate

After deployment, monitor performance across segments and over time, since class balance can drift. Be ready to retune the threshold or resampling strategy as the data distribution changes.

Key Points to Mention

  • Evaluation metrics: PR-AUC, F1, recall at fixed precision, and why accuracy is misleading
  • Data-level techniques: random oversampling, undersampling, SMOTE and its variants (Borderline-SMOTE, ADASYN)
  • Algorithm-level techniques: class weights, cost-sensitive learning, focal loss
  • Threshold tuning and probability calibration (Platt scaling, isotonic regression)
  • Stratified cross-validation and avoiding data leakage when resampling
  • Trade-offs: resampling can cause overfitting or information loss; class weights preserve the original distribution

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

Q7

When does feature scaling matter and why? What happens if you skip it?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Gradient descent converges poorly when features are on different scales, and distance-based models get dominated by high-magnitude features.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining feature scaling and its purpose, then explain when it matters (e.g., distance-based and gradient-based algorithms) and when it doesn't (e.g., tree-based models). Finally, discuss the consequences of skipping it, such as slow convergence, poor performance, and numerical instability.

Pro tip: Mention that scaling should be fit on training data only and applied to validation/test data to avoid data leakage, and note that some algorithms like tree-based models are invariant to monotonic transformations, so scaling is unnecessary.

1. Define feature scaling

Explain what feature scaling is (e.g., normalization, standardization) and why it's used to bring features to a similar scale.

2. Identify when it matters

Discuss algorithms sensitive to scale: distance-based (KNN, SVM, K-means), gradient-based (linear regression, neural networks), and regularization (Lasso, Ridge).

3. Identify when it doesn't matter

Mention algorithms invariant to scale: tree-based models (decision trees, random forests, gradient boosting).

4. Explain consequences of skipping

Describe issues like slow convergence, features with larger scales dominating distance calculations, poor model performance, and numerical instability.

5. Provide practical recommendations

Suggest best practices: use StandardScaler or MinMaxScaler, fit on training data only, and consider the algorithm's requirements.

Key Points to Mention

  • Distance-based algorithms (e.g., KNN, SVM, K-means) are highly sensitive to feature scales because they rely on Euclidean distance.
  • Gradient descent-based algorithms (e.g., linear regression, neural networks) converge faster with scaled features.
  • Tree-based models (e.g., decision trees, random forests) are invariant to feature scaling because they split on individual features.
  • Skipping scaling can lead to features with larger ranges dominating the learning process, resulting in suboptimal models.
  • Regularization methods (Lasso, Ridge) penalize coefficients, so scaling ensures fair penalization.
  • Always fit scalers on training data only and apply to validation/test data to prevent data leakage.

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

Q8

What is train/validation/test leakage and how do you prevent it during data preparation?

Technical Trade-offsData Modeling
Author's notes

This one tied back to the earlier coding question and I think they were checking if I'd connected the dots.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Define leakage as any information from outside the training set that improperly influences model training, then distinguish between train/validation/test leakage and target leakage. Explain prevention strategies across the data preparation pipeline, emphasizing temporal ordering, proper cross-validation, and pipeline encapsulation.

Pro tip: Mention that leakage often occurs silently and can be diagnosed by comparing model performance on a holdout set versus a truly unseen dataset—if performance drops drastically, leakage is likely. Also, use scikit-learn pipelines to enforce that preprocessing is fit only on training data.

1. Define leakage and its types

Clearly explain what data leakage is and distinguish between train/validation/test leakage (e.g., preprocessing on full data) and target leakage (using future or target-derived features).

2. Identify common sources

List typical sources such as scaling before splitting, imputation using global statistics, feature selection on full data, and temporal leakage in time-series.

3. Prevention during data splitting

Describe proper splitting techniques: hold-out test set at the very beginning, stratified splitting for imbalanced data, and group splitting to avoid subject overlap.

4. Prevention during preprocessing

Explain that all preprocessing (scaling, encoding, imputation) must be fit only on training data and applied to validation/test. Use pipelines to automate this.

5. Prevention during model selection and evaluation

Use nested cross-validation for hyperparameter tuning, ensure validation folds respect temporal or group structure, and never use test set for model selection.

Key Points to Mention

  • Data leakage leads to overly optimistic performance estimates and poor generalization.
  • Always split data before any preprocessing; use pipelines to encapsulate steps.
  • For time-series, use temporal splits (e.g., train on past, validate on future).
  • Use group-aware splitting when data has hierarchical or grouped structure (e.g., multiple records per user).
  • Target leakage: avoid features that are proxies for the target or only available after the target event.
  • Nested cross-validation for unbiased performance estimation when tuning hyperparameters.

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