179 questions
No questions match those filters.
Write k-fold cross-validation from scratch, and explain...
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansThe mechanics: shuffle the data, split it into K roughly equal folds, then run K rounds where one fold is held out as the test set and the rest are pooled for training. Each round produces one accuracy (or whatever metric you’re tracking), and you end up with K scores instead of just one.
That’s the reason it’s better than a single train-test split — one split gives you a single number that could be an artifact of a particularly easy or hard partition, purely by chance. K numbers let you report a mean, which tells you expected performance, and a standard deviation, which tells you how stable the model is across different slices of the data; a low std means consistent performance regardless of which data it happened to train on, a high std is a warning sign. Two details are easy to get wrong: shuffle before splitting so fold order doesn’t correlate with anything in the data, and use stratified folds for imbalanced classes so each fold keeps the same class proportions as the whole dataset.