1 Introduksi
1.1 Latar Belakang
Machine learning (ML) menyediakan algoritma adaptif untuk pattern recognition yang sulit dimodelkan dengan persamaan parametrik klasik. Dua keluarga tree-based ensemble dominan untuk tabular data sains pangan: Random Forest (Breiman, 2001) — bootstrap aggregation dari decision trees dengan random feature subset, dan Gradient Boosting (Friedman, 2001) — sequential tree fitting on residuals. Keduanya: (i) robust terhadap non-linearitas, (ii) handle mixed numeric+categorical, (iii) auto-detect feature interactions, (iv) provide feature importance ranking.
Konteks sains pangan: prediksi shelf life dari multivariate fingerprint, klasifikasi konsumen accept/reject dari sensory profile, deteksi adulterasi dari NIR spectrum, root cause analysis defect produksi dari proses parameter. Kelebihan: requires fewer assumptions than regresi linear. Kelemahan: less interpretable, overfitting risk bila data kecil.
1.2 Tujuan Modul
Modul Quick ML / Pattern Finder di SQalytics ditujukan untuk:
- Menerima dataset (features + target — regression atau classification).
- Melatih Random Forest atau Gradient Boosting dengan default sensible.
- Menyediakan train/test split + cross-validation untuk unbiased performance estimate.
- Menampilkan feature importance + partial dependence plot (PDP).
- Audiens: peneliti R&D yang explore pattern, data analyst tanpa ML expertise mendalam.
1.3 Posisi di Antara Alternatif
Pilih Quick ML / Pattern Finder untuk non-linear pattern discovery + feature importance. Untuk linear regression, pakai Regression Studio. Untuk multivariate spectral, pakai PLSR Studio. Untuk unsupervised grouping, pakai Cluster Analysis Explorer. Untuk dimensionality reduction, pakai PCA Explorer.
2 Metode
2.1 Dasar Teoretis
Decision tree (CART) (Breiman, Friedman, Olshen, & Stone, 1984) — partisi feature space secara rekursif dengan Gini impurity (classification) atau MSE (regression):
$$\text{Gini}(t) = 1 - \sum_{c=1}^{C} p_c^2, \quad \text{MSE}(t) = \frac{1}{n_t} \sum_{i \in t} (y_i - \bar{y}_t)^2$$Split optimal: maksimum reduction in impurity. Recursive sampai stopping criterion (depth, min samples).
Random Forest (Breiman, 2001):
- Bootstrap $B$ samples dari training set.
- Per bootstrap, tumbuh decision tree dengan random feature subset ($\sqrt{p}$ untuk classification, $p/3$ untuk regression) di setiap split.
- Prediksi = majority vote (classification) atau mean (regression) dari $B$ trees.
Formal:
Out-of-bag (OOB) error — tiap sample tidak masuk ~37% bootstrap → estimate generalization error tanpa hold-out set.
Gradient Boosting (Friedman, 2001):
$$F_m(\mathbf{x}) = F_{m-1}(\mathbf{x}) + \nu \cdot h_m(\mathbf{x})$$dengan $h_m$ tree fit ke residual $r_i = y_i - F_{m-1}(\mathbf{x}_i)$, $\nu$ learning rate (0.01–0.1). XGBoost dan LightGBM = optimasi efficient.
Feature importance (mean decrease impurity, MDI):
$$I_j = \frac{1}{B} \sum_{b=1}^{B} \sum_{t \in T_b: \text{split}_j} \Delta \text{impurity}(t)$$Normalisasi ke total 1.0. Alternatif: permutation importance — shuffle $X_j$, measure drop in performance.
Partial Dependence Plot (PDP) — marginal effect feature $j$:
$$\text{PDP}_j(v) = \frac{1}{n} \sum_{i=1}^{n} \hat{f}(X_{i,1}, \ldots, X_{i,j-1}, v, X_{i,j+1}, \ldots, X_{i,p})$$Cross-validation (k-fold) untuk performance estimate:
$$\text{CV}_{k}\text{-MSE} = \frac{1}{k} \sum_{i=1}^{k} \text{MSE}(\text{fold}_i)$$Default $k = 5$ atau 10.
Metrics:
- Regression: $R^2$, RMSE, MAE.
- Classification: Accuracy, Precision, Recall, $F_1$, AUC-ROC.
2.2 Persamaan Inti
- RF prediction: $\hat{y} = (1/B) \sum_b \hat{f}_b(\mathbf{x})$
- Gradient boosting: $F_m = F_{m-1} + \nu \cdot h_m$
- Gini impurity: $1 - \sum p_c^2$
- Feature importance: mean decrease impurity per split
- $F_1$: $2 \cdot \text{Prec} \cdot \text{Recall} / (\text{Prec} + \text{Recall})$
2.3 Asumsi & Batas Validitas
| Asumsi | Konsekuensi jika dilanggar | Cara cek di SQalytics |
|---|---|---|
| Sample size adequate ($n \geq 50$ per class) | Overfitting | Modul flag $n$ kecil |
| Training-test distribution similar | Generalization fail | Stratified split |
| Features informatif | Garbage in, garbage out | Feature importance review |
| Tidak ada data leakage | False high accuracy | Train-test split correct |
| Class balance (klasifikasi) | Bias to majority | Stratified + class weight |
| Tidak terlalu banyak features ($p \ll n$) | Curse of dimensionality | Feature selection |
3 Cara Kerja
3.1 Step-by-Step di SQalytics
- Buka
Quick ML / Pattern Finderdari domain Mutu dan Analisis Lanjutan. - Muat dataset: rows = observations, columns = features + target.
- Tetapkan target column dan task: regression / classification.
- Pilih algoritma: Random Forest (default) atau Gradient Boosting.
- Set train/test split ratio (default 80/20) + stratify (classification).
- Klik Train Model.
- Tinjau:
- Tab
Performance Metrics— train, test, cross-validation. - Tab
Feature Importance— bar chart ranked. - Tab
PDP— partial dependence per top feature. - Tab
Predicted vs Actual(regression) atauConfusion Matrix(classification). - Tab
Tuning(opsional) — grid search hyperparameter.
- Tab
3.2 Template Tabel Input + Contoh Data Sintetis
Prediksi shelf life dari proses + komposisi (150 observations, 8 features):
| Sample | Sugar_% | Aw | pH | Process_T | Pkg_O2 | Storage_T | Antioxidant | Shelf_life_day |
|---|---|---|---|---|---|---|---|---|
| 1 | 35 | 0.62 | 4.5 | 85 | 1.2 | 25 | 0.05 | 145 |
| 2 | 40 | 0.58 | 4.3 | 90 | 0.8 | 25 | 0.10 | 178 |
| 3 | 30 | 0.65 | 4.7 | 80 | 1.5 | 25 | 0.03 | 102 |
| … (150 observations total) | ||||||||
Target: Shelf_life_day (regression).
docs/assets/example-data/id/quality-advanced/template_quality_ml_pattern.csv.
3.3 Contoh Luaran
Performance (Random Forest, $B = 500$ trees):
| Metric | Train | Test | 5-fold CV |
|---|---|---|---|
| $R^2$ | 0.97 | 0.84 | 0.81 ± 0.05 |
| RMSE (day) | 6.2 | 14.5 | 15.8 ± 2.1 |
| MAE (day) | 4.8 | 10.2 | 11.5 ± 1.6 |
OOB $R^2 = 0.82$ (consistent with CV).
Feature importance (normalized):
| Feature | Importance |
|---|---|
| Pkg_O2 barrier | 0.32 |
| Aw | 0.24 |
| Antioxidant | 0.15 |
| Storage_T | 0.12 |
| pH | 0.08 |
| Process_T | 0.05 |
| Sugar_% | 0.03 |
| (residual) | 0.01 |
Partial dependence plot (PDP) Pkg_O2: shelf life turun dari 180 day → 90 day saat Pkg_O2 naik 0.5 → 2.5 cc/m²/day (non-linear, threshold ~1.5).
Partial dependence Aw: shelf life turun curam saat Aw > 0.65 (microbial spoilage threshold).
ASLT / Shelf-Life Prediction pada 2 Pkg_O2 levels). Confirm RF hypothesis via mekanistic kinetic model. Untuk regression linear-friendly, lanjut ke Regression Studio test apakah relationship simpler model bisa capture juga."4 Kesimpulan
4.1 Relevansi Real-World
- Predictive modeling shelf life / sensory acceptance dari multivariate input.
- Root cause analysis defect produksi (feature importance pada process parameter).
- Adulterasi detection dari NIR / spectral fingerprint.
- Consumer segmentation classification (accept/reject prediction).
- Process optimization screening sebelum DoE formal.
4.2 Where to Go from Here
⚙ Troubleshooting Cepat
i Riwayat Revisi
| Tanggal | Revisi | Penulis |
|---|---|---|
| 2026-05-12 | Draft v2 publikasi (KaTeX RF + gradient boosting + feature importance + PDP + APA Breiman/Friedman/Hastie) | Claude |
| 2026-05-12 | Konversi MD → HTML (W5 quality-advanced batch) | Claude |
4 Referensi
- Breiman, L. (2001). Random forests. Machine Learning, 45(1), 5–32. https://doi.org/10.1023/A:1010933404324
- Breiman, L., Friedman, J. H., Olshen, R. A., & Stone, C. J. (1984). Classification and regression trees. Wadsworth.
- Friedman, J. H. (2001). Greedy function approximation: A gradient boosting machine. Annals of Statistics, 29(5), 1189–1232. https://doi.org/10.1214/aos/1013203451
- Hastie, T., Tibshirani, R., & Friedman, J. (2009). The elements of statistical learning (2nd ed.). Springer. https://doi.org/10.1007/978-0-387-84858-7
- Chen, T., & Guestrin, C. (2016). XGBoost: A scalable tree boosting system. Proceedings of the 22nd ACM SIGKDD, 785–794. https://doi.org/10.1145/2939672.2939785
- Molnar, C. (2022). Interpretable machine learning (2nd ed.). https://christophm.github.io/interpretable-ml-book/