Predict a label only after defining its purpose
The educational task estimates whether a synthetic student record receives a placement outcome. The model is intended to demonstrate classification—not to approve, reject or rank real students. Its target is binary: placed or not placed. Its features describe academic and preparation measures available before the outcome.
Prediction unit
One synthetic student record.
Positive class
A placement outcome is recorded.
Model output
Probability plus a chosen threshold.
Synthetic data makes the teaching assumptions visible
The program generates 900 reproducible rows using a fixed random seed. Features are CGPA, aptitude, coding, communication, projects, internships and backlogs. A hidden probabilistic formula produces labels, then 3% missing values are added to aptitude and coding so the pipeline must impute them.
| Feature | Type/range | Availability | Reason included |
|---|---|---|---|
| CGPA | Continuous, 4.5–10 | Before placement | Academic record |
| Aptitude/coding/communication | Scores, bounded | Before outcome | Preparation measures |
| Projects/internships/backlogs | Counts | Before outcome | Experience and academic state |
Because the dataset is synthetic, its coefficients and accuracy do not describe a real college. Its advantage is instructional control: learners know how the target was generated and can test whether the workflow recovers useful signal.
The test set must remain untouched until the final audit
The full data is split into 60% training, 20% validation and 20% testing using stratification. Training estimates model parameters. Validation compares thresholds. Testing is opened once to estimate final generalization.
- Split development data from the final test set.
- Split development into training and validation.
- Fit median values, scaling statistics and model coefficients using training only.
- Select the threshold using validation predictions.
- Evaluate the chosen workflow once on test data.
Preprocessing and prediction form one fitted object
numeric features → median imputation → standard scaling → class-balanced logistic regression → probability
Logistic regression is selected because it produces probabilities and supports coefficient inspection. Standardization puts features on comparable scales. Class weights reduce the tendency to ignore the less frequent positive class. This does not guarantee fairness or calibration; it only changes the loss contribution of the classes.
A most-frequent DummyClassifier is the baseline. It can achieve seemingly respectable accuracy by predicting the majority class while producing zero recall for placed students. A model is useful only when it improves the metrics connected to the task.
A probability becomes a class only after a decision rule
| Metric | Question answered | Failure if used alone |
|---|---|---|
| Accuracy | What fraction is correct? | Can hide minority-class failure |
| Precision | Of predicted positives, how many are positive? | Can improve by predicting very few positives |
| Recall | Of actual positives, how many are found? | Can improve with many false alarms |
| F1 | What is the harmonic balance? | Ignores true negatives |
| ROC-AUC | How well are classes ranked across thresholds? | Does not select an operating threshold |
The program tests thresholds from 0.25 through 0.70 on validation data, requires recall of at least 0.70 when possible and chooses the best F1 among acceptable candidates. The test set is not used for that decision.
Reproducible Python program
Loading source…Install packages from programs/requirements.txt. The program generates its own data, so no external file is needed. Each run uses the same random state, making the split, fitted model and printed results reproducible for discussion.
Trace one leakage-safe experiment
- Create data.
- Protect test data.
- Build development splits.
- Train pipeline.
- Compare thresholds.
- Freeze threshold.
- Final evaluation.
- Interpret cautiously.
Press Next to begin.
Test the workflow, not only the function calls
Reproducibility
Pipeline isolation
Baseline challenge
Threshold rule
Feature removal
A demonstration model is not a deployable decision system
- Synthetic relationships are chosen by the programmer and cannot establish real-world validity.
- Coefficients are associations conditional on the included features; they do not prove causation.
- A real dataset may shift across batches, programs, companies and economic periods.
- Probability calibration, subgroup error analysis and privacy review are not optional in deployment.
- Training-support use still requires consent, access control, appeal and human review.
A responsible next experiment would define a support-only outcome, collect documented consented data, establish a temporal test split, audit missingness, compare calibrated models and monitor drift after deployment.
Check the experimental reasoning
Which split should choose the classification threshold?
Why train a DummyClassifier?
Extensions
- Add calibrated probabilities and compare reliability diagrams.
- Compare logistic regression with a pruned decision tree.
- Replace random split with a semester-based temporal split.
- Create a model card containing intended use, metrics and limitations.
Defend every experimental choice
Why is preprocessing inside a Pipeline?
Cross-validation or fitting applies each transformation using training data only, preventing information from validation or test rows entering learned preprocessing statistics.
Why can high accuracy be misleading?
When one class dominates, predicting only that class can be accurate while failing every minority example. The printed baseline demonstrates this directly.
Can coefficients identify what causes placement?
No. They describe adjusted associations in this synthetic model. Confounding, feature correlation, selection processes and the generated label mechanism prevent causal claims.
What would change for production?
Data contracts, temporal validation, calibration, fairness and privacy review, versioned artifacts, monitored serving, drift alerts, rollback and human oversight are required.
The experimental boundary is part of the model
A classifier is not just an algorithm. Data timing, leakage control, baseline comparison, threshold policy, error costs and responsible-use limits determine whether its evaluation deserves trust.
