← Coinbase Interview Insights

Coinbase·Data Scientist·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026Remote

Summary

Coinbase data scientist interview that went deep on ML fundamentals, specifically building a random forest from scratch with no library shortcuts. Not the vibe I expected from a crypto company but they clearly care about the theory.

Questions Asked (2)

Q1

Implement a Random Forest classifier from scratch, without using any ML libraries. Walk through how you'd build the decision tree component, handle bootstrap sampling and random feature selection, and aggregate predictions across trees.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

This was a lot to hold in your head at once.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the scope and constraints (e.g., dataset size, performance requirements) to tailor your implementation. Then, outline the three main components: decision tree building with recursive splitting, bootstrap sampling and random feature selection, and aggregation via majority vote. Walk through the algorithm step-by-step, emphasizing key design choices and trade-offs.

Pro tip: Mention that you would implement the decision tree using an iterative approach (e.g., a stack) to avoid recursion depth issues, and discuss how to handle missing values or categorical features—showing awareness of real-world data challenges.

1. Clarify Requirements and Constraints

Ask about dataset size, feature types, performance expectations, and whether any optimizations are needed. This shows you think before coding.

2. Design the Decision Tree

Explain recursive binary splitting: choose the best split based on impurity (Gini or entropy), stopping criteria (max depth, min samples), and how to handle leaf predictions.

3. Implement Bootstrap Sampling and Feature Randomness

Describe how to create bootstrap samples (sampling with replacement) and randomly select a subset of features at each split to decorrelate trees.

4. Aggregate Predictions

For classification, use majority voting; for regression, average. Discuss how to combine tree outputs efficiently.

5. Discuss Optimizations and Trade-offs

Mention computational complexity, parallelization opportunities, and how hyperparameters (number of trees, max depth) affect performance.

Key Points to Mention

  • Impurity measures: Gini impurity and entropy, and how to compute them efficiently.
  • Stopping criteria: maximum depth, minimum samples per leaf, and minimum impurity decrease.
  • Bootstrap sampling: sampling with replacement, out-of-bag error estimation.
  • Random feature selection: typically sqrt(n_features) for classification, and its role in reducing correlation.
  • Aggregation: majority voting for classification, averaging for regression.
  • Handling edge cases: missing values, categorical features, and class imbalance.

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

Q2

What are the key hyperparameters in a random forest and how do they affect model behavior and computational cost?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Covered n_estimators, max_depth, and max_features.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining random forest as an ensemble of decision trees and then systematically cover the most impactful hyperparameters: number of trees, max depth, max features, min samples per leaf/split, and bootstrap/sample size. For each, explain how it influences bias-variance trade-off, overfitting, and computational cost (training time, memory, inference). Conclude with a practical strategy for tuning these hyperparameters, emphasizing that n_estimators can be increased until performance plateaus, while others require cross-validation.

Pro tip: Mention that in practice, n_estimators is often set high (e.g., 500-1000) because more trees never hurt accuracy (only compute), while max_features is the most critical for decorrelating trees and controlling the bias-variance trade-off. Also note that in distributed settings like Spark, communication overhead can dominate, so tuning n_estimators and max_depth for parallelism is key.

1. Define random forest and its core hyperparameters

Briefly state that random forest is a bagging ensemble of decision trees and list the main hyperparameters: n_estimators, max_depth, max_features, min_samples_split, min_samples_leaf, bootstrap, and max_samples.

2. Explain effect on model behavior (bias-variance)

For each hyperparameter, describe how it affects overfitting/underfitting. For example, increasing max_depth reduces bias but increases variance; increasing min_samples_leaf increases bias but reduces variance.

3. Explain effect on computational cost

Discuss how each hyperparameter impacts training time, memory usage, and inference latency. For instance, n_estimators linearly increases training time; max_depth increases both time and memory exponentially in worst case.

4. Provide practical tuning guidance

Suggest a tuning strategy: set n_estimators high, tune max_features and max_depth via cross-validation, then adjust min_samples_leaf/split to control overfitting. Mention that max_features is often the most important.

5. Connect to real-world constraints (e.g., Coinbase)

Highlight trade-offs in production: need for low-latency inference may limit tree depth, while large n_estimators can be parallelized. Mention that in financial applications, interpretability and stability may favor shallower trees.

Key Points to Mention

  • n_estimators: number of trees; more trees reduce variance and stabilize predictions but increase training time linearly and memory.
  • max_features: number of features considered at each split; lower values decorrelate trees and reduce variance but may increase bias; key for high-dimensional data.
  • max_depth: maximum depth of each tree; deeper trees reduce bias but increase variance and computational cost (time and memory).
  • min_samples_split and min_samples_leaf: control the minimum samples required to split or be a leaf; higher values increase bias, reduce variance, and speed up training.
  • bootstrap and max_samples: whether to use bootstrap samples and how many; affects diversity of trees and computational cost.
  • Computational cost: training time scales with n_estimators, max_depth, and number of features; inference time scales with number of trees and depth.

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