student-performance-dnn
A compact, regularized Keras MLP that predicts a student's academic performance tier from demographic, behavioral, social, and prior-grade features of the UCI Student Performance dataset.
Note on metrics: this card uses the verified numbers in
evaluation_metrics.json(3-tier scheme). An earlier project README referenced a superseded 5-tier experiment — those figures are not the deployed checkpoint.
Model details
| Item | Value |
|---|---|
| Architecture | Dense 64 (ReLU, He-normal, L2) → Dropout 0.15 → Dense 32 (ReLU, L2) → Dropout 0.10 → Dense 3 (Softmax) |
| Input | 36 transformed features (19 scaled numeric + 17 ordinal-encoded categorical) |
| Output | 3 classes: 0 Fail / high risk (G3 0–9), 1 Pass / satisfactory (10–13), 2 Good / outstanding (14–20) |
| Trainable parameters | 4,547 |
| Optimizer | AdamW, learning rate 1e-3, weight decay 1e-4 |
| Loss | Sparse categorical cross-entropy |
| Checkpoint | model.safetensors (framework-neutral weights), keras_config.json (Keras 3 architecture), original student_dnn_model.keras |
Weights are exported as .safetensors with named tensors:
dense_layer_1.kernel (36, 64)
dense_layer_1.bias (64,)
dense_layer_2.kernel (64, 32)
dense_layer_2.bias (32,)
tier_probabilities_output.kernel (32, 3)
tier_probabilities_output.bias (3,)
Dataset
UCI Student Performance Dataset (Cortez & Silva, 2008), Portuguese language course (student-por.csv, 649 records). The smaller Mathematics course file is retained in the source repository for comparison only.
Engineered features: G_diff = G2 - G1, G_mean = (G1 + G2) / 2, total_alc = Dalc + Walc, parent_edu = max(Medu, Fedu), plus raw G1, G2.
Split: stratified 80% train / 20% held-out test (130 students); 20% of the training set used for validation. Random seed 42.
Preprocessing: StandardScaler for numeric columns; OrdinalEncoder → StandardScaler for categorical columns. The ColumnTransformer is fitted on training splits only (no leakage) and exported as preprocessor.joblib in the source repository.
Training hyperparameters
RANDOM_STATE = 42
TEST_SIZE = 0.20
VAL_SIZE = 0.20
dense_units = [64, 32]
dropout_rates = [0.15, 0.10]
learning_rate = 0.001
weight_decay = 1e-4
batch_size = 32
epochs = 120 # maximum
early_stopping_patience = 20 # monitor val_loss, restore_best_weights=True
reduce_lr_patience = 6 # factor=0.5, min_lr=1e-5
class_weight = None # balanced weights computed but not applied to final run
Batch Normalization was intentionally omitted: mini-batches are small and tabular, so BN introduced distribution shift. Dropout + L2 were used instead.
Evaluation
Held-out test set, n = 130 students:
| Metric | DNN (this model) | Random Forest baseline | Gradient Boosting baseline |
|---|---|---|---|
| Exact 3-tier accuracy | 86.92% | 90.77% | 88.46% |
| Within ±1 tier | 100% | 100% | 100% |
| Macro F1 | 0.8253 | 0.8805 | 0.8613 |
| Weighted F1 | 0.8631 | 0.9043 | 0.8828 |
| ROC-AUC (OvR) | 0.9290 | 0.9664 | 0.9677 |
| Test loss | 0.4597 | — | — |
Interpretation: on this small tabular dataset the tree baselines are stronger on exact-tier accuracy, while the DNN still achieves 100% adjacent-tier accuracy and strong ranking quality (ROC-AUC ≈ 0.93). The model is a study in regularization and leakage-free preprocessing, not a claim of state-of-the-art tabular performance.


Loading the weights
import json
import numpy as np
from safetensors.numpy import load_file
from tensorflow import keras
weights = load_file("model.safetensors")
config = json.load(open("keras_config.json"))
model = keras.models.model_from_json(json.dumps(config["config"]))
model.set_weights([weights[k] for k in (
"dense_layer_1.kernel", "dense_layer_1.bias",
"dense_layer_2.kernel", "dense_layer_2.bias",
"tier_probabilities_output.kernel", "tier_probabilities_output.bias",
)])
model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"])
For end-to-end inference, apply the fitted preprocessor.joblib from the source repository before calling model.predict().
Limitations and responsible use
- Trained on 649 records from one Portuguese course cohort; generalization to other institutions, languages, or time periods is unverified.
- Predictions are probabilistic and should never be used as the sole basis for grading, admissions, or disciplinary decisions.
- Sensitive attributes (sex, family structure, alcohol use, absences) are inputs. Deployments should audit subgroup performance and provide opt-out/appeal paths.
- The model predicts historical grade bands, not future potential or "talent". Treat output as an intervention signal, not a label.
Source and author
Full training pipeline, EDA, baselines, and Streamlit demo: github.com/Anvi-g
Built by Anvi Gogia — B.E. Computer Science (AI & ML), Chitkara University.