KatInterview

Core ML Concepts: Trees, Training Loops, Metrics, Embeddings, Attention

Machine LearningModel answer
MediumModel answerMachine Learningdecision-treesgradient-boostingoverfitting

Last updated

A five-part conceptual walkthrough covering ensembles of trees, supervised training, evaluation under imbalance, embeddings, and the basics of transformer attention.

Core ML Concepts: Trees, Training Loops, Metrics, Embeddings, Attention

Imagine a screening conversation for a junior ML engineer. You are not asked for proofs. You are asked to explain ideas accurately, give concrete examples, and discuss trade-offs. Plan on a few minutes per part, and bring up well-known pitfalls (overfitting, leakage, misleading metrics) before anyone asks.

Before answering, decide what you would clarify: the intended depth, whether the task is classification, regression or ranking, and whether the tree discussion is about a single tree, a forest, or boosted trees.

Part 1: Tree models

Describe how a single decision tree is built and used for prediction. Then contrast bagging (random forests) with boosting (gradient-boosted trees). Why do ensembles usually beat one tree, and when would you choose boosting over a forest?

Part 2: Training a supervised model

Walk through the training process. Cover the loss function, gradient descent, train/validation/test splits, regularization, and how you spot and reduce overfitting.

Part 3: Evaluating a model

How do you choose evaluation metrics? Explain why accuracy can mislead, and how class imbalance and the decision threshold change the conclusions you draw.

Part 4: Embeddings

What is an embedding and what does it represent? Why use embeddings instead of raw IDs or one-hot vectors? How are they learned, and where would you apply them?

Part 5: Transformer basics

What does self-attention compute? Why did transformers largely displace RNNs for sequence modeling? What role does positional encoding play?

Hints

Hint 1

For trees, tie each ensemble method to what it fixes: one reduces variance, the other reduces bias. Think about how correlation between trees affects the benefit of averaging.

Hint 2

For training and evaluation, separate three things: the data used to fit parameters, the data used to make decisions (hyperparameters, thresholds), and the data used only for the final estimate. Then ask what happens when these get mixed.

Hint 3

For embeddings and attention, focus on what geometry or weighting the model learns, and what is lost without it (similarity for IDs, word order for attention).