Explain Random Forest randomness and implications

Quick Overview

This question evaluates a candidate's understanding of Random Forest ensemble mechanics—sources of randomness, their effects on bias and variance, hyperparameter impacts, evaluation choices (OOB vs cross-validation), feature-importance bias, and class-imbalance strategies—within the Machine Learning domain for binary classification.

Explain Random Forest randomness and implications

Company: Snapchat

Role: Data Scientist

Category: Machine Learning

Difficulty: hard

Interview Round: Onsite

Random Forest rigor: 1) Enumerate all sources of randomness (bootstrap sampling, feature subsampling at each split, random tie-breaking, randomized split points) and explain the effect of each on bias and variance. 2) For a dataset with 100k rows, 100 features, and a 5% positive rate, propose n_estimators, max_depth, and max_features; justify how max_features controls tree correlation. 3) Compare out-of-bag (OOB) error to 5-fold cross-validation; when can they disagree and why? 4) Why are impurity-based importances biased toward continuous or high-cardinality features? Propose and justify a corrected approach (e.g., permutation importance with stratified shuffles and repeated runs). 5) Outline strategies for class imbalance (class_weight, threshold moving, balanced subsampling) and discuss consequences for probability calibration and decision thresholds.

Quick Answer: This question evaluates a candidate's understanding of Random Forest ensemble mechanics—sources of randomness, their effects on bias and variance, hyperparameter impacts, evaluation choices (OOB vs cross-validation), feature-importance bias, and class-imbalance strategies—within the Machine Learning domain for binary classification.

|Home/Machine Learning/Snapchat
Snapchat logo
Snapchat
Oct 13, 2025, 9:49 PM
hardData ScientistOnsiteMachine Learning
7
0

Random Forest — Rigor and Practical Choices

Context: You are building a binary classifier with a Random Forest. The dataset has 100,000 rows, 100 features, and a 5% positive rate. Answer the following:

  1. Sources of Randomness
  • Enumerate the sources of randomness in Random Forests (e.g., bootstrap sampling, feature subsampling at each split, random tie-breaking, randomized split points). For each, explain its typical effect on bias and variance.
  1. Hyperparameters for the Given Dataset
  • Propose reasonable values for n_estimators, max_depth, and max_features for the dataset above.
  • Justify how max_features controls correlation among trees and the bias–variance trade-off.
  1. OOB Error vs 5-Fold Cross-Validation
  • Compare out-of-bag (OOB) error with 5-fold cross-validation (CV).
  • When can they disagree and why?
  1. Feature Importance Bias
  • Explain why impurity-based importances are biased toward continuous or high-cardinality features.
  • Propose a corrected approach (e.g., permutation importance with stratified shuffles and repeated runs) and justify your design.
  1. Class Imbalance Strategies
  • Outline strategies for class imbalance (e.g., class_weight, threshold moving, balanced subsampling).
  • Discuss consequences for probability calibration and decision thresholds.
Loading comments...