↓ Skip to main content

entropy

·153 words·1 min
Dave the human
Author
Dave the human
Homo sapiens in the loop

Entropy is a statistics concept used to measure disorder in a sample.
It is applied to calculate the information gain of a decision tree’s split through node impurity, and can be described with the formula:

$$ E = -\sum_{i=1}^{n} P(X) \log_2 P(X) $$

In a decision tree’s node, $P(X)$ is the number of times a given class has occurred in the node divided by the number of total examples $n$ in the node.
It is basically the probability of encountering that class in the node’s sample.

$$P(X) = count(x)/n$$

Still considering the same node sample and assuming the feature is binary, we will have the highest entropy when 50% of the examples come from one class and the other 50% comes from the other, while a node having 100% of examples coming from the same class will have $E = 0$.

Decision trees commonly use either entropy or gini index at each split.


← K-means KNN from scratch →

Comments