Classification and Conditional Class Probabilities
Context: FIT2086_MOC Β· the categorical-target half of supervised learning β the branch Linear Regression (FIT2086) left open Β· the W6 machinery (ML fitting, penalised likelihood) now aimed at the Bernoulli instead of the Gaussian Β· the practical answer β Logistic Regression Β· scoring the result β Classification Evaluation (Confusion Matrix and Metrics)
Quick Revision
- π― Objective: define a classifier as the conditional class probability β estimate it β predict the class that maximises it.
- π¦ Core Components: direct joint estimation β exact but cells | naive Bayes β simplifying assumption | Logistic Regression β models the conditional directly.
- β‘ Key Constraint: the curse of dimensionality β estimating the joint table needs probabilities for binary predictors, which outruns any βΉ the direct approach is unusable past a handful of predictors.
π How It Works
1. A Classifier Is a Conditional Probability
- Target β is categorical (a class); predictors are called features in the classification literature.
- What we want β β the probability an individual is in class given their feature values.
- Probabilistic vs hard classifier β a probabilistic classifier returns the whole distribution over classes; a hard classifier collapses it to one label by .
- Why probabilities and not labels β they carry confidence: and give the same label but are not the same claim β Logarithmic Loss.
2. The Direct Approach β Joint Then Conditional
- All-categorical case β the conditional is a ratio of a joint to a marginal:
- Reading it β numerator is the joint probability of class-and-features; denominator is the marginal probability of the features alone β the product/sum rules of Random Variables and Probability Distributions (FIT2086), nothing new.
- Consequence β the joint distribution is a complete classifier β once you hold it, every conditional falls out by division.
3. Estimating the Joint from Data
- We are never given the joint β the population table is unknown; only realisations are observed.
- Proportion estimator β count the pair and divide by :
- Why it works β the WLLN (Expectations and Covariance (FIT2086)) guarantees these proportions converge on the population probabilities for large enough .
- Conditional from estimates β β divide the cell by its column total.
4. Why the Direct Approach Collapses
- The count β binary and binary βΉ joint probabilities; two mutations βΉ ; binary predictors βΉ cells.
- Exponential growth in β each cell needs its own sample of observations to estimate, so the demand on doubles per predictor β this is the curse of dimensionality.
- Practical verdict β the requirement outruns the sample size no matter how big is βΉ the problem must be constrained, not estimated cell by cell.
5. The Two Escape Routes
- Naive Bayes β impose a simplifying assumption on the joint (features independent given the class) β handles categorical predictors and multi-class targets easily; popular in text mining. (Named in the lecture, not examined β self-study.)
- Logistic Regression β skip the joint entirely and model the conditional directly as an adaptation of the linear model β handles categorical and continuous predictors; awkward for multi-class.
- The unitβs choice β logistic regression, because it inherits the whole linear-model toolkit.
6. Generative vs Discriminative
- Generative model β any model of the complete joint β conditioning on gives , so it can generate synthetic individuals of a chosen class.
- Dividing by β removes the classβs own prevalence, leaving what the features look like within that class.
- Why they are topical β modern generative models exploit structural regularities in the data type to beat the exponential-growth problem rather than estimating raw cells.
- Discriminative model β models only β cheaper, cannot generate data, and is what Logistic Regression does.
π¬ Model
- Declared spaces β (binary throughout this unit), features or a finite categorical product space.
- Estimation target β the conditional , not the mean β this is the only structural change from Linear Regression (FIT2086).
- Decision rule β ; for binary this is βpredict iff β β generalised by a threshold in ROC and AUC.
- Parameter count of the direct approach β free probabilities for binary features βΉ non-viable; every practical method replaces this with parameters.
βοΈ Core Decision Matrix
| Approach | What it estimates | Parameter cost | Predictor types | Where it breaks |
|---|---|---|---|---|
| Direct joint table | full joint | cells | categorical only | curse of dimensionality past |
| Naive Bayes | joint, under an independence assumption | categorical, multi-class easy | the independence assumption is usually false | |
| Logistic Regression | conditional directly | coefficients | categorical and continuous | multi-class is awkward; boundary is linear |
When It Flips: with small, all-categorical predictors and a large , the direct table is exact and assumption-free β it beats logistic regression, which forces a linear log-odds shape. Every added predictor doubles its cost, so the crossover arrives almost immediately.
π Exam Execution Trace & Applied Exercises
Applied Exercise 1 β estimate a classifier from raw data
Problem: individuals with mutation status and heart disease . Estimate the joint table, then and .
Final Extracted Output: in this sample the non-mutation group looks more likely to have heart disease β the reverse of the population table below, because is far too small. (Slide 21 prints for the second line; β arithmetic slip, the method is right.)
Applied Exercise 2 β the same classifier from population probabilities
Problem: population joint probabilities of heart disease and LDLR mutation : , , , . Classify a mutation carrier and a non-carrier.
Final Extracted Output: carrier β predict (); non-carrier β predict (). The mutation raises risk by percentage points.
Applied Exercise 3 β odds and the predictor verdict (Studio 12 sample exam)
Problem: joint probabilities of dense breasts and breast cancer by 60 : , , , . Find , , the odds of cancer given dense breasts, and judge as a predictor.
Shortcut: the marginal cancels in the odds β straight from the joint row (W12 revision: attendance row βΉ passes per fail). Final Extracted Output: a good predictor β cancer is as likely with dense breasts; the verdict needs this comparison of the two conditionals, never one conditional alone.
β οΈ Common Mistakes
- π‘ Dividing by instead of the column total β the conditional divides the joint cell by the marginal of the conditioning variable, not by the sample size; is the joint, is the conditional.
- π‘ Calling the direct approach βwrongβ β it is exact and assumption-free; it fails only on cost (), which is a sample-size problem, not a correctness one.
- π‘ Confusing generative with βbetterβ β a generative model estimates strictly more than a classifier needs; for pure prediction the discriminative conditional is the cheaper and usually the stronger choice.
- π‘ Reading a small-sample proportion as the population value β the WLLN is asymptotic; at the estimated table can invert the true relationship entirely.
π§ Active Recall
Why does knowing the full joint distribution mean you already have every classifier you could want?
- Hint: What operation turns a joint into a conditional?
Answer
- Short answer: Because any conditional is just the joint divided by a marginal, and the marginal is itself obtained by summing the joint β so the joint contains all of it.
- Why: Sum then divide β β no extra information is ever needed.
Two binary predictors need joint probabilities. Why is that worse than it sounds when grows?
- Hint: Count, then compare against .
Answer
- Short answer: The count is β exponential in β and each cell needs its own observations, so the required doubles with every predictor added.
- Why: Curse of dimensionality β at that is million cells; no realistic populates them, so most cells get proportion and the classifier is undefined where it matters.
What does a generative model buy you that logistic regression cannot, and what do you pay for it?
Answer
- Short answer: It can synthesise new individuals from a chosen class, because it models and can therefore evaluate ; the price is estimating the whole joint.
- Why: Discriminative shortcut β is all a classifier consumes, so modelling the joint spends parameters on structure the prediction task never reads.