⚡0 XP🔥0

Project: Student Placement Predictor

Lesson 11 of 11 ⏱ 8 min read ✎ 2 exercises ❓ 3-question quiz ▶ Runs Python

An end-to-end ML project - explore a placement dataset, prepare features with a pipeline, compare models with cross-validation, tune the best one, evaluate on a test set, explain it with feature importance, and predict for new students.

In this project you will build a model that predicts whether a final-year student will be placed, from academic and skill data - the kind of tool a college Training & Placement cell could use to find students who need extra support early.

Practice dataset

placement.csv - 600 students (synthetic data created for Vindhyaedu), already loaded in every editor on this page.

Columns: student_id, branch (CSE/IT/ECE/ME/CE), cgpa, internships, projects, aptitude_score (0-100, some missing), communication (1-10, some missing), backlogs, certifications, placed (1/0, the target), salary_lpa (only for placed students).

Step 1: understand the problem#

  • Task: binary classification - placed = 1 or 0.
  • Features: everything known before placement season.
  • Not a feature: salary_lpa - it only exists after a student is placed. Using it would leak the answer.
  • Metric: accuracy overall, plus recall for "not placed" - the cell wants to catch at-risk students.

Step 2: explore the data#

▶ Try it Yourselfplacement.csvPython
Ctrl + Enter to run
Output
(600, 11)
aptitude_score     14
communication      10
salary_lpa        188
dtype: int64

Placement rate: 0.687

By branch:
        count   mean
branch              
IT        106  0.802
CSE       182  0.703
ECE       129  0.698
CE         79  0.633
ME        104  0.567

Average values, placed vs not placed:
        cgpa  internships  aptitude_score  backlogs
placed                                             
0       6.98         0.78           63.15      1.12
1       7.69         1.05           67.44      0.68

Placed students have a higher CGPA, more internships, higher aptitude scores and fewer backlogs - promising signals.

▶ Try it Yourselfplacement.csvPython
Ctrl + Enter to run

Step 3: prepare features with a pipeline#

▶ Try it Yourselfplacement.csvPython
Ctrl + Enter to run
Output
features after preprocessing: 12
['num__cgpa', 'num__internships', 'num__projects', 'num__aptitude_score', 'num__communication', 'num__backlogs', 'num__certifications', 'cat__branch_CE', 'cat__branch_CSE', 'cat__branch_ECE', 'cat__branch_IT', 'cat__branch_ME']

Step 4: compare models with cross-validation#

▶ Try it Yourselfplacement.csvPython
Ctrl + Enter to run
Output
baseline             0.688 +/- 0.000
logistic regression  0.779 +/- 0.045
KNN (k=15)           0.744 +/- 0.016
decision tree        0.694 +/- 0.017
random forest        0.750 +/- 0.026
gradient boosting    0.731 +/- 0.062
हिंदी में समझें

हमने test set को छुए बिना, सिर्फ़ training data पर 5-fold cross-validation से कई models की तुलना की। हर model को baseline (हमेशा "placed" बोलने वाला) से बेहतर होना चाहिए। सबसे अच्छा model चुनकर उसे tune करेंगे, और test set पर सिर्फ़ एक बार आखिरी जाँच करेंगे।

Step 5: tune, then evaluate once on the test set#

Logistic regression performs at least as well as the more complex models here (the data has fairly simple, additive patterns), so we tune its regularisation strength C and evaluate it:

▶ Try it Yourselfplacement.csvPython
Ctrl + Enter to run
Output
best C: 0.1  CV accuracy: 0.767
[[18 20]
 [ 8 74]]
              precision    recall  f1-score   support

  not placed      0.692     0.474     0.562        38
      placed      0.787     0.902     0.841        82

    accuracy                          0.767       120
   macro avg      0.740     0.688     0.702       120
weighted avg      0.757     0.767     0.753       120

About 77% of test students are classified correctly - clearly better than the 69% baseline. But look at the not placed row: recall is only about 0.47, so the model finds fewer than half of the at-risk students. For the placement cell that is the number that matters, so in practice you would lower the decision threshold (for example, flag anyone with P(placed) below 0.7), accepting more false alarms in exchange for catching more students who need help.

Step 6: explain the model#

A model the placement cell cannot explain will not be trusted. Logistic regression's coefficients (on scaled features) show the direction and strength of each factor:

▶ Try it Yourselfplacement.csvPython
Ctrl + Enter to run
Output
backlogs         -0.62
branch_CE        -0.59
branch_ME        -0.44
branch_ECE        0.17
certifications    0.19
branch_CSE        0.23
projects          0.33
aptitude_score    0.42
communication     0.44
internships       0.47
branch_IT         0.62
cgpa              1.00
dtype: float64

Reading it: CGPA, internships and aptitude push the probability of placement up; backlogs push it down. That gives the cell concrete advice - clear backlogs, do an internship, practise aptitude.

Step 7: predict for new students#

▶ Try it Yourselfplacement.csvPython
Ctrl + Enter to run
Output
Riya    P(placed) = 0.99  -> on track
Manav   P(placed) = 0.05  -> needs mentoring
Sakshi  P(placed) = 0.83  -> on track

Sakshi's aptitude score is missing - the pipeline's imputer fills it in automatically.

Take it further#

  1. Real data - try the Kaggle Campus Recruitment or Placement Data datasets, or anonymised data from your own college (with permission).
  2. Salary model - a regression model predicting salary_lpa for placed students.
  3. Threshold - lower the threshold for "needs mentoring" to raise recall for at-risk students.
  4. Deploy - save the pipeline with joblib.dump(model, "placement.pkl") and serve it from a Flask or FastAPI app, or a Streamlit dashboard.
  5. Fairness - check that the model's errors are similar across branches and genders before using it for real decisions.
Common Mistake

A model like this should support human decisions (who to mentor), never replace them. Predictions are probabilities learned from past data, which may contain historical biases.

Summary#

You completed a full ML project: problem framing, leakage check, EDA, a preprocessing pipeline, model comparison with cross-validation, tuning, a single honest test evaluation, interpretation and prediction for new cases - the same process used in industry.

Practice Exercises

Write your code, then press Check. Your program is tested automatically.

1

Placement rate by branch

Load placement.csv with pandas and compute the placement rate (mean of placed) for each branch, as a Series rate sorted from highest to lowest and rounded to 3 decimals. Print it.

Dataset: placement.csv (already loaded - just use the file name)
2

Build the full pipeline

Build model: a ColumnTransformer (median-impute + scale the numeric columns, one-hot branch) followed by RandomForestClassifier(n_estimators=200, random_state=0). Split with test_size=0.2, random_state=42, stratify=y, fit, and store the test accuracy in acc. Print it rounded to 3 decimals.

Dataset: placement.csv (already loaded - just use the file name)

Quick Quiz

Q1.

Why is salary_lpa NOT used as a feature to predict placed?

Q2.

Why compare models with cross-validation instead of the test set?

Q3.

For a placement cell that wants to find students who need support, which metric is most useful for the "not placed" class?