← Waymo Interview Insights

Waymo·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Apr 2026

Summary

Waymo ML engineer interview had me implementing K-Means from scratch using only NumPy, then defending design choices out loud. Pretty deep for a single coding round, they clearly wanted someone who actually understands the math and not just sklearn wrappers.

Questions Asked (3)

Q1

Implement K-Means clustering from scratch using only NumPy. Your solution should include a fit method that initializes centroids, iteratively assigns points to the nearest centroid, and recomputes centroids until convergence or a maximum iteration limit. Also implement a predict method for new points. Use vectorized broadcasting for distance computation, handle empty clusters, and report final inertia.

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

The vectorized distance matrix part is where I almost tripped up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then outline the K-Means algorithm steps. Write clean, vectorized NumPy code with clear comments, and discuss edge cases like empty clusters and convergence criteria. Finally, analyze the time complexity and potential optimizations.

Pro tip: Mention that you would use K-Means++ initialization to improve convergence and avoid poor local minima, and discuss how to handle empty clusters by reassigning them to the farthest points from their centroids.

1. Clarify requirements and constraints

Ask about dataset size, dimensionality, and whether to implement K-Means++ initialization. Confirm that only NumPy is allowed and discuss performance expectations.

2. Design the class structure and initialization

Define a class with fit and predict methods. For initialization, either randomly select k points or implement K-Means++ for better centroid seeding.

3. Implement vectorized distance computation and assignment

Use broadcasting to compute pairwise distances between points and centroids efficiently. Assign each point to the nearest centroid using argmin.

4. Update centroids and handle empty clusters

Recompute centroids as the mean of assigned points. If a cluster is empty, reassign it to the point farthest from its current centroid or reinitialize randomly.

5. Convergence check and inertia calculation

Iterate until centroid movement is below a tolerance or max iterations reached. Compute final inertia as the sum of squared distances of each point to its centroid.

Key Points to Mention

  • Vectorized broadcasting for distance computation to avoid loops and improve performance.
  • Handling empty clusters by reassigning centroids to the farthest points or reinitializing.
  • Convergence criteria: either centroid shift below tolerance or maximum iterations.
  • Inertia (within-cluster sum of squares) as the objective function and its final value.
  • Time complexity: O(n * k * d * iterations) and potential optimizations like using tree-based methods.
  • K-Means++ initialization for better and more stable clustering results.

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

Q2

What is the computational complexity per iteration of K-Means, and how does initialization strategy affect the algorithm's sensitivity and final result quality?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Complexity I had down: O(n times k times d) per iteration for assigning points, where d is dimensionality.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly stating the computational complexity per iteration of K-Means, breaking it down into assignment and update steps. Then discuss how initialization strategies like K-Means++ and random initialization affect convergence, sensitivity to local optima, and final clustering quality. Finally, relate this to practical implications in large-scale or safety-critical settings like autonomous driving.

Pro tip: Emphasize that while K-Means is fast per iteration, the number of iterations and initialization quality often dominate overall runtime and result quality—mentioning K-Means++ as a standard improvement shows you understand real-world trade-offs.

1. State the per-iteration complexity

Clearly express the complexity as O(n * k * d) per iteration, where n is number of points, k is number of clusters, and d is dimensionality. Explain that this comes from computing distances from each point to each centroid.

2. Break down the algorithm steps

Describe the assignment step (assign each point to nearest centroid) and the update step (recompute centroids). Note that both steps contribute to the overall complexity.

3. Discuss initialization strategies

Compare random initialization with K-Means++ (and possibly other methods like PCA-based). Explain how K-Means++ reduces the chance of poor local optima by spreading initial centroids.

4. Analyze sensitivity and quality impact

Explain that poor initialization can lead to suboptimal clustering (higher inertia) and variable results across runs. K-Means++ often leads to faster convergence and better final quality, though it adds a small overhead.

5. Relate to practical considerations

Mention that in practice, multiple restarts with different initializations are common. For large-scale or real-time systems (like Waymo), the trade-off between initialization cost and result quality is crucial.

Key Points to Mention

  • Per-iteration complexity: O(n * k * d)
  • Assignment step computes distances from each point to each centroid
  • Update step recomputes centroids as mean of assigned points
  • Random initialization can lead to poor local optima and high variance
  • K-Means++ improves initialization by selecting centroids far apart
  • Multiple restarts (e.g., n_init) are often used to mitigate initialization sensitivity

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

Q3

How would you choose the right value of k? Walk through the elbow method and silhouette scoring.

Technical Trade-offsProduct Analytics & Metrics
Author's notes

Knew this cold so it was a relief after the coding stress.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing k-selection as a trade-off between model complexity and cluster quality, then walk through the elbow method and silhouette scoring as complementary diagnostic tools. Emphasize that no single metric is definitive; combine them with domain knowledge and downstream task performance to choose k.

Pro tip: Mention that in practice, the elbow method can be ambiguous and silhouette scores can favor convex clusters, so for real-world data (like Waymo's sensor data), you should validate k using a held-out metric tied to the business objective, such as cluster purity for labeling or stability across bootstrap samples.

1. Define the goal and constraints

Clarify what the clustering is for (e.g., customer segmentation, anomaly detection) and any constraints like interpretability or computational budget. This guides whether you prioritize compactness, separation, or domain-specific validity.

2. Elbow method: plot inertia vs. k

Run k-means for a range of k, compute within-cluster sum of squares (inertia), and plot it. Look for the 'elbow' where the rate of decrease sharply changes, indicating diminishing returns.

3. Silhouette scoring: evaluate cluster separation

For each k, compute the average silhouette coefficient, which measures how similar points are to their own cluster vs. the next closest. Choose k that maximizes the score, but also inspect per-cluster silhouettes for outliers.

4. Combine metrics and validate

Cross-reference elbow and silhouette results; if they disagree, investigate. Use additional validation like gap statistic, Davies-Bouldin index, or stability analysis across resamples.

5. Tie back to business objective

Select k that yields actionable clusters for the downstream task. For example, if clusters will be used for targeted marketing, ensure they are distinct and sizable enough to be actionable.

Key Points to Mention

  • Elbow method: inertia (WCSS) vs. k, look for inflection point; subjective and can be unclear.
  • Silhouette score: range [-1, 1], higher is better; measures cohesion and separation.
  • Limitations: both assume spherical clusters and can fail with non-convex shapes; silhouette is O(n^2) so may not scale.
  • Alternative methods: gap statistic, Davies-Bouldin, Calinski-Harabasz, and stability-based approaches.
  • Domain knowledge: incorporate business context and downstream evaluation to finalize k.
  • Scalability: for large datasets, use mini-batch k-means or sampling to compute metrics efficiently.

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