EXERCISE
1The data type is your compass โ it points you toward the right analysis technique and away from meaningless results.
Save
Choosing the wrong technique for your data type is like using a thermometer to measure weight โ the tool works fine, it is just measuring the wrong thing.
Matching data type โ technique:
| Data Type | Good Techniques | Bad Techniques |
|---|---|---|
| Numerical | Mean, std dev, | Mode (sometimes ok) |
| Categorical | Mode, frequency count, chi-square | Mean, median (meaningless) |
| Ordinal | Median, mode, rank correlation | Mean (gaps are not equal) |
# CORRECT: Mean on numerical data
speeds = [99, 86, 87, 88, 111, 86, 103]
print(sum(speeds) / len(speeds))
# Output: 94.29
# CORRECT: Mode on categorical data
colours = ["red", "blue", "red", "green", "red"]
from collections import Counter
most_common = Counter(colours).most_common(1)
print(most_common)
# Output: [('red', 3)]
# WRONG: Mean on ordinal data
# Grades A=4, B=3, C=2: average is 3.0 = "B"
# But the gaps between grades are NOT necessarily equal
# So "B" as an average is misleading
> ๐ก Key Insight: In real-world ML projects, you will often need to convert between types. Turning categorical data into numbers (encoding) is one of the most critical preprocessing steps. You will see this when we reach decision trees later in this course.