CodeBlanks Logo Icon CodeBlanks

Summary - Statistics

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 ddof difference.
  • 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 columns

These 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

model.py
import numpy as np

x = np.array([3, 5, 7, 9, 11])

# buraya yaz

Sample solution

model.py
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.

Question
s = X.std(____)
Answer
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

All lessons in Beginner

13 Project: Classification

  1. Preparing data
  2. Training model
  3. Prediction
  4. Evaluation