Formulas & Examples

All key formulas with worked examples

Listen to Formula Explanations

Two hosts walk through each formula with step-by-step examples

Mean (Average)
\[ \bar{x} = \frac{\sum_{i=1}^{n} x_i}{n} \]
Sum of all values divided by count
Example

Q: Find mean of: 10, 20, 30, 40, 50

A: Mean = (10+20+30+40+50)/5 = 150/5 = 30

Variance
\[ \sigma^2 = \frac{\sum_{i=1}^{n}(x_i - \bar{x})^2}{n} \]
Average of squared differences from mean
Example

Q: Find variance of: 2, 4, 6 (mean=4)

A: Variance = [(2-4)² + (4-4)² + (6-4)²]/3 = [4+0+4]/3 = 8/3 = 2.67

Standard Deviation
\[ \sigma = \sqrt{\sigma^2} \]
Square root of variance
Example

Q: If variance = 16, find standard deviation

A: σ = √16 = 4

Accuracy
\[ Accuracy = \frac{TP + TN}{TP + TN + FP + FN} \]
Proportion of correct predictions
Example

Q: TP=80, TN=90, FP=10, FN=20. Find accuracy.

A: Accuracy = (80+90)/(80+90+10+20) = 170/200 = 0.85 = 85%

Precision
\[ Precision = \frac{TP}{TP + FP} \]
Of positive predictions, how many correct?
Example

Q: TP=80, FP=20. Find precision.

A: Precision = 80/(80+20) = 80/100 = 0.80 = 80%

Recall (Sensitivity)
\[ Recall = \frac{TP}{TP + FN} \]
Of actual positives, how many found?
Example

Q: TP=80, FN=20. Find recall.

A: Recall = 80/(80+20) = 80/100 = 0.80 = 80%

F1 Score
\[ F1 = 2 \times \frac{Precision \times Recall}{Precision + Recall} \]
Harmonic mean of precision and recall
Example

Q: Precision=0.8, Recall=0.6. Find F1.

A: F1 = 2×(0.8×0.6)/(0.8+0.6) = 2×0.48/1.4 = 0.96/1.4 = 0.686

Specificity
\[ Specificity = \frac{TN}{TN + FP} \]
Of actual negatives, how many correctly identified?
Example

Q: TN=90, FP=10. Find specificity.

A: Specificity = 90/(90+10) = 90/100 = 0.90 = 90%

StandardScaler
\[ x_{scaled} = \frac{x - \mu}{\sigma} \]
Transform to mean=0, std=1
Example

Q: x=70, mean=50, std=10. Standardize x.

A: x_scaled = (70-50)/10 = 20/10 = 2.0

MinMaxScaler
\[ x_{scaled} = \frac{x - x_{min}}{x_{max} - x_{min}} \]
Transform to range [0, 1]
Example

Q: x=30, min=10, max=50. Scale x.

A: x_scaled = (30-10)/(50-10) = 20/40 = 0.5

Pearson Correlation
\[ \rho = \frac{cov(X,Y)}{\sigma_X \cdot \sigma_Y} \]
Linear relationship strength (-1 to +1)
Example

Q: cov(X,Y)=15, σ_X=5, σ_Y=3. Find correlation.

A: ρ = 15/(5×3) = 15/15 = 1.0 (perfect positive)

← Definitions Practice →