Data Mining Exercise 6
Data Preprocessing & Decision Tree - Sampling and Entropy calculation for Node selection
Warning
This article is a work in progress and may contain incomplete information or inaccuracies. Please verify details from reliable sources.
Data Mining Exercise 6
The foundation of Data Preprocessing (Sampling) and Decision Tree Model (Entropy calculation for Node selection).
Question 3: Difference between 2 sampling methods (Stratified vs. Simple Random)
Problem
Want to sample from a population with subgroups.
- Method 1: Stratified Sampling (proportional selection)
- Method 2: Simple Random Sampling (random pool, ignoring groups)
Difference
The core lies in "probability of getting representatives from all groups" and "Precision".
1. Representation Guarantee
Method 1 (Stratified):
- 100% guarantee to get data from all groups according to their real proportions.
- This method is excellent if our data is Imbalanced (e.g. contains very rare groups).
📌 Example: University Opinion Poll
There are 9,000 students and 100 professors.
If sampling via Stratified, we force a quota that professors must be included.
Method 2 (Simple Random):
- Relies on luck. If any group is very small, there's a high chance we "won't sample them at all".
- Causing that group's data to be missing (Under-represented).
Example: Simple Random Problem
From the university case, if randomly pooled, we might only get students and no professors, causing a skewed poll result.
2. Standard Error
| Sampling Method | Error Value | Reason | |------
---|----------|--------| | Stratified | Lower | Guarantees population structure. The obtained data is better distributed. | | Simple Random | Higher | Especially if each group is highly diverse. |
Conclusion
✅ Recommendation
If you know the data is already divided into groups and want each group to be represented, you must use Stratified.
(This is also the Standard for splitting Train/Test sets in Classification tasks).
Question 4: Entropy Calculation (Uncertainty value)
Data
Total 8 balls:
- 🔴 Red: 4 balls
- 🟢 Green: 2 balls
- 🔵 Blue: 2 balls
Entropy Formula:
Calculation Steps
1. Find the probability () of each color
2. Substitute values into the formula
We must calculate term by term and sum them up (don't forget the minus sign at the front):
3. Convert Log values (base 2):
4. Calculate numbers
Answer
✅ Result
The Entropy value is 1.5 bits.
Data Mining Connection Trivia
What is the maximum possible value (Max Entropy) for this problem?
If 3 ball colors have exactly equal amounts (equal occurrence probability), the highest Entropy value would be bits.
💡 Result Interpretation
Our calculated value of 1.5, which is almost the Max, means this dataset "has high uncertainty" (hard to guess what color will be drawn, even though Red is the most abundant).
Connection with Decision Tree
In Decision Tree:
- We like Nodes with low Entropy (e.g. all Red = Entropy 0).
- Because it means the data is Pure.
- The purer it is, the more accurate the prediction!