Vol. I  ·  Est. 2025  ·  Portfolio

The Study Guide



Predicting Student Dropout at Enrollment  ·  From Zero to Mastery

How to use this guide

46 short concept cards in ten parts, in the order you need them. Each card opens with the idea in one line, then builds intuition, then shows exactly how our study used it.

  • Foundations no background needed
  • Core the methods you must be able to explain
  • Mastery the subtle points that impress

Open Check yourself only after you've tried to answer. Press Mark as understood when a card clicks; your progress is saved in this browser.

Your progress

0 of 46 understood

Part I

The Problem

What we are predicting, from what, and when. Get this part solid and every later choice makes sense.

01
Foundations

The whole study in one breath

In one line: we asked how well you can predict, on the day a student enrolls, whether they will graduate, drop out, or still be enrolled years later, and we tested that honestly.

Read this card first and come back to it at the end. Everything else in the guide explains one piece of it.

  1. Data: 4,424 students from a Portuguese polytechnic, 36 predictors, three possible outcomes.
  2. When: predict at enrollment (A), after semester 1 (B) and after semester 2 (C).
  3. How: five classifiers, optional feature reduction, all inside one leak-proof pipeline.
  4. Judged by: macro-F1, using nested cross-validation and a t-test corrected for overlapping folds.
  5. Then: which features matter, whether errors fall evenly on groups, and how much depends on variables of unknown timing.
QuestionAnswer
RQ1 · How early?≈ 0.57 macro-F1 at enrollment. Semester 1 adds ≈ +0.10, semester 2 only ≈ +0.03–0.04.
RQ2 · Which model?LR, RF and SVM are statistically indistinguishable. Tuning only helps naive Bayes.
RQ3 · What matters?Feature reduction never helps. Tuition status, scholarship, course and age drive enrollment predictions.
RQ4 · Can we trust it?Errors are uneven across groups, and removing five fuzzy-timing variables drops the score to ≈ 0.52.
Say it in class

"At enrollment you can only build a coarse screen, about 0.57 macro-F1. The model you pick barely matters; when you predict matters a lot."

02
Foundations

Educational data mining and early warning

In one line: educational data mining (EDM) applies data mining to school records, and an early-warning system uses it to flag students who might need support.

Intuition

An advisor can only reach out to students they know to look for. A model that flags likely dropouts early gives the advisor time to act. The earlier the flag, the more useful it is, but the less information the model has.

The tension that drives the whole paper

Accuracy and usefulness pull in opposite directions. Grades make predictions much better, but grades only exist after a semester, when some students are already struggling or gone. Most published models get their high accuracy from those grades.

Check yourself

Q. Why not just report the after-semester-2 model, since it scores best?

A. By then many at-risk students have already struggled for a year. The point of early warning is acting early, so the enrollment-time score is the honest measure of what is possible when it matters most.

03
Foundations

The dataset

In one line: the UCI "Predict Students' Dropout and Academic Success" dataset: 4,424 students, 36 predictors, three outcomes.

  • Source: Polytechnic Institute of Portalegre, Portugal, 17 undergraduate programs, students enrolled 2008/09 to 2018/19. Released by Realinho et al. (2022).
  • What is in a row: demographics (age, gender, nationality), socioeconomic info (parents' education and jobs, scholarship, debtor, tuition status), enrollment info (course, application mode, admission grade), first-year grades, and three national economic rates (unemployment, inflation, GDP).
  • Quality: no missing values, no duplicates. Four pairs of numeric features correlate strongly (0.84 to 0.94); each pair is the same metric in semester 1 and semester 2.
  • Privacy: anonymized, GDPR-checked, licensed CC BY 4.0.
Check yourself

Q. Why does it matter that the data comes from one school?

A. Patterns can be specific to that school's programs, policies and student body. Results may not transfer elsewhere without retraining and checking (see card 43).

04
Foundations

Three classes, and what "Enrolled" means

In one line: each student is labeled Graduate, Dropout or Enrolled, measured at the end of the normal program length.

  • Graduate (2,209; 49.9%): finished on time.
  • Dropout (1,421; 32.1%): left. In this dataset that includes switching field or institution, so rates look higher than "left higher education entirely."
  • Enrolled (794; 17.9%): still studying when the clock ran out (3 years, or 4 for Nursing).

Why Enrolled is so hard

"Enrolled" is not a final outcome. It is a snapshot of someone whose story is unfinished; statisticians call this right-censoring. Some of these students will graduate late and some will leave. At enrollment, they look like a blend of the other two groups, so no model separates them cleanly.

Check yourself

Q. Why not just drop Enrolled like the earlier study?

A. Real schools cannot delete their in-between students. A deployed model has to say something about everyone, so the three-class task is the realistic one.

05
Foundations

Class imbalance

In one line: the classes are different sizes (2.8 : 1 largest to smallest), so a lazy model can look good by ignoring the small class.

The ratio is 2,209 Graduates to 794 Enrolled ≈ 2.8. A model that predicts "Graduate" for everyone is right about half the time, which is why accuracy is a misleading score here.

Two families of fixes exist: change the loss (class weights, card 15) or change the data (oversampling, card 36). We used class weights by default and tested the alternatives.

Check yourself

Q. What does "2.8 : 1" mean exactly?

A. The majority class (Graduate, 2,209) has about 2.8 times as many students as the minority class (Enrolled, 794).

06
Foundations

Variable types

In one line: every column is stored as a number, but the numbers mean different things, so each type needs different handling.

TypeMeaningExampleCount
NominalCodes for categories; order means nothingCourse 9147, parent's occupation9
BinaryYes / noScholarship holder8
OrdinalOrdered categoriesApplication order (1st choice, 2nd…)1
NumericReal quantities and countsAdmission grade, age, units approved18

Why this matters

If you feed "course = 9147" to logistic regression as a number, it assumes course 9147 is "more" than course 33, which is nonsense. Nominal codes must be one-hot encoded (card 9).

07
Foundations

Prediction time: Scenarios A, B, C

In one line: we built the same task three times, using only what would be known at each moment.

ScenarioWhenRaw variablesColumns after encoding
AAt enrollment24107
BAfter semester 130113
CAfter semester 236119

The scenarios are nested: B is A plus six semester-1 variables, C is B plus six semester-2 variables. Comparing them tells you the price of predicting early.

Check yourself

Q. Why is the jump from A to B (≈ +0.10) so much bigger than B to C (≈ +0.03)?

A. Semester 1 is the first real evidence of how a student copes. Semester 2 mostly repeats that evidence (the semester-1 and semester-2 metrics correlate 0.84 to 0.94), so it adds little new information.

08
Core

Data leakage

In one line: leakage is when a model sees information during training that it would not have when used for real, which makes scores look better than they are.

Two kinds, both relevant here

  • Train/test contamination: anything learned from data (scaling means, selected features, PCA directions) is fit on the whole dataset before splitting, so the test set has helped build the model that is tested on it.
  • Temporal leakage: a feature records something that happens after the prediction moment. If "tuition not up to date" is recorded a week before a student withdraws, it is partly a symptom of dropping out, not a predictor.
Say it in class

"Everything that learns from data is refit inside each training fold. The test fold is only ever transformed and scored."

Check yourself

Q. Is z-scoring all 4,424 students before cross-validation really a problem? It is just a mean and standard deviation.

A. It is a small leak, but a leak: test students shift the mean and SD the model was trained with. With feature selection or PCA the leak gets much larger, because the test fold then helps choose features. The safe habit is to make every fitted step part of the pipeline.

Part II

Turning Records into Numbers

Models need numeric inputs on comparable scales. These three steps get the data there without cheating.

09
Foundations

One-hot encoding

In one line: replace a category code with one 0/1 column per category, so the model never treats codes as amounts.

"Course" with 17 values becomes 17 columns: course_9147 is 1 for students in that course and 0 for everyone else.

Pooling rare levels

Categories seen fewer than 20 times in a training fold are merged into one "infrequent" column. A column with 3 students in it gives the model almost nothing reliable to learn, and it can memorize those 3 people.

The side effect that matters later

One variable becomes many weak columns. That is why "top 15 columns" feature selection throws away useful information (card 31), and why per-column Gini importance has to be summed back to the variable (card 32).

Check yourself

Q. Why is "fewer than 20" counted inside each training fold, not on the whole dataset?

A. Counting on the whole dataset would use test-fold students to decide the encoding: a tiny leak. Doing it in-fold keeps the test fold unseen.

10
Foundations

Standardization (z-scores)

In one line: rescale each numeric feature to mean 0 and standard deviation 1, so no feature dominates just because of its units.

z=x−μσz = \frac{x - \mu}{\sigma}

Admission grades run roughly 95 to 190; "units approved" run 0 to about 20. Without scaling, distance-based models (SVM) and penalized ones (logistic regression with L2) would treat grade differences as far more important just because the numbers are bigger.

Trees (random forests) do not care about scale, since they only ask "is x above a threshold?" Scaling still does no harm, so one pipeline serves all models.

11
Core

Pipelines

In one line: a pipeline chains every preprocessing step and the model into one object, so it all gets fit on training data and applied to test data together.

Encode→Scale→Oversample?→Reduce?→Classify

In scikit-learn, calling pipeline.fit(train) fits each step in order on training data. pipeline.predict(test) only applies the fitted steps. This makes leakage structurally hard to commit.

Say it in class

"One scikit-learn pipeline, refit inside every fold, so no step ever sees the test students."

Part III

The Models

Two baselines that set the floor, and three primary models that each draw the boundary between classes in a different way.

12
Foundations

Zero-R: the floor

In one line: Zero-R ignores every feature and always predicts the most common class.

Here that means predicting "Graduate" for all 4,424 students. It is not a serious model. It is the score you get for free, so any real model has to beat it by a clear margin to be worth anything.

13
Core

Gaussian naive Bayes

In one line: pick the class that makes the student's features most likely, assuming each feature is an independent bell curve within each class.

How it works

Bayes' rule, with the "naive" assumption that features are independent once you know the class:

P(c∣x)  ∝  P(c)∏jN ⁣(xj; μcj, σcj2)P(c \mid x) \;\propto\; P(c)\prod_{j} \mathcal{N}\!\left(x_j;\ \mu_{cj},\ \sigma^2_{cj}\right)

For each class it learns a mean and variance per feature, then multiplies the bell-curve heights together.

Why it struggled here

One-hot columns are 0/1, not bell-shaped. For a rare category, the variance inside a class can be almost zero, so the bell curve becomes a spike. One spike multiplied in can swamp everything else, and the model becomes wildly overconfident.

var_smoothing fixes this by adding a small amount (a fraction of the largest feature variance) to every variance, widening the spikes.

Check yourself

Q. Why is NB called a "baseline" if tuning makes it decent?

A. It is fast, simple and makes a strong, usually wrong, independence assumption. It shows what a cheap probabilistic model achieves, which tells us how much the primary models add.

14
Core

Logistic regression

In one line: give each class a weighted sum of the features, turn the three sums into probabilities, and predict the largest.

How it works

Each class cc gets a score wc⋅x+bcw_c \cdot x + b_c. The softmax function turns the scores into probabilities that add to 1:

P(c∣x)=ewc⋅x+bc∑kewk⋅x+bkP(c \mid x) = \frac{e^{w_c \cdot x + b_c}}{\sum_{k} e^{w_k \cdot x + b_k}}

Training finds the weights that make the true labels as probable as possible (minimizing cross-entropy loss). The L2 penalty discourages large weights, which prevents overfitting. C is the inverse of the penalty strength: small C means strong regularization and simpler weights.

Its boundaries between classes are straight lines (hyperplanes) in feature space, which is why it is called a linear model. The lbfgs solver is just the optimization algorithm that finds the weights.

Check yourself

Q. If LR is linear and RF is nonlinear, why do they tie?

A. Most enrollment signal sits in a few strong, simple indicators (tuition, scholarship, age, course). A straight boundary captures nearly all of it, so the extra flexibility of RF has little left to find.

15
Core

Balanced class weights

In one line: make mistakes on rare classes cost more during training, so the model cannot ignore them.

scikit-learn's class_weight="balanced" sets each class's weight to:

wc=nsamplesnclasses⋅ncw_c = \frac{n_{\text{samples}}}{n_{\text{classes}} \cdot n_c}
ClassCountWeight
Graduate2,2094424 / (3 × 2209) ≈ 0.67
Dropout1,421≈ 1.04
Enrolled794≈ 1.86

Getting one Enrolled student wrong now costs about as much as getting almost three Graduates wrong.

16
Core

Decision trees and Gini impurity

In one line: a tree asks yes/no questions about one feature at a time, choosing each question to make the groups it creates as pure as possible.

Gini impurity

Purity is measured by Gini impurity: the chance that two students drawn at random from a node have different labels.

G=1−∑cpc 2G = 1 - \sum_{c} p_c^{\,2}

Worked example: a node that is 50% Graduate, 30% Dropout, 20% Enrolled has G=1−(0.25+0.09+0.04)=0.62G = 1 - (0.25 + 0.09 + 0.04) = 0.62. A node with only Dropouts has G=0G = 0.

At each node the tree tries every feature and threshold and keeps the split with the biggest drop in impurity. It keeps splitting until it hits a limit (maximum depth, or a minimum number of students per leaf).

Key property

Every split is axis-aligned: one feature, one threshold. Remember this for card 30, where it explains why PCA hurt random forests.

17
Core

Random forests

In one line: grow hundreds of deliberately different trees and average their votes; the errors cancel out and the average is far more stable than any one tree.

Two sources of randomness

  1. Bootstrap rows: each tree trains on a random sample of students drawn with replacement (about 63% unique students).
  2. Random features: at each split, a tree may only choose among a random subset of features (√p by default).

Single deep trees overfit: they memorize noise. Because the trees here are trained on different data and features, they make different mistakes, and averaging cancels much of it out. More trees reduce variance and do not cause overfitting, which is why we held the count fixed at 300 rather than tuning it.

Check yourself

Q. Why not tune the number of trees?

A. Adding trees only lowers variance; past a few hundred the score plateaus. It is not a knob that trades off fit, so tuning it wastes compute.

18
Core

Support vector machines (RBF)

In one line: an SVM draws the boundary with the widest possible gap between classes; the RBF kernel lets that boundary curve smoothly.

Margin and C

Among all boundaries that separate the classes, the SVM picks the one farthest from the nearest points (the "support vectors"). Real data overlaps, so a soft margin allows some violations. C sets the price of a violation: large C fits the training data tightly, small C keeps the margin wide and smooth.

The kernel trick

Instead of drawing a straight line in the original space, the SVM measures similarity between students with a kernel. The RBF (Gaussian) kernel is:

K(x,x′)=exp⁡ ⁣(−γ ∥x−x′∥2)K(x, x') = \exp\!\left(-\gamma \,\lVert x - x' \rVert^2\right)

Students close together count as very similar. γ sets how quickly similarity fades with distance: large γ gives wiggly, local boundaries; small γ gives smooth ones. gamma="scale" picks γ = 1 / (number of features × feature variance) automatically.

scikit-learn handles three classes by training one SVM for every pair of classes (one-vs-one) and letting them vote.

Check yourself

Q. Why must features be scaled for an SVM but not for a random forest?

A. The RBF kernel uses distances. An unscaled feature with large numbers would dominate the distance. Trees only compare a feature with a threshold, so scale never enters.

19
Core

Hyperparameters and tuning grids

In one line: hyperparameters are settings you choose before training (C, depth, γ…), as opposed to parameters the model learns (weights, splits).

A grid search tries every combination in a list and keeps the best by validation score. The danger is that the "best" setting partly reflects luck on the validation data; that is why the search must happen inside training data only (card 24).

ModelGrid
NBvar_smoothing ∈ 1e-9, 1e-6, 1e-3, 1e-2, 0.1, 0.3, 1
LRC ∈ 0.01, 0.1, 1, 10
RFmax_depth ∈ None, 10, 20 · min_samples_leaf ∈ 1, 5 · max_features ∈ √p, 0.3
SVMC ∈ 0.1, 1, 10 · γ ∈ scale, 0.01, 0.1
Selectorsnone · RFFI k ∈ 5, 10, 15, 20, 25 · PCA ∈ 85%, 90%, 95%, 99%
Part IV

Measuring Performance

How we turn predictions into a score, and how we make sure that score is not flattering us.

20
Foundations

The confusion matrix

In one line: a table of actual class (rows) against predicted class (columns); every metric is computed from it.

With three classes it is a 3 × 3 grid. The diagonal holds correct predictions; everything off the diagonal is a specific kind of mistake. Row-normalizing (dividing each row by its total) turns each row into "of the students who really were X, what share did the model call each class?" The diagonal then shows each class's recall.

RF at enrollment, actual ↓ predicted →DropoutEnrolledGraduate
Dropout0.64≈ 0.120.24
Enrolled0.250.340.41

The Graduate row is in Fig. 2 of the paper. The Dropout → Enrolled cell is what is left of the row.

21
Foundations

Precision, recall and F1

In one line: recall asks "of the real dropouts, how many did we catch?"; precision asks "of the students we flagged, how many really dropped out?"; F1 balances the two.

Precisionc=TPcTPc+FPcRecallc=TPcTPc+FNc\text{Precision}_c = \frac{TP_c}{TP_c + FP_c} \qquad \text{Recall}_c = \frac{TP_c}{TP_c + FN_c}F1c=2 PcRcPc+RcF1_c = \frac{2\,P_c R_c}{P_c + R_c}

F1 is the harmonic mean, which punishes imbalance: precision 1.0 with recall 0.1 gives F1 ≈ 0.18, not 0.55. You only get a high F1 if both are decent.

Which one matters for early warning?

Missing a real dropout (low recall) means a student who needed help gets none. A false alarm (low precision) costs an advisor's time and, if mishandled, can stigmatize a student. That is why the paper reports dropout recall and false-flag rate separately in the fairness audit.

Check yourself

Q. A model flags every student as a dropout. What are its dropout recall and precision?

A. Recall is 1.0 (it catches everyone). Precision equals the dropout base rate, 0.32. F1 ≈ 0.49 for that class, and the other two classes get F1 = 0.

22
Core

Macro-F1

In one line: compute F1 for each class separately and take the plain average, so every class counts equally no matter its size.

macro-F1=13(F1Dropout+F1Enrolled+F1Graduate)\text{macro-F1} = \frac{1}{3}\left(F1_{\text{Dropout}} + F1_{\text{Enrolled}} + F1_{\text{Graduate}}\right)

Worked example: where Zero-R's 0.222 comes from

  1. Zero-R predicts Graduate for all 4,424 students.
  2. Graduate recall = 1.0 (it catches every graduate). Graduate precision = 2,209 / 4,424 = 0.499.
  3. Graduate F1 = 2 × 0.499 × 1.0 / (0.499 + 1.0) = 0.666.
  4. Dropout and Enrolled are never predicted, so their F1 = 0.
  5. Macro-F1 = (0.666 + 0 + 0) / 3 = 0.222. Its accuracy would be 0.499, which looks far less alarming.

Neighbours you should be able to name

  • Accuracy: share of all predictions that are right. Dominated by the big class.
  • Weighted F1: average of class F1s weighted by class size. Also dominated by the big class.
  • Balanced accuracy: average of per-class recall. Fair to small classes, but ignores precision.
Say it in class

"Macro-F1 averages the three classes equally, so the small Enrolled class matters as much as Graduate. Accuracy would reward ignoring it."

23
Core

Cross-validation

In one line: split the data into k parts, train on k − 1 and test on the remaining one, rotate through all parts, and average the scores.

  • k-fold: with k = 5 every student is tested exactly once, by a model that never saw them. Each test fold is about 885 students and each training set about 3,539.
  • Stratified: every fold keeps the same Graduate / Dropout / Enrolled mix as the full data. Without it, a fold could get unusually few Enrolled students by chance.
  • Repeated: reshuffle and do it again. Two repeats of 5-fold give 10 scores per model, which makes the average steadier.
Naming trap. The paper writes "5 × 2 repeated stratified CV," meaning 5 folds repeated 2 times (10 scores). That is not Dietterich's famous "5×2cv" test, which is 2-fold repeated 5 times. If a classmate mixes them up, you can clarify.
24
Mastery

Nested cross-validation

In one line: tuning gets its own cross-validation inside each training set, so the test fold is never used to pick settings.

The problem it solves

If you try 20 settings and report the best test score, part of that "best" is luck on those test students. The score is optimistically biased, sometimes heavily (Cawley & Talbot, 2010).

How it works

  1. Outer loop (10 folds): hold out a test fold.
  2. Inner loop (3 folds, inside the outer training set only): score every grid setting and pick the best.
  3. Refit that setting on the whole outer training set and score it once on the outer test fold.
  4. The 10 outer scores estimate how well "tune, then train" performs on unseen students.

Note what is being estimated: not one fixed model, but the whole procedure, including tuning. Different folds may even pick different settings.

Check yourself

Q. The tuned and fixed scores for LR, RF and SVM are almost identical. Was nested CV a waste?

A. No. You only know tuning does not matter because you measured it honestly. It also rescued NB (+0.24), and it guarantees our reported numbers carry no tuning optimism.

Part V

Is a Difference Real?

Two models score 0.570 and 0.579. Is that a real gap or noise? This part is where the paper is strongest.

25
Core

The paired t-test

In one line: compare two models fold by fold, then ask whether the average difference is big relative to how much it bounces around.

For each fold jj, take the difference dj=scoreA−scoreBd_j = \text{score}_A - \text{score}_B. With JJ folds, mean dˉ\bar d and variance sd2s_d^2:

t=dˉsd2/J,df=J−1t = \frac{\bar d}{\sqrt{s_d^2 / J}}, \qquad df = J - 1

A large |t| means the difference is consistent; the p-value says how surprising a t that large would be if the models were truly equal.

The hidden assumption

This formula assumes the 10 differences are independent. They are not: any two training sets in 5-fold CV share most of their students, so the fold scores move together. The formula then underestimates the true variance, and t comes out too big. The result is too many false "significant" findings.

26
Mastery

The corrected resampled t-test

In one line: Nadeau and Bengio's correction inflates the variance to account for overlapping training sets, which makes the test honest.

t=dˉ(1J+ntentr)sd2t = \frac{\bar d}{\sqrt{\left(\frac{1}{J} + \frac{n_{te}}{n_{tr}}\right) s_d^2}}

The only change is the extra nte/ntrn_{te}/n_{tr} term. With 5 folds, test/train = 1/4, and J = 10:

  • Naive multiplier: 1/J=0.101/J = 0.10
  • Corrected multiplier: 0.10+0.25=0.350.10 + 0.25 = 0.35, so the variance is 3.5 times larger
  • t shrinks by 3.5≈1.87\sqrt{3.5} \approx 1.87

Try it: the paper's LR vs RF result at Scenario C

Naivep = 0.029
Corrected t1.39
Correctedp = 0.20

J = 10 folds, df = 9, two-sided. A naive t of about 2.6 reproduces the paper's p = 0.029 → 0.20.

Say it in class

"Cross-validation folds share training data, so ordinary t-tests are overconfident. With the Nadeau–Bengio correction, a 'significant' p of 0.029 becomes 0.20."

27
Mastery

Multiple comparisons and Holm

In one line: if you run many tests, some will be "significant" by luck; Holm's method raises the bar so the chance of any false alarm in the family stays at 5%.

Why it is needed

At α = 0.05, each test has a 5% false-alarm chance. Run 20 tests on equal models and you expect about one false "discovery." The probability of at least one false alarm is called the family-wise error rate.

Holm's step-down procedure

  1. Sort the m p-values from smallest to largest.
  2. Compare the smallest to α / m, the next to α / (m − 1), and so on.
  3. Stop at the first one that fails; it and everything after it are not significant.

Example, m = 3, α = 0.05, p = 0.01, 0.03, 0.04: 0.01 < 0.0167 passes; 0.03 > 0.025 fails, so stop. Only the first is significant, even though all three are under 0.05.

Holm rejects everything plain Bonferroni (which compares every p to α / m) would reject, and sometimes more, with the same guarantee.

28
Mastery

"Not different" is not "the same"

In one line: failing to find a difference is not proof that none exists; it means any difference is too small for our data to detect.

That is why the paper says LR, RF and SVM are "equivalent within our uncertainty, not proven identical." The confidence interval is the better guide: LR − RF at B is −0.011 with interval [−0.036, +0.013]. The interval includes zero, and it also rules out a gap bigger than about 0.04 in either direction.

Beyond the paper: formally proving "the same" requires an equivalence test such as TOST (two one-sided tests), where you first declare a margin, say ±0.02, that you consider meaningless. We did not run one, so we make the weaker, correct claim.

Check yourself

Q. Someone says "so RF and LR are equally good." How do you refine that?

A. "We found no significant difference, and the confidence interval rules out large gaps. That supports treating them as practically interchangeable on macro-F1, though their error patterns differ (card 20)."

Part VI

Shrinking the Feature Space

Fewer features can mean simpler, faster, more robust models. Here it never helped, and the reason is instructive.

29
Core

Feature selection: RFFI and RFE

In one line: keep only the k columns a model considers most important, either in one pass (RFFI) or by repeatedly dropping the weakest (RFE).

  • RFFI (random forest feature importance): fit a 200-tree forest, rank columns by Gini importance, keep the top k. Fixed k = 15; tuned k ∈ 5, 10, 15, 20, 25.
  • RFE (recursive feature elimination): fit a 100-tree forest, drop the 10 weakest columns, refit, repeat until 15 remain. Rankings get recomputed as features leave, which can catch features that only look useful alongside others. It is far more expensive, so it was not tuned.

Both work on encoded columns, so "15" means 15 columns, not 15 variables. A single variable like course occupies many columns, and RFFI inherits Gini's preference for continuous and binary columns over split-up category dummies.

30
Core

Principal component analysis

In one line: rotate the data onto new axes ordered by how much variance they capture, then keep only the first few axes.

Intuition

Picture a cloud of points shaped like a tilted cigar. The first principal component points along the cigar's length, where the spread is largest. The second is perpendicular to it, and so on. If most of the spread lives in a few directions, you can drop the rest and lose little variance.

How it works

On standardized data, the components are the eigenvectors of the covariance matrix, and each eigenvalue is the variance along its component. You keep enough components to reach a target share of total variance.

Two catches

  • Unsupervised: PCA never looks at the labels. High variance does not mean predictive, so a small but crucial direction can be thrown away.
  • It mixes features: each component is a blend of all original columns. That breaks the clean "tuition = unpaid" splits that trees rely on (card 16).
Check yourself

Q. Why would PCA hurt RF but not LR?

A. LR already works with weighted blends of features, so a rotation changes little for it. RF splits on one feature at a time; after PCA, the single strong indicators are smeared across many components, so no clean split exists.

31
Mastery

Why reduction did not help

In one line: there was not much redundancy to remove, and one-hot encoding spreads the useful signal thinly across many columns.

  1. Moderate redundancy: the only strongly duplicated features are the semester-1 / semester-2 pairs. At enrollment, there is little overlap to compress.
  2. Thin columns: course and application mode are informative as whole variables, but each dummy column is weak alone. Selecting the top 15 columns cuts off useful levels.
  3. Few strong signals: the important information is already concentrated in a handful of indicators the models find without help.
Say it in class

"No tested reduction significantly beat using every feature. That does not prove a bigger subset is worse; it shows these methods could not shrink the space for free."

Part VII

Explaining the Model

Which variables drive the predictions? Three methods, and why two of them agree while the third misleads.

32
Core

Gini importance and its bias

In one line: a forest's built-in importance adds up how much each feature reduced impurity across all its splits; it is quick but biased.

Also called mean decrease in impurity (MDI). It is computed on training data, during fitting.

The bias (Strobl et al., 2007)

A feature with many possible split points, such as a continuous value or a category with many levels, gets many more chances to find a split that reduces impurity by chance. Because it is measured on training data, those lucky splits count as importance.

33
Core

Permutation importance

In one line: shuffle one variable among the held-out students and see how much the score drops; a big drop means the model relied on it.

Shuffling keeps the variable's distribution but breaks its link to the outcome. Because it is measured on held-out data with the real metric (macro-F1 here), it reflects what the model actually uses to generalize, not what it memorized.

Caveat

With correlated features, the model can lean on a partner when one is shuffled, so both can look less important than they really are as a pair.

34
Mastery

SHAP and TreeSHAP

In one line: SHAP splits each individual prediction into fair contributions from every feature, using a rule from game theory.

Intuition

Treat the features as players in a team game whose payout is the prediction. A feature's Shapley value is its average marginal contribution: how much the prediction changes when it joins, averaged over every possible order in which the features could join.

ϕj=∑S⊆F∖{j}∣S∣! (∣F∣−∣S∣−1)!∣F∣![f(S∪{j})−f(S)]\phi_j = \sum_{S \subseteq F \setminus \{j\}} \frac{|S|!\,(|F|-|S|-1)!}{|F|!}\Big[f(S \cup \{j\}) - f(S)\Big]

The property that justifies our method

Local accuracy: the contributions add up exactly to the prediction.

f(x)=ϕ0+∑jϕjf(x) = \phi_0 + \sum_j \phi_j

Because the values are additive, summing the SHAP values of one variable's one-hot columns gives an exact contribution for the whole variable.

TreeSHAP computes exact Shapley values for tree models quickly, using the tree structure instead of trying every coalition. "Path-dependent" means it handles absent features using how many training samples went down each branch.

Global importance is the mean absolute SHAP value across students; the sign tells you direction (raises or lowers P(Dropout)).

Say it in class

"SHAP explains what the model does, not what causes dropout, and it splits credit among correlated features."

35
Core

Comparing rankings: Spearman ρ

In one line: Spearman's ρ is the correlation between two rankings: 1 means identical order, 0 means unrelated.

Rank the variables by each method, then compute the ordinary correlation of the ranks. With no ties:

ρ=1−6∑di2n(n2−1)\rho = 1 - \frac{6\sum d_i^2}{n(n^2-1)}

where did_i is the difference between a variable's two ranks.

Part VIII

Handling Imbalance

Change the loss, or change the data? We tested both.

36
Mastery

ROS, SMOTE and calibration

In one line: oversampling adds minority examples to the training data; it did not beat simply weighting the classes, and it can distort probabilities.

  • ROS (random oversampling): duplicate minority students until classes balance.
  • SMOTE: create synthetic students on the line between a minority student and one of its k = 5 nearest same-class neighbors:xnew=xi+λ (xnn−xi),λ∼U(0,1)x_{new} = x_i + \lambda\,(x_{nn} - x_i), \quad \lambda \sim U(0,1)
  • SMOTE-NC: a variant that copies category values instead of interpolating them.

The one-hot problem

Standard SMOTE interpolates 0/1 dummy columns too, creating students who are "0.37 enrolled in Nursing." These are impossible records.

Calibration

A model is calibrated if, among students given a 30% dropout probability, about 30% actually drop out. Rebalancing (by weights or resampling) pushes probabilities toward the minority class. van den Goorbergh et al. (2022) show this often harms calibration without improving discrimination.

Check yourself

Q. Why must oversampling happen inside the training folds only?

A. If you oversample before splitting, copies or near-copies of a student can land in both training and test folds. The model then gets tested on students it has effectively seen, which inflates the score.

Part IX

Fairness and Validity

A good average can hide who gets hurt, and a good score can hide a feature recorded too late. This part checks both.

37
Core

Subgroup error audits

In one line: compute the error rates separately for each group of students, because one overall score can hide very different experiences.

Two rates per group, both about dropout:

  • Dropout recall (true positive rate): of the students in this group who really dropped out, what share did we flag? Low recall means missed alerts.
  • False-flag rate (false positive rate): of the students in this group who did not drop out, what share did we flag anyway? High means false alarms.

Groups audited: gender, scholarship, displaced (living away from home), international, and age bands.

38
Mastery

Equal opportunity and equalized odds

In one line: named fairness criteria (Hardt et al., 2016) that turn "treat groups alike" into something you can measure.

  • Equal opportunity: equal recall (true positive rate) across groups. Every student who will drop out has the same chance of being caught, whatever their group.
  • Equalized odds: equal recall and equal false-flag rate across groups.

So a recall gap is an equal-opportunity violation, and recall plus false-flag gaps together are an equalized-odds violation. That is exactly how the paper frames its audit.

Beyond the paper: when groups have different base rates, no imperfect classifier can satisfy every fairness definition at once (Kleinberg et al.; Chouldechova). Choosing a definition is a value judgement about which errors matter most, which is why we report rates rather than declaring the model "fair."

39
Mastery

Base-rate exaggeration

In one line: the model pushes each group's predicted dropout rate further from the middle than reality: low-risk groups look even safer, high-risk groups look even riskier.

GroupActual dropout ratePredictedDirection
Scholarship holders12.2%5.8%under
Age ≤ 2021.2%12.5%under
Male45.0%49.8%over
Age ≥ 2655.9%74.7%over

Why it happens

With little individual information at enrollment, the model leans on group-level features. "Has a scholarship" is a strong signal of graduating, so scholarship holders who do drop out are missed: recall 0.28, against 0.68 for non-holders. "Age 26+" signals risk, so 57% of older students who stay are falsely flagged.

Say it in class

"At enrollment the model exaggerates group base rates. Real grades shrink the gaps, which is another reason to update predictions after semester 1."

40
Core

Bootstrap confidence intervals

In one line: resample the students with replacement thousands of times, recompute the rate each time, and read the uncertainty off the spread.

  1. From a group of n students, draw n at random with replacement (some appear twice, some not at all).
  2. Compute the metric (say, recall) on that resample.
  3. Repeat B = 2,000 times.
  4. The 2.5th and 97.5th percentiles of the 2,000 values form the 95% percentile interval.

For a gap between two groups, each group is resampled independently and the difference recomputed each time. If the interval excludes 0, the gap is significant.

41
Mastery

Fairness through unawareness

In one line: deleting a protected attribute like gender usually does not remove bias, because other features carry the same information.

Course choice, age, application mode and parents' jobs can all correlate with gender. The model can reconstruct much of what you removed from these proxies; this is called redundant encoding. Yu et al. (2021) found that including or removing protected attributes barely changed accuracy or fairness in a study of 93,457 students.

42
Mastery

Timing sensitivity and A-strict

In one line: five "enrollment" variables have no documented collection date, so we re-ran Scenario A without them to get a strict lower bound.

  • Finance flags (2): debtor, tuition fees up to date. Unpaid tuition might be recorded just before a student withdraws (reverse timing), making it partly a symptom.
  • Macro rates (3): unemployment, inflation, GDP. They take exactly 10 distinct combinations across 11 years, so they identify the enrollment cohort, not anything about the student. Cohort dropout rates range from 24% to 38%.
Change in macro-F1−macro (21 vars)−finance (22)A-strict (19)
LR−0.004−0.035−0.044
RF−0.024−0.044−0.061
SVM−0.012−0.045−0.052
Say it in class

"We report two enrollment numbers: 0.57 with all features, and about 0.52 if you only trust variables we know exist on day one."

43
Mastery

Cohorts and generalization

In one line: random folds mix every year together, so they cannot tell you how the model would do on next year's students, let alone another school's.

If the model learns quirks of particular cohorts (a policy change, an economic shock), random folds will test it on students from the same cohorts and reward those quirks. Leave-one-cohort-out validation trains on 9 inferred cohorts and tests on the 10th, simulating "deploy on a year we have never seen."

Transferring to another school (MSU, say)

  • Travels: the pipeline, the evaluation protocol, the corrected tests, the subgroup audit.
  • Does not travel automatically: the fitted model, the local course and application codes, and the outcome definition ("dropout" includes transfers here).
  • To reuse it: match the outcome definition, confirm which fields exist at enrollment, retrain, and re-run the subgroup audit before anyone acts on a flag.
Part X

Defend It

The numbers to remember, the questions you are likely to get, and the words to know.

44
Core

Numbers cheat sheet

In one line: the dozen numbers worth memorizing; everything else you can derive or look up.

Students · predictors · classes4,424 · 36 · 3
Graduate / Dropout / Enrolled49.9% / 32.1% / 17.9%
Imbalance ratio2.8 : 1
Zero-R macro-F10.222
Enrollment macro-F1 (LR / RF / SVM)0.570 / 0.579 / 0.575
After sem 1 / sem 2 (RF)0.684 / 0.719
Gain from semester 1 / semester 2≈ +0.10 / ≈ +0.03–0.04
Strict enrollment baseline≈ 0.52–0.53
NB fixed → tuned (A)0.273 → 0.518
Naive vs corrected p (LR vs RF, C)0.029 vs 0.20
Spearman ρ SHAP–permutation0.84
Unpaid vs paid tuition dropout86.6% vs 24.7%
Scholarship recall vs non-holders0.28 vs 0.68
Age 26+ non-dropouts falsely flagged57%
Compute≈ 15 min fixed, ≈ 75 min nested (≈ 29,000 fits)
45
Mastery

Tough questions, good answers

In one line: short, honest answers to what a sharp classmate or instructor is likely to ask.

Why is 0.57 good if it is barely above a coin flip?
Macro-F1 is not accuracy, and three classes make chance much lower: the free baseline is 0.222. 0.57 is a large gain over that, but we call it a coarse screen, not a verdict.
Why not deep learning or XGBoost?
Tabular data, 4,424 rows, and a linear model already ties the nonlinear ones. Signal, not model capacity, is the bottleneck at enrollment. Boosting is a reasonable future comparison.
Why macro-F1 and not AUC?
All three classes matter operationally and the data is imbalanced; macro-F1 weights them equally on the actual decisions. AUC measures ranking, and multiclass AUC needs extra choices to define.
Isn't tuition status just leakage?
Possibly, which is why we ran A-strict. Without the finance flags, the score drops to ≈ 0.52, and we report both numbers.
Why 5 folds × 2 repeats instead of 10 × 10?
Nested tuning multiplies the cost; 10 × 10 is recommended for replicability but was not tractable. The corrected t-test accounts for the fold overlap we do have.
RF had the highest scores. Why not call it the winner?
Because the differences are within noise once fold overlap is accounted for. A naive test would have declared a false winner (p = 0.029 vs 0.20).
Should the model use gender at all?
Removing it often does not remove bias, because of proxies. Whatever is decided has to be checked with an audit like ours, and flags should only ever trigger offers of support.
Does SHAP tell us why students drop out?
No. It explains the model's behavior. Unpaid tuition could be a cause, a symptom, or a marker of something else entirely.
Would this work at MSU?
The method would; the fitted model would need retraining on MSU data, with the outcome definition matched and the subgroup audit re-run.
How did you use AI?
Parts of the refactored pipeline, scripts and figure code were drafted with an AI coding assistant. Everything was verified by full reruns, deterministic checks and cross-checking numbers against earlier results.
46
Foundations

Glossary

Base rate
The true share of a group with an outcome (e.g. 12.2% of scholarship holders drop out).
Bootstrap
Resampling with replacement to estimate uncertainty.
Calibration
Whether predicted probabilities match observed frequencies.
Censoring
An outcome not yet observed when data collection stops (the Enrolled class).
Class weight
A multiplier making errors on rare classes cost more.
Cohort
Students who enrolled in the same year.
Cross-validation
Rotating train/test splits so every student is tested once.
Equalized odds
Equal true and false positive rates across groups.
Equal opportunity
Equal true positive rate (recall) across groups.
False-flag rate
Share of non-dropouts flagged as dropouts (false positive rate).
Family-wise error rate
Chance of at least one false positive across a set of tests.
Hyperparameter
A setting chosen before training (C, γ, depth).
Leakage
Information available in training that would not be at prediction time.
Macro-F1
Unweighted average of per-class F1.
Nested CV
Tuning inside each training set so test folds never guide choices.
One-hot encoding
One 0/1 column per category.
Permutation importance
Score drop when a variable is shuffled on held-out data.
Recall
Share of a class's real members that the model catches.
SHAP
Fair per-feature contributions to each prediction, from Shapley values.
Stratified
Keeping class proportions equal across folds.
Zero-R
Always predicts the majority class; the floor.

You've reached the end. If every card is marked, try explaining the big-picture card from memory: that's the real test.