Student Performance Prediction · Phase 3 · Lesson 1 of 3
Baseline Rule and Logistic Regression
Implement the agreed baseline rule, then train a logistic regression model, and compare both on the training data using cross-validation.
What you need
A computer with a web browser and a free Google account for Google Colab, or Python with Jupyter installed locally. Libraries: pandas, scikit-learn and matplotlib (all free).
In this lesson you will
- Implement and score a baseline rule
- Train a logistic regression with cross-validation
Key concepts
baselinelogistic regressioncross-validationpipelineprobability
The lesson
Score the baseline first, such as flagging every student with attendance below 75%. It is cheap and explainable, so any model must clearly improve on it.
Logistic regression predicts a probability between 0 and 1 for each student. It is a strong, interpretable first model for tabular data. Put encoding, scaling and the model in a scikit-learn Pipeline so the same steps are always applied in the same order.
Use 5-fold cross-validation on the training set to estimate performance without touching the test set.
Step by step
- Score the baseline on the training data with recall and precision.
- Build a Pipeline with preprocessing and logistic regression.
- Run 5-fold cross-validation and record the mean and spread of recall and precision.
- Compare with the baseline.
Practice activity
Produce a comparison table of the baseline and logistic regression from cross-validation.
Expected result: A table showing whether logistic regression beats the baseline, with mean and spread.
Common mistakes
- Skipping the baseline
- Fitting preprocessing outside the pipeline on all data
Check your understanding
-
Why put preprocessing inside a Pipeline?
Show answer
So the same steps are applied consistently and fitted only on training data in each fold.
-
What does cross-validation estimate?
Show answer
How the model is likely to perform on new data, without using the test set.
Further learning
Projects are instructor-guided: an instructor sets milestones, checks your work and gives feedback, online or in person. Self-study of the public lessons does not lead to a certificate. Enrolment and fees follow the Academy's existing policies — contact the Academy.