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

  • 58Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Tree Fundamentals
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is a decision tree in machine learning?

Tap to flipClick to flipspace

A tree-like structure generated from data that makes predictions by applying decisions at nodes until it reaches an output.

Or swipe the card

58 cards

  1. What is a decision tree in machine learning?

    A tree-like structure generated from data that makes predictions by applying decisions at nodes until it reaches an output.

  2. Which kinds of machine-learning problems can decision trees address?

    Classification and regression, including prediction or function-approximation tasks.

  3. What is a classification problem?

    Given data, assign it to one of a predefined set of classes.

  4. What is a regression problem?

    Given data, predict a target or output value.

  5. What does each node in a decision tree represent?

    A collection of data points. The root node contains all training data, and child nodes contain subsets created by splits.

  6. What happens at a decision-tree split?

    A feature value is tested against a condition or threshold, directing each data point to one of the child nodes.

  7. What is a leaf node in a decision tree?

    A terminal node where the tree produces its final classification or regression prediction.

  8. How does a decision tree classify a new data point?

    Start at the root, apply each node's feature test to choose a branch, and use the prediction at the leaf reached.

  9. How is a classification label commonly chosen at a tree node?

    Use the class represented by the largest number of data points at that node.

  10. What would a simple regression prediction at an unsplit root node be?

    The average target value among the training data points in that node.

  11. Why might a tree-growing algorithm offer different split metrics?

    Different metrics provide different procedures for choosing how to form the tree; software packages may offer them as options.

  12. Which metrics are commonly associated with classification trees, and which with regression trees?

    Gini impurity and information entropy are commonly used for classification; variance reduction is used for regression.

  13. What is Gini impurity?

    A measure of how mixed the classes are within a node. For class fractions fif_ifi​, it is G=1−∑i=1Kfi2G=1-\sum_{i=1}^{K} f_i^2G=1−∑i=1K​fi2​.

  14. In the Gini impurity formula, what does fif_ifi​ represent?

    The fraction of data points in the node that belong to class iii.

  15. What does a Gini impurity of zero indicate?

    The node is pure: all its data points belong to a single class.

  16. Why does a pure node have Gini impurity zero?

    Its class fractions are one for the represented class and zero for all others, so 1−∑ifi2=01-\sum_i f_i^2=01−∑i​fi2​=0.

  17. What does a higher Gini impurity generally indicate?

    The node's data points are more mixed across classes.

  18. How is Gini impurity calculated for the Iris root node with 49 setosa, 50 versicolor, and 50 virginica samples?

    Use 1−(49/149)2−(50/149)2−(50/149)21-(49/149)^2-(50/149)^2-(50/149)^21−(49/149)2−(50/149)2−(50/149)2, which is approximately 0.6670.6670.667 (about 0.660.660.66).

  19. What class fractions and Gini impurity does a node containing 50 versicolor samples and no other classes have?

    Its fractions are (1,0,0)(1,0,0)(1,0,0), so its Gini impurity is zero.

  20. What is the main goal of using Gini impurity while growing a classification tree?

    Reduce impurity through successive splits so that the resulting nodes are as pure as possible.

  21. What is the Gini split index?

    The parent node's Gini impurity minus the child nodes' Gini impurities weighted by their proportions of the data.

  22. How are the child-node weights in a Gini split calculated?

    Each weight is the fraction of the parent node's data points sent to that child: pj=nj/np_j=n_j/npj​=nj​/n.

  23. Why is a larger Gini split index preferred?

    It indicates a greater reduction in weighted impurity, meaning the children are closer to pure.

  24. What would the Gini split index be if a split produced two pure children?

    It would equal the parent impurity, because both weighted child impurities are zero.

  25. How does a tree-growing algorithm choose among candidate splits?

    It can evaluate candidate feature-and-threshold choices, calculate each split index, and select the one with the largest Gini split index.

  26. What two elements define a threshold-based decision-tree split?

    A selected feature and a threshold value used to divide its values.

  27. How does a split using threshold aaa divide data based on a feature?

    One child receives points with feature values below aaa; the other receives points with values greater than or equal to aaa.

  28. What does p1p_1p1​ represent when computing the Gini split index?

    The fraction of the parent node's data points assigned to the first child.

  29. What does p2p_2p2​ represent when computing the Gini split index?

    The fraction of the parent node's data points assigned to the second child.

  30. How can candidate feature thresholds be selected in a decision tree?

    An algorithm can enumerate possible splits or use a heuristic to find promising feature-and-threshold choices.

  31. Why are split thresholds and feature choices usually automated?

    There are many possible combinations, and tree-building algorithms search for effective splits.

  32. What happens to data as a decision tree grows?

    Each split partitions the data into smaller subsets, which can be split again at later nodes.

  33. Does a decision tree have to reuse the same feature at every split?

    No. It can choose from the available features at each node, and a feature may be selected again.

  34. What is a key trade-off when deciding how deeply to grow a tree?

    Deeper trees can fit training data more closely, but overly complex trees may overlearn the training set and generalize poorly.

  35. Why might a tree be stopped before every training point is classified perfectly?

    Accepting some training errors can avoid an excessively deep, overfit tree and improve generalization to new data.

  36. What are the three Iris species used in the classification example?

    Setosa, versicolor, and virginica.

  37. Which four features describe each Iris sample in the example?

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

  38. How many Iris samples of each species are used in the example?

    49 setosa, 50 versicolor, and 50 virginica, for 149 samples total.

  39. What are the stated sepal-length ranges for the three Iris species?

    Setosa: 4.3–5.8; versicolor: 4.9–7.0; virginica: 4.9–7.9.

  40. What petal-length ranges are given for setosa, versicolor, and virginica?

    Setosa: 1.0–1.9; versicolor: 3.0–5.1; virginica: 4.5–6.9.

  41. What would the root-node majority-class prediction be for the Iris data, and what is its limitation?

    Versicolor or virginica, with a tie broken arbitrarily. Predicting one class for every sample would get only 50 of 149 training samples correct.

  42. How can petal length at a threshold of 2.4 separate the Iris training samples?

    Samples with petal length below 2.4 are setosa; samples above the threshold are versicolor or virginica.

  43. What are the child-node sizes and impurities after the Iris petal-length split at 2.4?

    The split creates a pure setosa node with 49 samples and Gini impurity 000, and a 100-sample node with 50 versicolor and 50 virginica samples and impurity 0.50.50.5.

  44. What is the Gini split index for the Iris petal-length split at 2.4?

    Approximately 0.3240.3240.324: parent impurity minus (49/149)×0(49/149)\times 0(49/149)×0 and (100/149)×0.5(100/149)\times 0.5(100/149)×0.5.

  45. Why can petal length distinguish setosa from the other Iris species more cleanly than versicolor from virginica?

    The stated setosa petal-length range ends at 1.9, while the other ranges start at 3.0 or higher; versicolor and virginica ranges overlap.

  46. What happens when the Iris example next splits the 100 non-setosa samples using petal width at 1.8?

    The samples are divided into groups of about 54 and 46; the first group is labeled versicolor and the second virginica by their respective majorities.

  47. How might a tree classify a new Iris sample using the example splits?

    If petal length is below 2.4, predict setosa. Otherwise, check petal width: below 1.8 predicts versicolor, and above 1.8 predicts virginica.

  48. How should the accuracy of an Iris decision tree be checked on unseen samples?

    Apply the tree to test data and compare its predicted labels with the correct labels.

  49. Why might a decision tree misclassify a sample even after splitting?

    A leaf can still contain samples from multiple classes, so its majority-class prediction will be wrong for some samples.

  50. What is a random forest?

    An ensemble of multiple decision trees whose predictions are combined.

  51. What problem with individual decision trees motivates random forests?

    A single tree can be sensitive to small changes or errors in the data, producing a substantially different tree.

  52. How can random forests create different training sets from the original data?

    They can use different subsets of data points, different subsets of features, or both.

  53. How are the trees in a random forest constructed?

    Build a decision tree for each modified or subsampled version of the original data.

  54. How does a random forest usually make a classification prediction?

    Collect the predictions from its trees and return the class receiving the majority of votes.

  55. If two random-forest trees predict setosa and one predicts virginica, what is the forest's prediction?

    Setosa, because it receives the majority of votes.

  56. What can be done if random-forest trees split their votes evenly among classes?

    The tie must be broken using some decision rule.

  57. How does using multiple trees help make a random forest more robust?

    The forest combines predictions from trees built on varied data or feature subsets, reducing dependence on any single tree's result.

  58. How do the roles of a decision tree and a random forest differ?

    A decision tree predicts using one tree; a random forest combines predictions from a collection of trees, typically by majority vote for classification.

Card 1 of 58
Card 1 of 58

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent