By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Probability basics are the mathematical foundation for reasoning about uncertainty in data‑driven problems. They let you turn raw observations into likelihoods, compute expected outcomes, and combine evidence with Bayes’ theorem. In a data‑science pipeline you’ll use them to (1) pick the right statistical model, (2) evaluate risk (e.g., “Will this customer churn?”), and (3) calibrate predictions from classifiers or recommender systems. Example: A telecom company estimates the probability a subscriber will churn next month by blending historic churn rates (prior) with recent usage spikes (likelihood) via Bayes’ rule, then uses the posterior to target retention offers.
Bayes’ Theorem – (\displaystyle P(A|B)=\frac{P(B|A)\,P(A)}{P(B)}) (P(A|B)): posterior, (P(B|A)): likelihood, (P(A)): prior, (P(B)): evidence.
Probability Mass Function (PMF) – For discrete (X): (\displaystyle p_X(x)=P(X=x)). Sums to 1.
Probability Density Function (PDF) – For continuous (X): (\displaystyle f_X(x)) with (\displaystyle \int_{-\infty}^{\infty} f_X(x)dx = 1).
Cumulative Distribution Function (CDF) – (\displaystyle F_X(x)=P(X\le x)=\int_{-\infty}^{x} f_X(t)dt).
Expectation (Mean) – (\displaystyle \mathbb{E}[X]=\sum_x x\,p_X(x)) (discrete) or (\displaystyle \int_{-\infty}^{\infty} x\,f_X(x)dx) (continuous).
Variance – (\displaystyle \operatorname{Var}(X)=\mathbb{E}[(X-\mu)^2]=\mathbb{E}[X^2]-\mu^2), where (\mu=\mathbb{E}[X]).
Standard Deviation – (\sigma=\sqrt{\operatorname{Var}(X)}); measures spread in the same units as (X).
Law of Total Probability – (\displaystyle P(B)=\sum_i P(B|A_i)P(A_i)) for a partition ({A_i}).
Conditional Independence – (X\perp Y \mid Z) ⇔ (P(X,Y|Z)=P(X|Z)P(Y|Z)). Crucial for Naïve Bayes.
Maximum Likelihood Estimation (MLE) – (\displaystyle \hat\theta_{\text{MLE}}=\arg\max_\theta \prod_{i=1}^n f(x_i|\theta)). Gives the parameter values that make the observed data most probable.
Conjugate Prior – A prior distribution that yields a posterior of the same family (e.g., Beta prior → Beta posterior for Bernoulli likelihood).
df = pd.read_csv('churn.csv')
df['churn'].value_counts(normalize=True)
p_prior = df['churn'].mean()
scipy.stats.norm.fit(df['monthly_minutes'])
x_new
python from scipy.stats import norm prior = p_prior likelihood = norm.pdf(x_new['monthly_minutes'], *params) # PDF value evidence = np.mean(likelihood) # approximated by averaging over training set posterior = likelihood * prior / evidence
train_test_split
sklearn.calibration.calibration_curve
Mistake: Treating a PDF value as a probability. Correction: PDFs can exceed 1; they must be integrated over an interval to yield a probability.
Mistake: Using the sample mean as the prior without accounting for class imbalance. Correction: Either re‑balance (SMOTE, class weighting) or explicitly set a prior that reflects business risk (e.g., higher churn cost).
Mistake: Assuming independence when features are correlated (Naïve Bayes). Correction: Verify independence with correlation matrices; if strong dependence exists, consider Tree‑augmented Naïve Bayes or a different model.
Mistake: Forgetting the evidence term (P(B)) and normalizing posteriors manually. Correction: Always compute the denominator (or use a library that does it) to keep posterior probabilities summing to 1.
Mistake: Ignoring variance when comparing two distributions (e.g., saying “means are equal → same performance”). Correction: Use t‑test or Welch’s test that incorporate variance, or compare confidence intervals.
Scenario: Your churn model outputs a posterior of 0.85 for a high‑value customer. Answer: The customer has an 85 % chance to churn; you would prioritize a retention offer.
Scenario: You fit a Gaussian to monthly minutes, but the data are heavily right‑skewed. Answer: The Gaussian assumption is violated; consider a log‑transform or a Gamma distribution instead.
Scenario: After applying Naïve Bayes, the validation AUC is 0.55, yet the training AUC is 0.99. Answer: The model is over‑fitting due to strong independence assumptions; try a more flexible classifier or add feature engineering.
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.