KatInterview

Five ML Concepts: Gradients, Penalties, Dropout, Similarity, Encoding

Machine LearningModel answer
EasyModel answerMachine Learningloss-functionsregularizationdropout

Last updated

Answer five conceptual ML questions covering loss gradients, L1 vs L2 penalties, activations and dropout, cosine vs Euclidean similarity, and encoding high-cardinality categorical features.

Applied ML Concepts: Short-Answer Set

Imagine you are asked to talk through the following five topics. For each one, give the underlying mechanism rather than a bare definition, and back it with a short equation or a concrete example.

1. Loss gradients and training behavior

Show how the derivative of the squared-error loss leads to the weight-update rule in gradient descent. Then explain how switching from squared error to cross-entropy changes the way a classifier trains.

2. Taming overfitting with penalties

A model fits the training set very well but does poorly on held-out data. Contrast L1 and L2 penalties on the weights. When would you choose one over the other, and how do they differ geometrically in how they constrain the weight vector?

3. Hidden-layer building blocks

Why must hidden layers use non-linear activations such as ReLU rather than linear ones? Also describe how dropout works during training, why it regularizes, and how it behaves differently when the model is used for prediction.

4. Measuring closeness

When is cosine similarity a better choice than Euclidean distance, for example in recommenders or clustering? Give a small example in which Euclidean distance gives a misleading answer.

5. Encoding many-valued categories

You have a categorical column with thousands of distinct values, such as postal codes. What goes wrong with one-hot encoding here, and what other encodings could you use?

Hints

Hint 1

For topic 1, write the gradient with respect to the pre-activation of a sigmoid output under each loss and see which factor appears in one but cancels in the other.

Hint 2

For topic 2, compare the size of the penalty's pull on a weight as the weight gets small, and picture the shape of each constraint region (round vs. pointed).

Hint 3

For topics 4 and 5, build a tiny numeric example: two vectors pointing the same way with different lengths, and a category appearing only a handful of times. Think about leakage when you use the target to encode.