1. Home
  2. Explore
  3. Computer Science
  4. Decision Trees and Random Forests

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Decision Trees and Random Forests

  • 41Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Decision Tree Concepts

What is a decision tree in machine learning?

41 questions

  1. 1

    What is a decision tree in machine learning?

    1. A

      A method that combines many models by averaging their individual outputs

    2. B

      A table that stores every possible feature combination and its target value

    3. C

      A tree-like structure generated from data to make predictions or classifications

    4. D

      A process that transforms features into a single numerical score

    Correct answer
    C

    A 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.

  2. 2

    Which distinction between classification and regression matches the content?

    1. A

      Classification assigns an example to a predefined class; regression predicts a target value

    2. B

      Classification builds a tree; regression uses only a single average prediction

    3. C

      Classification selects features; regression selects the training examples to retain

    4. D

      Classification predicts a numerical target; regression assigns an example to a predefined class

    Correct answer
    A

    Classification 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.

  3. 3

    Which types of machine learning problems can decision trees address, according to the lecture?

    1. A

      Only regression problems

    2. B

      Only classification problems

    3. C

      Only problems with a categorical target and no features

    4. D

      Classification and regression problems

    Correct answer
    D

    Classification and regression problems

    Explanation

    The content describes decision trees as applicable to both classification and regression problems.

  4. 4

    What does a node in a decision tree represent during its construction?

    1. A

      A single feature value shared by every sample in the dataset

    2. B

      A fixed prediction that is independent of the data reaching it

    3. C

      A separate training dataset created by averaging other datasets

    4. D

      A collection of data points that has reached that part of the tree

    Correct answer
    D

    A 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.

  5. 5

    What data does the root node contain before any splits are made?

    1. A

      Only the data points from the largest class

    2. B

      All data points in the problem

    3. C

      A random subset containing one feature from each sample

    4. D

      Only data points that already have pure class membership

    Correct answer
    B

    All data points in the problem

    Explanation

    The root is the initial node and contains all the data points before the tree partitions them.

  6. 6

    If a classifier makes no splits and always predicts a most frequent class, what limitation does the example illustrate?

    1. A

      It will classify every training example correctly but fail only on regression data

    2. B

      It uses all features, so it is likely to overfit the training set

    3. C

      It produces pure nodes without needing to examine feature values

    4. D

      It can be correct only for examples in the predicted class, so its accuracy may be poor

    Correct answer
    D

    It 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.

  7. 7

    In a regression problem, what simple prediction might be made at an unsplit root node?

    1. A

      A random value selected from the feature ranges

    2. B

      The target value of the first training example

    3. C

      The average target value across the training data

    4. D

      The most frequent target value after converting it to a class

    Correct answer
    C

    The 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.

  8. 8

    Why might a tree that perfectly separates its training data still be undesirable?

    1. A

      It necessarily increases impurity at every child node

    2. B

      It cannot make predictions for examples with numerical features

    3. C

      It may overlearn the training data and generalize poorly to new examples

    4. D

      It prevents the use of a test set to assess performance

    Correct answer
    C

    It 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.

  9. 9

    How many Iris samples and species are used in the lecture’s example?

    1. A

      150 samples across setosa, versicolor, and virginica

    2. B

      100 samples across four different Iris species

    3. C

      149 samples across setosa, versicolor, and virginica

    4. D

      149 samples across setosa and versicolor only

    Correct answer
    C

    149 samples across setosa, versicolor, and virginica

    Explanation

    The example uses 149 preclassified samples: 49 setosa, 50 versicolor, and 50 virginica.

  10. 10

    Which set lists the four measured features in the Iris example?

    1. A

      Sepal length, stem width, petal length, and leaf width

    2. B

      Sepal length, sepal width, petal length, and petal width

    3. C

      Flower length, flower width, sepal length, and petal color

    4. D

      Sepal width, petal width, flower height, and stem length

    Correct answer
    B

    Sepal length, sepal width, petal length, and petal width

    Explanation

    The four features described are sepal length, sepal width, petal length, and petal width.

  11. 11

    What role do the preclassified Iris samples play in the example?

    1. A

      They serve only to test a tree after it has been built without training data

    2. B

      They define the feature ranges but are not used to learn classifications

    3. C

      They train a classifier to assign a species to a new flower from its features

    4. D

      They provide the final predictions without requiring a learned model

    Correct answer
    C

    They 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.

  12. 12

    Which sepal-length ranges are reported for the three Iris species?

    1. A

      Setosa: 1–1.9; versicolor: 3–5.1; virginica: 4.5–6.9

    2. B

      Setosa: 4.3–5.8; versicolor: 4.9–7; virginica: 4.9–7.9

    3. C

      Setosa: 4.9–7; versicolor: 4.3–5.8; virginica: 4.9–7.9

    4. D

      Setosa: 4.3–5.8; versicolor: 4.9–7.9; virginica: 4.9–7

    Correct answer
    B

    Setosa: 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.

  13. 13

    Why are the Iris species and their feature measurements useful for illustrating a decision tree?

    1. A

      They establish that one feature always separates all three species completely

    2. B

      They show that classifying flowers requires no labeled training examples

    3. C

      They guarantee that every possible threshold creates three perfectly pure groups

    4. D

      They show how measured features can be used to partition labeled samples and classify a new sample

    Correct answer
    D

    They 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.

  14. 14

    For a node with class fractions fif_ifi​, how is its Gini impurity defined in the lecture?

    1. A

      ∑ifi\sum_i f_i∑i​fi​

    2. B

      1−∑ifi1-\sum_i f_i1−∑i​fi​

    3. C

      1−∑ifi21-\sum_i f_i^21−∑i​fi2​

    4. D

      ∑ifi2−1\sum_i f_i^2-1∑i​fi2​−1

    Correct answer
    C

    1−∑ifi21-\sum_i f_i^21−∑i​fi2​

    Explanation

    Gini impurity is calculated as 1−∑ifi21-\sum_i f_i^21−∑i​fi2​, where each fif_ifi​ is the fraction of node samples belonging to class iii.

  15. 15

    At the Iris root node, what fraction corresponds to setosa?

    1. A

      50/14950/14950/149

    2. B

      1/31/31/3

    3. C

      49/14949/14949/149

    4. D

      49/5049/5049/50

    Correct answer
    C

    49/14949/14949/149

    Explanation

    The root contains 49 setosa samples among 149 total samples, so the setosa fraction is 49/14949/14949/149.

  16. 16

    What is the Gini impurity of a node containing samples from only one class?

    1. A

      The fraction of samples in the largest class

    2. B

      One

    3. C

      The number of samples in the node

    4. D

      Zero

    Correct answer
    D

    Zero

    Explanation

    A pure node has one class fraction equal to 1 and all other class fractions equal to 0. Substituting these into 1−∑ifi21-\sum_i f_i^21−∑i​fi2​ gives zero.

  17. 17

    What does a nonzero Gini impurity indicate about a node?

    1. A

      The node contains no samples from the training dataset

    2. B

      The node predicts a numerical target instead of a class

    3. C

      The node contains a mixture of classes rather than only one class

    4. D

      The node has already been split into its maximum possible number of children

    Correct answer
    C

    The 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.

  18. 18

    Which impurity measure is associated with classification problems in the lecture?

    1. A

      Gini impurity or information entropy

    2. B

      Feature-range overlap only

    3. C

      Mean target value only

    4. D

      Variance reduction only

    Correct answer
    A

    Gini impurity or information entropy

    Explanation

    The lecture identifies Gini impurity and information entropy as measures typically used for classification trees.

  19. 19

    Which measure is identified for building regression trees?

    1. A

      Majority-class frequency

    2. B

      Information entropy only

    3. C

      Gini impurity only

    4. D

      Variance reduction

    Correct answer
    D

    Variance reduction

    Explanation

    Variance reduction is identified as a metric used when modeling regression problems.

  20. 20

    How is a candidate Gini split index calculated for two child nodes?

    1. A

      The larger child impurity minus the smaller child impurity

    2. B

      Parent impurity plus the unweighted sum of the two child impurities

    3. C

      The average of the two child impurities divided by the parent impurity

    4. D

      Parent impurity minus each child impurity weighted by that child’s fraction of the data

    Correct answer
    D

    Parent 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.

  21. 21

    Why does a larger Gini split index indicate a preferable split in the lecture’s procedure?

    1. A

      It means the weighted impurity of the children is lower relative to the parent

    2. B

      It means the parent node was already pure before splitting

    3. C

      It means the children contain more samples than the parent

    4. D

      It means the split used fewer features than every alternative

    Correct answer
    A

    It 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.

  22. 22

    What feature-based operation is performed at a decision point in a tree?

    1. A

      All feature values are averaged to create a new class label

    2. B

      A feature value is compared with a threshold to choose a child branch

    3. C

      A feature is removed and the sample is sent to a random child

    4. D

      A sample is compared with the target values of every training point

    Correct answer
    B

    A 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.

  23. 23

    Why must a split procedure choose both a feature and a threshold?

    1. A

      The feature identifies the root node, and the threshold determines the tree’s name

    2. B

      The feature selects the training samples, and the threshold assigns the test-set accuracy

    3. C

      The feature determines the class label, and the threshold determines how many classes exist

    4. D

      The feature identifies what to test, and the threshold determines how its values divide the data

    Correct answer
    D

    The 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.

  24. 24

    What separation does petal length provide in the Iris example?

    1. A

      Setosa values are separated from the other species by a gap, while versicolor and virginica ranges overlap

    2. B

      Virginica values are completely separated from all other species, while setosa and versicolor overlap

    3. C

      Petal length separates versicolor from virginica but not setosa from either

    4. D

      All three species have nonoverlapping petal-length ranges

    Correct answer
    A

    Setosa 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.

  25. 25

    In the illustrated split, what happens when petal length is compared with a threshold of 2.4?

    1. A

      All 149 samples go to one child because 2.4 is outside every feature range

    2. B

      The 50 virginica samples go to one child, and the 99 setosa and versicolor samples go to the other

    3. C

      The 49 setosa samples go to one child, and the 100 versicolor and virginica samples go to the other

    4. D

      The 50 versicolor samples go to one child, and the 99 setosa and virginica samples go to the other

    Correct answer
    C

    The 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.

  26. 26

    What Gini impurities are reported for the two children created by the petal-length threshold of 2.4?

    1. A

      Zero for the setosa child and 0.5 for the child containing versicolor and virginica

    2. B

      0.5 for the setosa child and zero for the child containing the other species

    3. C

      Zero for both children because setosa is separated from the other species

    4. D

      0.66 for the setosa child and 0.5 for the child containing the other species

    Correct answer
    A

    Zero 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.51-0.5^2-0.5^2=0.51−0.52−0.52=0.5.

  27. 27

    What Gini split index is reported for the petal-length threshold of 2.4?

    1. A

      0.5

    2. B

      0.324

    3. C

      0.66

    4. D

      0.1915

    Correct answer
    B

    0.324

    Explanation

    Using the parent impurity and the child impurities weighted by their sample fractions gives the reported split index of 0.324.

  28. 28

    What Gini split index is reported for the example split using sepal length at 5.8?

    1. A

      0.66

    2. B

      0.1915

    3. C

      0.324

    4. D

      0.5

    Correct answer
    B

    0.1915

    Explanation

    The lecture reports a Gini split index of 0.1915 for the sepal-length threshold of 5.8.

  29. 29

    When comparing candidate splits, which one does the described procedure choose?

    1. A

      The candidate that uses the feature with the widest range

    2. B

      The candidate with the maximum Gini split index

    3. C

      The candidate with the minimum Gini split index

    4. D

      The candidate that sends the most samples to one child

    Correct answer
    B

    The 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.

  30. 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?

    1. A

      Discard both children and return all samples to the root

    2. B

      Continue splitting only the pure child because it has a known class

    3. C

      Continue exploring the mixed child while the pure child needs no further splitting

    4. D

      Stop immediately because any pure child makes the entire tree pure

    Correct answer
    C

    Continue 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.

  31. 31

    If a terminal node contains more samples from one class than from the others, what class does the tree predict there?

    1. A

      The class that was most frequent in the root, regardless of the node

    2. B

      The class with the fewest samples in that node

    3. C

      The class with the greatest number of samples in that node

    4. D

      A class selected randomly from all possible classes

    Correct answer
    C

    The 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.

  32. 32

    How does a new Iris sample use the example tree to obtain a classification?

    1. A

      It follows branches based on its feature values until reaching a node that predicts a species

    2. B

      It follows branches based on its known species until reaching a feature threshold

    3. C

      It is assigned the species with the widest training feature range

    4. D

      It is compared with every training sample and assigned the root’s most frequent species

    Correct answer
    A

    It 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.

  33. 33

    Why might a tree builder stop splitting even when a node is not pure?

    1. A

      A very deep tree may overfit training data, so accepting some training errors can improve generalization

    2. B

      An impure node cannot be divided using numerical features

    3. C

      Further splits prevent evaluation on a test dataset

    4. D

      A mixed node always has a lower impurity than every possible child

    Correct answer
    A

    A 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.

  34. 34

    How does the lecture characterize the sensitivity of a single decision tree to data changes?

    1. A

      It changes only when the number of target classes changes

    2. B

      Minor data changes or errors can produce a substantially different tree

    3. C

      Minor data changes cannot alter its thresholds or structure

    4. D

      It is unaffected by errors because each node uses a majority class

    Correct answer
    B

    Minor 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.

  35. 35

    What is a random forest as described in the lecture?

    1. A

      A collection of decision trees built from varied versions of the original data

    2. B

      A regression method that replaces all features with their average

    3. C

      A collection of class labels selected without using training examples

    4. D

      A single decision tree whose branches are chosen randomly at prediction time

    Correct answer
    A

    A 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.

  36. 36

    Which approach can create varied datasets for the trees in a random forest?

    1. A

      Replacing the training labels with predictions from the test set

    2. B

      Subselecting data points, features, or both from the original dataset

    3. C

      Duplicating every data point while keeping every feature unchanged

    4. D

      Sorting the data by one feature and using the same samples for every tree

    Correct answer
    B

    Subselecting 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.

  37. 37

    If ten different datasets are formed from the original data and a tree is built for each, what do the resulting trees form?

    1. A

      A regression tree with ten target values

    2. B

      A test set containing ten new samples

    3. C

      A random forest of ten decision trees

    4. D

      A single decision tree with ten root nodes

    Correct answer
    C

    A random forest of ten decision trees

    Explanation

    Each dataset can produce a decision tree, and the collection of those trees is a random forest.

  38. 38

    How does the described random forest produce a classification prediction?

    1. A

      It averages the feature values from all trees and assigns the nearest class

    2. B

      It collects the trees’ predictions and uses their majority decision

    3. C

      It uses only the prediction from the tree with the deepest structure

    4. D

      It chooses the prediction made by the tree trained on the largest dataset

    Correct answer
    B

    It 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.

  39. 39

    Three trees predict setosa, setosa, and virginica for the same sample. What does the described majority rule predict?

    1. A

      Virginica

    2. B

      No prediction, because not all trees agree

    3. C

      Averaged setosa and virginica

    4. D

      Setosa

    Correct answer
    D

    Setosa

    Explanation

    Setosa receives two of the three votes, so it is the majority prediction even though one tree predicts virginica.

  40. 40

    What issue arises if the trees in a classification forest each predict a different class?

    1. A

      The forest must predict the class from the root node of the first tree

    2. B

      There is no majority, so a tie-breaking method is needed

    3. C

      The forest must discard every tree and retrain on the test data

    4. D

      The forest automatically converts the votes into a regression value

    Correct answer
    B

    There 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.

  41. 41

    Why can combining trees trained on varied datasets make a random forest more robust than relying on one tree?

    1. A

      Subsampling ensures that each tree has zero training error

    2. B

      Every tree is guaranteed to make the same prediction on every new example

    3. C

      Majority voting removes the need to evaluate predictions on test data

    4. D

      Agreement across multiple trees can reduce dependence on fluctuations in any one dataset or tree

    Correct answer
    D

    Agreement 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.

Question 1 of 41
Question 1 of 41

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent