Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Student Academic Risk Prediction 🎓

TSV 3343 — Big Data Analytics and Development — Mini Project (15%)

A complete data-science pipeline that predicts whether a university student is "At Risk" or "Not At Risk" academically, and serves live predictions through an interactive Quarto-Shiny web app.


📋 Project Overview

Aspect Detail
Domain Higher Education / Student Performance
Task Binary Classification
Target academic_risk → At Risk / Not At Risk
Dataset 12,084 records × 14 attributes
Model XGBoost Classifier (calibrated)
Explainability SHAP (TreeExplainer)
Deployment Quarto-Shiny interactive document

🗂️ Project Structure

File / Folder Purpose
P01.qmd Full analysis notebook: EDA, cleaning, feature engineering, model training, evaluation, calibration, SHAP analysis
P01_shiny.qmd Interactive web app — live prediction form, SHAP waterfall + beeswarm, CSV batch upload, CSV/PDF report download
P01_data_cleaned.csv Cleaned dataset (12,001 rows × 16 features)
model_py312.pkl Trained XGBoost model (Python 3.12-safe pickle)
scaler_py312.pkl StandardScaler fitted on the 16 features (Python 3.12-safe pickle)
sample_students_strings.csv Example batch-upload CSV with human-readable values (Male/Female, Yes/No)
requirements.txt Python dependencies
_quarto.yml Quarto project configuration

⚙️ Setup

1. Install Quarto

Download and install Quarto 1.10+ from https://quarto.org/docs/get-started/

2. Create the conda environment

conda create -n jupyter_env python=3.12
conda activate jupyter_env
pip install -r requirements.txt

3. Verify model & scaler

The app loads these at startup:

  • model_py312.pkl — XGBoost classifier
  • scaler_py312.pkl — StandardScaler

Both are already included in the project folder.


▶️ How to Run

Analysis Notebook

quarto preview P01.qmd

Interactive Web App

quarto preview P01_shiny.qmd

Then open http://localhost:4200 in your browser.


🧩 What the Web App Does

1. Input Cards (Top Row)

  • Student Profile — Age, Gender, Programme
  • Academic Record — Attendance %, Assignment Avg, Quiz Avg, Midterm Score, Previous GPA
  • Habits & Circumstances — Study Hours/Week, Absences, Internet Access, Extracurricular

2. Prediction Output

Live text showing:

  • Prediction: At Risk / Low Risk
  • Probability: e.g. 0.3447
  • Top 3 SHAP drivers

3. SHAP Waterfall (Full Width)

Shows how each feature pushes this specific student's prediction up or down.

  • Red bars = push risk up
  • Blue bars = push risk down
  • f(x) = final prediction score
  • E[f(X)] = baseline average prediction

Grey numbers on the left (e.g. -0.200 = age) are not accuracy — they are the standardized (scaled) values your model sees:

scaled = (raw_value - dataset_mean) / dataset_std

Example: age 21 becomes -0.200 because 21 is slightly below the dataset mean (21.458).

4. SHAP Beeswarm (Full Width)

Global view of which features matter most across all students.

  • Y-axis = feature names, sorted by importance
  • X-axis = SHAP value (impact on model output)
  • Each dot = one student
  • Color = feature value (red = high, blue = low)

How to read it:

  • Top features have the biggest effect on predictions
  • Wide spread = feature can strongly push risk up or down
  • Narrow cluster = feature has little effect
  • Dots on the right (positive) = increase risk; dots on the left (negative) = decrease risk

5. Batch CSV Upload

Upload a CSV with student data. The app:

  • Computes engagement_score if missing
  • Maps Male/Female → 0/1, Yes/No → 1/0
  • One-hot encodes programme
  • Scales features with the saved StandardScaler
  • Returns probability + label for each row

Use sample_students_strings.csv to test.

6. Download Reports

  • CSV — batch prediction results
  • PDF — single-input report (text summary + waterfall + beeswarm)

📊 Model Details

Metric Value
Algorithm XGBoost
Calibration Isotonic
Decision threshold 0.1546
Test recall 0.6319
Test precision 0.2367
Test F1 0.3444
Test accuracy 0.6543
Confusion matrix TN 1353 / FP 703 / FN 127 / TP 218

16 Features (exact order)

age, gender, attendance_pct, assignment_avg, quiz_avg, midterm_score,
study_hours_week, previous_gpa, absences, internet_access, extracurricular,
prog_Computer Science, prog_Data Science, prog_IT, prog_Software Engineering,
engagement_score

🧠 Key Concepts

StandardScaler

The model was trained on scaled data, so all inputs are transformed:

scaled = (raw - mean) / std

This is why the waterfall shows small decimal numbers instead of the raw slider values.

SHAP (SHapley Additive exPlanations)

  • Waterfall — explains one specific prediction (this student)
  • Beeswarm — explains the model globally (all students)

Calibration

The raw XGBoost probability is adjusted with isotonic regression so the predicted probability better matches real-world frequencies.


🛠️ Troubleshooting

Problem Fix
could not convert string to float: 'Male' The app now auto-maps Male/Female and Yes/No in CSV upload. Use sample_students_strings.csv as a template.
Duplicate output ID Restart quarto preview and open one browser tab.
IProgress not found warning Suppressed automatically by warnings.filterwarnings("ignore") in the setup cell.
More column widths than children Suppressed automatically. Layout is verified working.
Pickle load error Use model_py312.pkl and scaler_py312.pkl (rebuilt for Python 3.12).

📚 References

  • Lundberg, S. M., & Lee, S.-I. (2017). A Unified Approach to Interpreting Model Predictions. NeurIPS.
  • Chen, T., & Guestrin, C. (2016). XGBoost: A Scalable Tree Boosting System. KDD.
  • Pedregosa et al. (2011). Scikit-learn: Machine Learning in Python. JMLR.

Author: Nik Abdul Aqmal Bin Zunaidi Group: 01 Lecturer: Assoc. Prof. Dr. Zuraini Zainol Course: TSV 3343 — Big Data Analytics and Development

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages