Decision Trees and Random Forests
- 41Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is a decision tree in machine learning?
What is a decision tree in machine learning?
41 questions
- 1
What is a decision tree in machine learning?
- A
A method that combines many models by averaging their individual outputs
- B
A table that stores every possible feature combination and its target value
- C
A tree-like structure generated from data to make predictions or classifications
- D
A process that transforms features into a single numerical score
Correct answer
CA tree-like structure generated from data to make predictions or classifications
Explanation
A decision tree is generated from data and uses a tree-like structure to predict target values or assign classifications.
- A
- 2
Which distinction between classification and regression matches the content?
- A
Classification assigns an example to a predefined class; regression predicts a target value
- B
Classification builds a tree; regression uses only a single average prediction
- C
Classification selects features; regression selects the training examples to retain
- D
Classification predicts a numerical target; regression assigns an example to a predefined class
Correct answer
AClassification assigns an example to a predefined class; regression predicts a target value
Explanation
Classification chooses among predefined categories, whereas regression predicts an output or target-feature value.
- A
- 3
Which types of machine learning problems can decision trees address, according to the lecture?
- A
Only regression problems
- B
Only classification problems
- C
Only problems with a categorical target and no features
- D
Classification and regression problems
Correct answer
DClassification and regression problems
Explanation
The content describes decision trees as applicable to both classification and regression problems.
- A
- 4
What does a node in a decision tree represent during its construction?
- A
A single feature value shared by every sample in the dataset
- B
A fixed prediction that is independent of the data reaching it
- C
A separate training dataset created by averaging other datasets
- D
A collection of data points that has reached that part of the tree
Correct answer
DA collection of data points that has reached that part of the tree
Explanation
Each node contains a collection of data points; splitting a node divides its data among child nodes.
- A
- 5
What data does the root node contain before any splits are made?
- A
Only the data points from the largest class
- B
All data points in the problem
- C
A random subset containing one feature from each sample
- D
Only data points that already have pure class membership
Correct answer
BAll data points in the problem
Explanation
The root is the initial node and contains all the data points before the tree partitions them.
- A
- 6
If a classifier makes no splits and always predicts a most frequent class, what limitation does the example illustrate?
- A
It will classify every training example correctly but fail only on regression data
- B
It uses all features, so it is likely to overfit the training set
- C
It produces pure nodes without needing to examine feature values
- D
It can be correct only for examples in the predicted class, so its accuracy may be poor
Correct answer
DIt can be correct only for examples in the predicted class, so its accuracy may be poor
Explanation
At the root, always choosing a most frequent class ignores the features. In the example, predicting versicolor would correctly label only 50 of 149 samples.
- A
- 7
In a regression problem, what simple prediction might be made at an unsplit root node?
- A
A random value selected from the feature ranges
- B
The target value of the first training example
- C
The average target value across the training data
- D
The most frequent target value after converting it to a class
Correct answer
CThe average target value across the training data
Explanation
The lecture explains that an unsplit regression model could predict the average target value of all training examples, though this may be a poor model.
- A
- 8
Why might a tree that perfectly separates its training data still be undesirable?
- A
It necessarily increases impurity at every child node
- B
It cannot make predictions for examples with numerical features
- C
It may overlearn the training data and generalize poorly to new examples
- D
It prevents the use of a test set to assess performance
Correct answer
CIt may overlearn the training data and generalize poorly to new examples
Explanation
Perfect separation of the training set can reflect overlearning, which may reduce the tree’s ability to generalize to new data.
- A
- 9
How many Iris samples and species are used in the lecture’s example?
- A
150 samples across setosa, versicolor, and virginica
- B
100 samples across four different Iris species
- C
149 samples across setosa, versicolor, and virginica
- D
149 samples across setosa and versicolor only
Correct answer
C149 samples across setosa, versicolor, and virginica
Explanation
The example uses 149 preclassified samples: 49 setosa, 50 versicolor, and 50 virginica.
- A
- 10
Which set lists the four measured features in the Iris example?
- A
Sepal length, stem width, petal length, and leaf width
- B
Sepal length, sepal width, petal length, and petal width
- C
Flower length, flower width, sepal length, and petal color
- D
Sepal width, petal width, flower height, and stem length
Correct answer
BSepal length, sepal width, petal length, and petal width
Explanation
The four features described are sepal length, sepal width, petal length, and petal width.
- A
- 11
What role do the preclassified Iris samples play in the example?
- A
They serve only to test a tree after it has been built without training data
- B
They define the feature ranges but are not used to learn classifications
- C
They train a classifier to assign a species to a new flower from its features
- D
They provide the final predictions without requiring a learned model
Correct answer
CThey train a classifier to assign a species to a new flower from its features
Explanation
The preclassified samples provide training data from which a decision tree learns to classify new flowers using their measured features.
- A
- 12
Which sepal-length ranges are reported for the three Iris species?
- A
Setosa: 1–1.9; versicolor: 3–5.1; virginica: 4.5–6.9
- B
Setosa: 4.3–5.8; versicolor: 4.9–7; virginica: 4.9–7.9
- C
Setosa: 4.9–7; versicolor: 4.3–5.8; virginica: 4.9–7.9
- D
Setosa: 4.3–5.8; versicolor: 4.9–7.9; virginica: 4.9–7
Correct answer
BSetosa: 4.3–5.8; versicolor: 4.9–7; virginica: 4.9–7.9
Explanation
The lecture reports sepal-length ranges of 4.3–5.8 for setosa, 4.9–7 for versicolor, and 4.9–7.9 for virginica.
- A
- 13
Why are the Iris species and their feature measurements useful for illustrating a decision tree?
- A
They establish that one feature always separates all three species completely
- B
They show that classifying flowers requires no labeled training examples
- C
They guarantee that every possible threshold creates three perfectly pure groups
- D
They show how measured features can be used to partition labeled samples and classify a new sample
Correct answer
DThey show how measured features can be used to partition labeled samples and classify a new sample
Explanation
The example demonstrates how a tree uses feature measurements to divide labeled training data and then classify a new flower by following the resulting decisions.
- A
- 14
For a node with class fractions fi, how is its Gini impurity defined in the lecture?
- A
∑ifi
- B
1−∑ifi
- C
1−∑ifi2
- D
∑ifi2−1
Correct answer
C1−∑ifi2
Explanation
Gini impurity is calculated as 1−∑ifi2, where each fi is the fraction of node samples belonging to class i.
- A
- 15
At the Iris root node, what fraction corresponds to setosa?
- A
50/149
- B
1/3
- C
49/149
- D
49/50
Correct answer
C49/149
Explanation
The root contains 49 setosa samples among 149 total samples, so the setosa fraction is 49/149.
- A
- 16
What is the Gini impurity of a node containing samples from only one class?
- A
The fraction of samples in the largest class
- B
One
- C
The number of samples in the node
- D
Zero
Correct answer
DZero
Explanation
A pure node has one class fraction equal to 1 and all other class fractions equal to 0. Substituting these into 1−∑ifi2 gives zero.
- A
- 17
What does a nonzero Gini impurity indicate about a node?
- A
The node contains no samples from the training dataset
- B
The node predicts a numerical target instead of a class
- C
The node contains a mixture of classes rather than only one class
- D
The node has already been split into its maximum possible number of children
Correct answer
CThe node contains a mixture of classes rather than only one class
Explanation
When multiple classes are represented in a node, more than one class fraction is nonzero and its Gini impurity is positive.
- A
- 18
Which impurity measure is associated with classification problems in the lecture?
- A
Gini impurity or information entropy
- B
Feature-range overlap only
- C
Mean target value only
- D
Variance reduction only
Correct answer
AGini impurity or information entropy
Explanation
The lecture identifies Gini impurity and information entropy as measures typically used for classification trees.
- A
- 19
Which measure is identified for building regression trees?
- A
Majority-class frequency
- B
Information entropy only
- C
Gini impurity only
- D
Variance reduction
Correct answer
DVariance reduction
Explanation
Variance reduction is identified as a metric used when modeling regression problems.
- A
- 20
How is a candidate Gini split index calculated for two child nodes?
- A
The larger child impurity minus the smaller child impurity
- B
Parent impurity plus the unweighted sum of the two child impurities
- C
The average of the two child impurities divided by the parent impurity
- D
Parent impurity minus each child impurity weighted by that child’s fraction of the data
Correct answer
DParent impurity minus each child impurity weighted by that child’s fraction of the data
Explanation
The split index is the parent Gini impurity minus the weighted child impurities: each child’s impurity is multiplied by the fraction of parent data sent to that child.
- A
- 21
Why does a larger Gini split index indicate a preferable split in the lecture’s procedure?
- A
It means the weighted impurity of the children is lower relative to the parent
- B
It means the parent node was already pure before splitting
- C
It means the children contain more samples than the parent
- D
It means the split used fewer features than every alternative
Correct answer
AIt means the weighted impurity of the children is lower relative to the parent
Explanation
The split index measures the reduction in impurity. A larger value means the child nodes have lower weighted impurity and are closer to pure.
- A
- 22
What feature-based operation is performed at a decision point in a tree?
- A
All feature values are averaged to create a new class label
- B
A feature value is compared with a threshold to choose a child branch
- C
A feature is removed and the sample is sent to a random child
- D
A sample is compared with the target values of every training point
Correct answer
BA feature value is compared with a threshold to choose a child branch
Explanation
At a decision point, the tree tests a feature value against a condition, such as whether it is below a threshold, and follows the corresponding branch.
- A
- 23
Why must a split procedure choose both a feature and a threshold?
- A
The feature identifies the root node, and the threshold determines the tree’s name
- B
The feature selects the training samples, and the threshold assigns the test-set accuracy
- C
The feature determines the class label, and the threshold determines how many classes exist
- D
The feature identifies what to test, and the threshold determines how its values divide the data
Correct answer
DThe feature identifies what to test, and the threshold determines how its values divide the data
Explanation
A split is defined by a feature and a comparison value. Together they determine which samples go to each child node.
- A
- 24
What separation does petal length provide in the Iris example?
- A
Setosa values are separated from the other species by a gap, while versicolor and virginica ranges overlap
- B
Virginica values are completely separated from all other species, while setosa and versicolor overlap
- C
Petal length separates versicolor from virginica but not setosa from either
- D
All three species have nonoverlapping petal-length ranges
Correct answer
ASetosa values are separated from the other species by a gap, while versicolor and virginica ranges overlap
Explanation
Setosa petal lengths are reported as 1–1.9, while versicolor is 3–5.1 and virginica is 4.5–6.9. Thus setosa can be separated by a threshold in the gap, while the latter two ranges overlap.
- A
- 25
In the illustrated split, what happens when petal length is compared with a threshold of 2.4?
- A
All 149 samples go to one child because 2.4 is outside every feature range
- B
The 50 virginica samples go to one child, and the 99 setosa and versicolor samples go to the other
- C
The 49 setosa samples go to one child, and the 100 versicolor and virginica samples go to the other
- D
The 50 versicolor samples go to one child, and the 99 setosa and virginica samples go to the other
Correct answer
CThe 49 setosa samples go to one child, and the 100 versicolor and virginica samples go to the other
Explanation
With the petal-length threshold of 2.4, all 49 setosa samples fall on one side, while the 50 versicolor and 50 virginica samples fall on the other.
- A
- 26
What Gini impurities are reported for the two children created by the petal-length threshold of 2.4?
- A
Zero for the setosa child and 0.5 for the child containing versicolor and virginica
- B
0.5 for the setosa child and zero for the child containing the other species
- C
Zero for both children because setosa is separated from the other species
- D
0.66 for the setosa child and 0.5 for the child containing the other species
Correct answer
AZero for the setosa child and 0.5 for the child containing versicolor and virginica
Explanation
The setosa child is pure and has impurity zero. The other child contains 50 versicolor and 50 virginica samples, giving impurity 1−0.52−0.52=0.5.
- A
- 27
What Gini split index is reported for the petal-length threshold of 2.4?
- A
0.5
- B
0.324
- C
0.66
- D
0.1915
Correct answer
B0.324
Explanation
Using the parent impurity and the child impurities weighted by their sample fractions gives the reported split index of 0.324.
- A
- 28
What Gini split index is reported for the example split using sepal length at 5.8?
- A
0.66
- B
0.1915
- C
0.324
- D
0.5
Correct answer
B0.1915
Explanation
The lecture reports a Gini split index of 0.1915 for the sepal-length threshold of 5.8.
- A
- 29
When comparing candidate splits, which one does the described procedure choose?
- A
The candidate that uses the feature with the widest range
- B
The candidate with the maximum Gini split index
- C
The candidate with the minimum Gini split index
- D
The candidate that sends the most samples to one child
Correct answer
BThe candidate with the maximum Gini split index
Explanation
The procedure computes the split index for each candidate and chooses the one with the maximum value, which represents the greatest impurity reduction.
- A
- 30
After a split creates one pure child and one mixed child, what is the appropriate next step in the example’s tree-building logic?
- A
Discard both children and return all samples to the root
- B
Continue splitting only the pure child because it has a known class
- C
Continue exploring the mixed child while the pure child needs no further splitting
- D
Stop immediately because any pure child makes the entire tree pure
Correct answer
CContinue exploring the mixed child while the pure child needs no further splitting
Explanation
Once setosa is isolated in a pure child, the lecture continues exploring the mixed child containing versicolor and virginica.
- A
- 31
If a terminal node contains more samples from one class than from the others, what class does the tree predict there?
- A
The class that was most frequent in the root, regardless of the node
- B
The class with the fewest samples in that node
- C
The class with the greatest number of samples in that node
- D
A class selected randomly from all possible classes
Correct answer
CThe class with the greatest number of samples in that node
Explanation
The node’s predicted class is the most represented class among the samples that reach it.
- A
- 32
How does a new Iris sample use the example tree to obtain a classification?
- A
It follows branches based on its feature values until reaching a node that predicts a species
- B
It follows branches based on its known species until reaching a feature threshold
- C
It is assigned the species with the widest training feature range
- D
It is compared with every training sample and assigned the root’s most frequent species
Correct answer
AIt follows branches based on its feature values until reaching a node that predicts a species
Explanation
A new sample is routed through the tree using its feature values; the terminal node it reaches provides the predicted species.
- A
- 33
Why might a tree builder stop splitting even when a node is not pure?
- A
A very deep tree may overfit training data, so accepting some training errors can improve generalization
- B
An impure node cannot be divided using numerical features
- C
Further splits prevent evaluation on a test dataset
- D
A mixed node always has a lower impurity than every possible child
Correct answer
AA very deep tree may overfit training data, so accepting some training errors can improve generalization
Explanation
The lecture cautions against building an excessively complex tree that memorizes training data. Stopping with some errors may support better generalization to test data.
- A
- 34
How does the lecture characterize the sensitivity of a single decision tree to data changes?
- A
It changes only when the number of target classes changes
- B
Minor data changes or errors can produce a substantially different tree
- C
Minor data changes cannot alter its thresholds or structure
- D
It is unaffected by errors because each node uses a majority class
Correct answer
BMinor data changes or errors can produce a substantially different tree
Explanation
The lecture describes decision trees as potentially not very robust: small changes or errors in data can lead to quite different trees.
- A
- 35
What is a random forest as described in the lecture?
- A
A collection of decision trees built from varied versions of the original data
- B
A regression method that replaces all features with their average
- C
A collection of class labels selected without using training examples
- D
A single decision tree whose branches are chosen randomly at prediction time
Correct answer
AA collection of decision trees built from varied versions of the original data
Explanation
A random forest combines multiple decision trees, each trained using a modified version or subset of the original data.
- A
- 36
Which approach can create varied datasets for the trees in a random forest?
- A
Replacing the training labels with predictions from the test set
- B
Subselecting data points, features, or both from the original dataset
- C
Duplicating every data point while keeping every feature unchanged
- D
Sorting the data by one feature and using the same samples for every tree
Correct answer
BSubselecting data points, features, or both from the original dataset
Explanation
The lecture describes creating different datasets by selecting portions of the data points, selecting portions of the features, or both.
- A
- 37
If ten different datasets are formed from the original data and a tree is built for each, what do the resulting trees form?
- A
A regression tree with ten target values
- B
A test set containing ten new samples
- C
A random forest of ten decision trees
- D
A single decision tree with ten root nodes
Correct answer
CA random forest of ten decision trees
Explanation
Each dataset can produce a decision tree, and the collection of those trees is a random forest.
- A
- 38
How does the described random forest produce a classification prediction?
- A
It averages the feature values from all trees and assigns the nearest class
- B
It collects the trees’ predictions and uses their majority decision
- C
It uses only the prediction from the tree with the deepest structure
- D
It chooses the prediction made by the tree trained on the largest dataset
Correct answer
BIt collects the trees’ predictions and uses their majority decision
Explanation
For classification, the forest gathers predictions from its trees and selects the class receiving the majority of votes.
- A
- 39
Three trees predict setosa, setosa, and virginica for the same sample. What does the described majority rule predict?
- A
Virginica
- B
No prediction, because not all trees agree
- C
Averaged setosa and virginica
- D
Setosa
Correct answer
DSetosa
Explanation
Setosa receives two of the three votes, so it is the majority prediction even though one tree predicts virginica.
- A
- 40
What issue arises if the trees in a classification forest each predict a different class?
- A
The forest must predict the class from the root node of the first tree
- B
There is no majority, so a tie-breaking method is needed
- C
The forest must discard every tree and retrain on the test data
- D
The forest automatically converts the votes into a regression value
Correct answer
BThere is no majority, so a tie-breaking method is needed
Explanation
If each tree votes for a different class, there is no majority decision; the lecture notes that the tie must be broken somehow.
- A
- 41
Why can combining trees trained on varied datasets make a random forest more robust than relying on one tree?
- A
Subsampling ensures that each tree has zero training error
- B
Every tree is guaranteed to make the same prediction on every new example
- C
Majority voting removes the need to evaluate predictions on test data
- D
Agreement across multiple trees can reduce dependence on fluctuations in any one dataset or tree
Correct answer
DAgreement across multiple trees can reduce dependence on fluctuations in any one dataset or tree
Explanation
Using multiple trees trained on varied data versions can reduce sensitivity to fluctuations in a particular dataset; an overwhelming consensus is presented as more reliable than relying on a single tree.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.