JustExplain — Explainable AI Sentencing Predictor
JustExplain is a collaborative Explainable AI (XAI) and machine learning research project designed to predict court sentencing lengths (in months) in Indonesia while providing transparent feature attribution. Lead author: Jarot — with my contribution spanning the ML pipeline engineering, research methodology design, and data preprocessing pipeline. The project mitigates judicial disparity and ensures algorithmic transparency by marrying non-linear ensemble models (Random Forest and XGBoost) with SHAP (SHapley Additive exPlanations) values.
Data Ingestion & Feature Engineering
The pipeline ingests 22,630 raw XML court orders from the public indo-law dataset using an lxml parser to build a tabular DataFrame. It handles missing values using median/mode imputation, filters outliers with IQR, and splits the data via stratified binning. The system engineers 15 key features, including 13 deterministic core features (such as log-scaled fines and narcotics quantities), 10 semantic LSA components extracted via TF-IDF + TruncatedSVD from charge and fact texts, and 2 target encoded features with Bayesian smoothing (alpha=50) to mitigate high-cardinality court and sub-classification bias. Feature selection is governed by Multicollinearity VIF < 10 and top Mutual Information rankings, followed by standard scaling.
Model Development & Validation
By tuning Random Forest and XGBoost models via GridSearchCV (with FP16 mixed precision on GPU clusters and MLflow run registry) and applying inverse-RMSE weighting, the ensemble achieves high accuracy. The target is normalized via Box-Cox transformation during training and back-transformed using inverse Box-Cox for real-scale predictions. Validation stability is secured using a Stratified 10-Fold Cross-Validation, yielding R² 0.80 ± 0.01.
Architecture
Interactive Dashboard & Fairness Audit
The interactive Streamlit interface provides real-time simulations where users can adjust prosecutor demands, fines, offense classification, age, and type free-text indictment/facts. The dashboard generates the main prediction with 95% confidence intervals, a SHAP waterfall plot, Partial Dependence Plots (PDP), geographical maps, and a KNN comparison table featuring 5 similar historical cases as legal precedents. Systematic auditing proved an exceptionally high fairness consistency (Regional Fairness Ratio = 1.01, Crime Type Fairness Ratio = 1.19) and calibration stability (Calibration SD = 0.93 months).