Menu

Statistics and Descriptive Statistics

Statistics and Descriptive Statistics

3.1 What Is Statistics?

Statistics is the study of collecting, organizing, analyzing, and interpreting data.

AI systems depend on data, and statistics helps developers understand its characteristics before training a model.

For example, before building a model to predict employee salaries, you might examine the average salary, the spread of salaries, and whether unusual values exist in the dataset.

3.2 Mean, Median, and Mode

These measures describe different aspects of a dataset.

Mean: The arithmetic average of all values.

[
\text{Mean} = \frac{\text{Sum of values}}{\text{Number of values}}
]

Median: The middle value after sorting the observations. For an even number of observations, it is the average of the two middle values.

Mode: The most frequently occurring value.

Consider this dataset:

[
[10, 20, 20, 30, 70]
]

  • Mean = 30
  • Median = 20
  • Mode = 20

The mean is affected by unusually large or small values, while the median is often more robust to extreme observations.

3.3 Calculating Statistics in Python

You can use Python's built-in statistics module.

import statistics
scores = [10, 20, 20, 30, 70]
print("Mean:", statistics.mean(scores))
print("Median:", statistics.median(scores))
print("Mode:", statistics.mode(scores))

Output:

Mean: 30

Median: 20

Mode: 20

3.4 Understanding Variance and Standard Deviation

The mean describes the center of a dataset, but it does not explain how widely the values are spread.

Variance measures the average squared deviation from the mean. Standard deviation is the square root of variance and expresses spread in the original units.

Consider two datasets:

  • Dataset A: [48, 49, 50, 51, 52]
  • Dataset B: [10, 30, 50, 70, 90]

Both have a mean of 50, but Dataset B has much greater variation.

Python example:

import statistics
data_a = [48, 49, 50, 51, 52]
data_b = [10, 30, 50, 70, 90]
print(statistics.pstdev(data_a))
print(statistics.pstdev(data_b))

Output:

1.4142135623730951

28.284271247461902

The function pstdev() calculates the population standard deviation. If the observations are a sample used to estimate a larger population, statistics.stdev() calculates the sample standard deviation instead.

3.5 Why Statistics Matters in AI

Statistics helps with:

  • Identifying missing or unusual data.
  • Understanding distributions and relationships.
  • Comparing model performance.
  • Evaluating uncertainty and prediction errors.
  • Detecting potential data quality issues.

A model trained on unrepresentative or poor-quality data may produce unreliable predictions, even when its algorithm is implemented correctly.


Artificial Intelligence Tutorial

VA

Vishalini A



Learn via Video Course

Artificial Intelligence and Machine Learning Course Logo

Artificial Intelligence and Machine Learning Course

55 hrs



Get in Touch For Details