.sum() inside its loop, which collapsed “each wavelength’s own contribution” into a single number too early — so all 228 wavelengths received exactly the same VIP value, and the “top 20 VIP wavelengths” the script printed were meaningless.
Three simple checks would have caught this bug:
In this class we will use methods that check themselves and walk through VIP, classification, and outlier judgment again.
Full narration and captions; three simulated NB12 datasets. Player and downloads · Interactive lab
Beginner No coding: Orange OR14 (PCA + logistic regression classification, Apply Domain to find out-of-model samples) Advanced Colab NB12 (VIP, PLS-DA, Q residual)
| Time | Contents |
|---|---|
| 0:00–0:25 | Lecture: W13 recap (w, t, b), VIP principle and one hand calculation |
| 0:25–1:15 | Reading VIP: VIP vs. coefficient, VIP>1 filtering, selection bias (NB12 demo) |
| 1:15–1:40 | Lecture: classification principles (one-hot/argmax, PLS-DA, logistic regression, confusion matrix) |
| 1:40–2:30 | Orange OR14, part 1: PCA + logistic regression on six oils, read the confusion matrix |
| 2:30–2:55 | Lecture: Hotelling T² and Q residual, influence plot |
| 2:55–3:30 | Orange OR14, part 2: Apply Domain to find out-of-model samples + Corn outlier module |
| 3:30–4:00 | Group sharing: do the high-VIP bands match the chemistry? Which two oils are confused most easily? |
Assume SSY = [8, 2] (LV1 explains 8, LV2 explains 2, total 10); J = 3
| Wavelength | LV1 share | LV2 share | Σ SSY × share | VIP² = J × … ÷ ΣSSY | VIP |
|---|---|---|---|---|---|
| Wavelength 1 | 0.64 | 0.00 | 8×0.64 + 2×0.00 = 5.12 | 3×5.12÷10 = 1.536 | 1.24 |
| Wavelength 2 | 0.36 | 0.20 | 8×0.36 + 2×0.20 = 3.28 | 3×3.28÷10 = 0.984 | 0.99 |
| Wavelength 3 | 0.00 | 0.80 | 8×0.00 + 2×0.80 = 1.60 | 3×1.60÷10 = 0.480 | 0.69 |
| NB12 | VIP | Coefficient b |
|---|---|---|
| 1200 nm (acetic acid C–H, illustrative) | 2.57 | +4.96 |
| 1450 nm (water O–H first overtone, illustrative) | 1.82 | -4.01 |
A 4-LV PLS model built from the NB12 demo data (simulated spectra, not this class’s measurements); blue line = VIP (always ≥0), orange line = coefficient b.
| NB12 model | No. of wavelengths | LV | RMSECV | RMSEP |
|---|---|---|---|---|
| Full range | 81 | 4 | 0.1756 | 0.1658 |
| VIP>1 | 18 | 3 | 0.2256 ↑ | 0.1329 ↓ |
NB12 demo data (simulated): training set 60, test set 20; red line = VIP=1. Unit: acetic acid %.
| CAN | COC | EVOO | PEA | ROO | SOY | Result | |
|---|---|---|---|---|---|---|---|
| One-hot of EVOO (the answer) | 0 | 0 | 1 | 0 | 0 | 0 | Column 3 = 1 |
| NB12 test sample ŷ (actual COC) | -0.13 | 0.91 | -0.17 | 0.22 | 0.37 | -0.21 | argmax → COC ✓ |
| Misclassified sample ŷ (actual CAN) | 0.25 | -0.07 | 0.25 | 0.10 | -0.13 | 0.60 | argmax → SOY ✗ |
Codes: CAN = canola oil, COC = coconut oil, EVOO = extra virgin olive oil, PEA = peanut oil, ROO = refined olive oil, SOY = soybean oil.
| Actual \ Predicted | CAN | COC | EVOO | PEA | ROO | SOY |
|---|---|---|---|---|---|---|
| CAN | 4 | 0 | 0 | 0 | 0 | 1 |
| COC | 0 | 4 | 0 | 0 | 0 | 0 |
| EVOO | 0 | 0 | 4 | 0 | 0 | 0 |
| PEA | 0 | 0 | 0 | 5 | 0 | 0 |
| ROO | 0 | 0 | 1 | 0 | 2 | 1 |
| SOY | 0 | 0 | 0 | 0 | 0 | 5 |
NB12 demo data (simulated spectra, not this class’s measurements).
| Predicted ROO | Predicted not ROO | |
|---|---|---|
| Actually ROO | TP = 2 caught | FN = 2 missed |
| Actually not ROO | FP = 0 false alarm | TN = 23 correctly excluded |
Collapse the 6×6 matrix into a 2×2 of “ROO / not ROO”.
NB12 demo data (simulated PCA, 40 calibration samples, 2 principal components; not real Corn values). Dashed lines = 95% limits.
📖 Outlier detection teaching module (Corn dataset, T²/Q influence plot) → — practice with the T²/Q influence plot on the Corn dataset (80 samples × 700 wavelengths, three instruments m5/mp5/mp6).
Open NB12 in Colab ↗ · Beginner (no coding): Orange workflow OR14 ↗. Please also include the conclusions from each group’s sharing in your report: whether the high-VIP regions match the chemistry, and which two oils are confused most easily.
Tap to tick — make sure you really can do it.