Machine Learning Basics

A node of a decision tree holds 6 data points of class A and 4 of class B. What is the Gini impurity of this node?

  1. A0.24
  2. B0.40
  3. C0.48
Show answer and explanation

Answer: C. 0.48

Gini impurity is computed as 1 − Σp², where p is the proportion of each class. Class A has a proportion of 0.6 and class B 0.4, so the impurity is 1 − (0.36 + 0.16) = 0.48. A node with only one class has an impurity of 0, and with two classes the maximum, 0.5, occurs when they are half and half. A decision tree splits the data by choosing the feature and threshold that minimize the weighted average impurity (Gini impurity or entropy) of the child nodes after the split.

  • A. This is 0.6 × 0.4 = 0.24, the two-class Gini impurity 2 × 0.6 × 0.4 without the factor of 2.
  • B. This is the proportion of the minority class, the error rate when classifying by majority vote.
  • C. Correct. 1 − (0.6² + 0.4²) = 0.48.
Practice this topic Back to topic

Related calculators

Books on Machine Learning Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Machine Learning Basics questions

  1. Which of the following correctly describes the difference between bagging (random forests and the like) and boosting in ensemble learning?
  2. The class of the 2D point (0, 0) is predicted with k-nearest neighbors. The training data consists of red points (1, 0), (3, 0) and (0, −3) and blue points (0, 2) and (−2, 1). Using Euclidean distance, which pair of predictions for k = 3 and k = 5 is correct?
  3. Which of the following describes a support vector machine (SVM)?
  4. 20% of all emails are spam. A certain word appears in 50% of spam emails and in 5% of non-spam emails. Which is closest to the probability that an email containing this word is spam?
  5. Which logic function cannot be represented by a simple perceptron consisting only of input and output layers (a single neuron that outputs 0 or 1 with a threshold)?