Summary - Statistics
- Machine Learning course
- Beginner
- Lesson 30/112
- 6 min
In this group you learned mean, median, standard deviation, and correlation.
Summary: statistics
In this group you learned to summarise data with numbers:
- Centre: mean (sensitive to outliers), median (robust), mode (categorical).
- Spread: variance and standard deviation; the
ddofdifference. - Relationship: correlation; linear only, not causation.
- Per-feature computation with
axis=0.
print(X.mean(axis=0), X.std(axis=0))
print(np.corrcoef(X, rowvar=False)) # correlation matrix between columnsThese measures form the basis of scaling and feature selection in the next groups.
Practice Quick summary
Print the mean, median and standard deviation of x in a single print, separated by spaces.
Starter code
import numpy as np
x = np.array([3, 5, 7, 9, 11])
# buraya yazSample solution
import numpy as np
x = np.array([3, 5, 7, 9, 11])
print(x.mean(), np.median(x), x.std())Expected output
7.0 7.0 2.8284271247461903
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which best describes the typical salary in a skewed salary distribution?
- The median Correct answer
- The mean
- The variance
- The maximum
Explanation: A few very high salaries pull the mean up; the median isn't affected.
2 Compute the standard deviation of each column.
s = X.std(____)
s = X.std(axis=0)
Explanation: axis=0 gives one value per feature.
3 Match the concepts.
| Term | Meaning |
|---|---|
center |
Mean, median |
spread |
Variance, std |
relationship |
Correlation |
robust |
Median |