Skip to content
Logo
arrow_backBackKembali
Project

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

1. Data Pipeline & Prep 22.6k+ Court Order XML Ingestion (lxml) IQR Outlier Removal | Stratified 80:20 Split Cleaned df 2. Feature Engineering 13 Core + 10 LSA text embeddings 2 Bayesian Target Enc. (smoothing α=50) VIF < 10 & Mutual Info Selection StandardScaler 3. Model Ensemble & Tuning Random Forest + XGBoost Tuning GridSearchCV with Box-Cox Target Transform Inverse-RMSE Weighted Ensemble Model Test set preds 4. Evaluation & XAI Audit R² 0.81 | MAE 7.03 | RMSE 11.87 SHAP (TreeExplainer) Waterfall/Beeswarm Fairness Ratio 1.01 | Calibration SD 0.93 Data & Konfigurasi SHAP Ensemble model (.pkl) Streamlit Interactive Dashboard Main Metrics, 95% CI & Geo-maps SHAP Waterfall Plot | PDPs | KNN Comparison

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).

Stack
PythonScikit-LearnXGBoostSHAPMLflowStreamlitGitPythonlxmlPandasNumPySciPyStatsmodelsSeaborn
R² 0.81MAE 7.03 mosRMSE 11.87 mos22.6k+ cases