Module quiz

Trees, ensembles and classical models quiz

31 questions across 2 lessons. Choose an answer, check it, and read why each option is right or wrong.

Checking answers needs JavaScript. You can still read every question and option below.

0 of 31 answered

Keyboard: arrow keys move between options. Space or Enter selects the focused option.

Decision trees, random forests and gradient boosting14 questions

ObjectiveCompute the Gini and entropy gain of a split by hand, explain why greedy splitting grows trees that overfit, and choose the controls (depth, leaf size, pruning) by validation error.

  1. Question 1 of 31A node holds 8 rows, 4 positive and 4 negative. Split A sends them to (3 positive, 1 negative) and (1 positive, 3 negative). Split B sends them to (4 positive, 2 negative) and (0 positive, 2 negative). Which split has the larger Gini gain?

    Choose one answer.

  2. Question 2 of 31Which statements about how trees choose splits are true? Select all that apply.

    Choose all that apply.

  3. Question 3 of 31You grow a full tree and then apply cost-complexity pruning, raising ccp_alpha from 0 through a series of larger values. What do you expect, and how do you pick the value to keep?

    Choose one answer.

ObjectiveUse the variance of an average of correlated predictors, rho sigma^2 + (1 - rho) sigma^2 / B, to explain what bagging and feature subsampling fix and what more trees cannot, and use out-of-bag error as a free validation estimate.

  1. Question 4 of 31A bag of B = 50 trees has per-tree prediction variance 4 and pairwise correlation 0.25. What is the variance of the averaged prediction, and roughly what happens if you raise B to 5,000?

    Choose one answer.

  2. Question 5 of 31A random forest of 100 trees has the same validation error as one of 1,000 trees, and the error is well above what the team needs. The data has several useful features. Which change could lower the error floor the formula describes?

    Choose one answer.

  3. Question 6 of 31Which statements about out-of-bag (OOB) error in a bagged forest are true? Select all that apply.

    Choose all that apply.

ObjectiveExplain gradient boosting as stagewise fitting of the negative gradient (residuals for squared error, y - p for log loss), say how learning rate, number of rounds and tree depth interact, and contrast it with bagging.

  1. Question 7 of 31Squared-error gradient boosting on three rows with targets y = (2, 4, 9). The starting constant is the mean, 5. The first stump puts rows 1 and 2 in one leaf and row 3 in the other, and the learning rate is 0.5. What are the predictions after round 1?

    Choose one answer.

  2. Question 8 of 31A gradient-boosted binary classifier uses log loss on a raw score F, with probability p = sigmoid(F). For a row with y = 1 and current score F = -1.0, what target does the next regression tree receive for this row?

    Choose one answer.

  3. Question 9 of 31In a boosting run with learning rate 0.3 and depth-4 trees, training loss falls on every round of 2,000. Validation loss reaches its minimum at round 140 and rises afterwards. What is the best response?

    Choose one answer.

  4. Question 10 of 31Which statements correctly contrast bagging (random forests) with gradient boosting? Select all that apply.

    Choose all that apply.

ObjectiveDecide when tree ensembles are the right default for tabular data, and avoid the practical traps: impurity importance, correlated features, missing values, high-cardinality categoricals and extrapolation.

  1. Question 11 of 31A forest's impurity-based feature importance ranks customer_id, a unique identifier per row, as the second most important feature. Permutation importance on a held-out validation set puts it near zero. How do you read this?

    Choose one answer.

  2. Question 12 of 31Which statements about missing values and categorical features in tree models are true? Select all that apply.

    Choose all that apply.

  3. Question 13 of 31A boosted-tree model for weekly sales is trained on 2020 to 2023, where sales rose steadily. In 2024 it predicts a flat line near the 2023 level while actual sales keep rising. What explains this, and what is a sensible fix?

    Choose one answer.

  4. Question 14 of 31A table has 200 rows and six numeric features whose relationship to the target is linear plus noise. On validation, least squares scores MSE 1.05, boosted trees 1.52 and a random forest 1.64, with a noise floor of 1.0. A colleague says trees always win on tabular data. What is the best response?

    Choose one answer.

k-NN, k-means, PCA, SVM and naive Bayes: the classical toolkit17 questions

ObjectiveExplain k-nearest neighbours as a model that stores the data, how k trades bias against variance, and why distance concentrates in high dimensions so that irrelevant or unscaled columns wreck the neighbours.

  1. Question 15 of 31A rental-price classifier uses 5-NN on three columns: floor area in square metres (20 to 200), number of rooms (1 to 5) and distance to the nearest metro station in metres (50 to 5,000). Accuracy is poor and the neighbours it returns look similar only in metro distance. What is the most direct fix?

    Choose one answer.

  2. Question 16 of 31Which statements about k-nearest neighbours are true? Select all that apply.

    Choose all that apply.

  3. Question 17 of 31For 1,000 uniformly random points in 500 dimensions, an engineer finds that for a typical query the ratio (nearest distance) / (farthest distance) is about 0.85. What does this say about k-NN on data like this?

    Choose one answer.

  4. Question 18 of 31On a validation set of 1,000 rows, a k-NN fraud model has these results. k = 1: accuracy 0.72 (training accuracy 1.00). k = 15: 0.79. k = 301: 0.74. What should you conclude?

    Choose one answer.

ObjectiveRun the k-means loop by hand, explain why it reaches only a local optimum and what k-means++ and restarts change, choose k with inertia and silhouette, and name the cases where it fails (non-convex shapes, unscaled columns, outliers) with DBSCAN and hierarchical clustering as alternatives.

  1. Question 19 of 31Five points on a line: 0, 2, 3, 10, 11. k-means with k = 2 starts with centres at 2 and 3. After the first update step, what are the centres, and what happens in the next assignment step?

    Choose one answer.

  2. Question 20 of 31A customer-segmentation job gives different segments each night, although the data barely changes. Which statements are true? Select all that apply.

    Choose all that apply.

  3. Question 21 of 31A fraud analyst runs k-means with k = 3 on two columns: transaction amount (0 to 50,000) and number of items (1 to 10). The three clusters are simply low, middle and high amounts, whatever the item count. What is the cause and the first thing to try?

    Choose one answer.

  4. Question 22 of 31You must group GPS pings into regions. The regions are curved, such as a ring road and a river bank, their number is unknown, and about 5% of the pings are errors that should be flagged. Which approach fits best?

    Choose one answer.

  5. Question 29 of 31On a customer data set, k-means gives these inertias for k = 2 to 8: 900, 610, 190, 170, 155, 142, 131. The silhouette scores are 0.41, 0.49, 0.64, 0.52, 0.47, 0.40, 0.37. What do you report as the number of clusters, and how do you support it?

    Choose one answer.

ObjectiveCompute PCA by centring, covariance and eigen-decomposition, read the explained variance to pick the number of components, and say when PCA misleads (units, signal in low-variance directions, non-linear structure).

  1. Question 23 of 31After centring, two features have covariance matrix with rows (5, 2) and (2, 2). Its eigenvalues are 6 and 1. What share of the total variance does the first principal component explain?

    Choose one answer.

  2. Question 24 of 31Which statements about using PCA before a classifier are true? Select all that apply.

    Choose all that apply.

  3. Question 25 of 31A factory monitors 40 sensors. Reducing them to the 3 principal components that explain 98% of the variance leaves a fault detector with much lower recall. Engineers found that faults appear as small shifts in a combination of sensors that normally varies very little. What explains the drop?

    Choose one answer.

ObjectiveChoose between k-NN, a linear or kernel SVM, naive Bayes, trees and linear models for a case from its size, dimension, need for probabilities and need for explanation, using the margin and hinge loss for the SVM and the independence assumption for naive Bayes.

  1. Question 26 of 31You have 40,000 documents, about 20,000 sparse word-count columns, a binary label, and one day to ship a first baseline that ranks documents; calibrated probabilities are not needed yet. Which first model family is the best choice?

    Choose one answer.

  2. Question 27 of 31A linear SVM on a noisy two-class data set is retrained with C raised from 0.1 to 100, nothing else changed. What do you expect, and why?

    Choose one answer.

  3. Question 28 of 31In a naive Bayes spam filter, the single strongest word feature accidentally appears three times in the feature vector (the same count copied twice). Which statements are true? Select all that apply.

    Choose all that apply.

ObjectiveSay what Gaussian mixtures with EM, Isolation Forest, t-SNE and UMAP add to k-means and PCA, and why the clusters of a t-SNE plot are not features.

  1. Question 30 of 31A t-SNE plot of 40,000 customers shows six well-separated islands. A product manager wants to ship the island numbers as segment features in a production model, and to place next month's new customers by running t-SNE again on them alone. What is the main problem?

    Choose one answer.

  2. Question 31 of 31Which statements about Gaussian mixtures and unlabelled anomaly detection are true? Select all that apply.

    Choose all that apply.

Boss challenge: Trees, ensembles and the classical toolkit

A longer check of the whole module. It is optional, and nothing else on the site depends on it.

  • 10 questions, taken from the lesson quizzes above.
  • Pass mark: 7 correct of 10.
  • You can try it as many times as you like.
  • A correct answer is kept, so a pass can build up across several tries.
  • If you miss some, you get links to the lesson sections to read again.

Checking answers needs JavaScript. You can still read every question and option below.

0 of 10 answered

Keyboard: arrow keys move between options. Space or Enter selects the focused option.

  1. Question 1 of 10Which statements about how trees choose splits are true? Select all that apply.

    Choose all that apply.

  2. Question 2 of 10A bag of B = 50 trees has per-tree prediction variance 4 and pairwise correlation 0.25. What is the variance of the averaged prediction, and roughly what happens if you raise B to 5,000?

    Choose one answer.

  3. Question 3 of 10Which statements correctly contrast bagging (random forests) with gradient boosting? Select all that apply.

    Choose all that apply.

  4. Question 4 of 10A boosted-tree model for weekly sales is trained on 2020 to 2023, where sales rose steadily. In 2024 it predicts a flat line near the 2023 level while actual sales keep rising. What explains this, and what is a sensible fix?

    Choose one answer.

  5. Question 5 of 10On a validation set of 1,000 rows, a k-NN fraud model has these results. k = 1: accuracy 0.72 (training accuracy 1.00). k = 15: 0.79. k = 301: 0.74. What should you conclude?

    Choose one answer.

  6. Question 6 of 10A customer-segmentation job gives different segments each night, although the data barely changes. Which statements are true? Select all that apply.

    Choose all that apply.

  7. Question 7 of 10A factory monitors 40 sensors. Reducing them to the 3 principal components that explain 98% of the variance leaves a fault detector with much lower recall. Engineers found that faults appear as small shifts in a combination of sensors that normally varies very little. What explains the drop?

    Choose one answer.

  8. Question 8 of 10A linear SVM on a noisy two-class data set is retrained with C raised from 0.1 to 100, nothing else changed. What do you expect, and why?

    Choose one answer.

  9. Question 9 of 10A t-SNE plot of 40,000 customers shows six well-separated islands. A product manager wants to ship the island numbers as segment features in a production model, and to place next month's new customers by running t-SNE again on them alone. What is the main problem?

    Choose one answer.

  10. Question 10 of 10Which statements about Gaussian mixtures and unlabelled anomaly detection are true? Select all that apply.

    Choose all that apply.