Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Summaries chosen with the answer in mind
PCR summarises the features by their biggest patterns, without asking whether those patterns matter for the response. Partial least squares asks while summarising: each component is the combination of features that moves most together with y (largest covariance). It keeps the stability of using a few summaries, but the summaries are chosen to be useful.
PLS is the standard calibration method for spectrometers (near-infrared, Raman, LIBS on rovers such as ChemCam and SuperCam), process sensors and soft sensors in industry. It works with hundreds of correlated channels and only dozens of reference samples.
- 1. PLS picks each component to maximise…
- 2. Compared with PCR, PLS usually needs…
- 3. PLS works when there are…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.One component by hand
Centred data: rows (1, 0), (−1, 0), (0, 1), (0, −1), with y = (2, −2, 1, −1).
- Weight: w ∝ Xᵀy = (4, 2), so w = (2, 1)/√5.
- Score: t = Xw = (2, −2, 1, −1)/√5, with tᵀt = 2.
- y-loading: q = yᵀt/tᵀt = (10/√5)/2 = √5.
- Fit: ŷ = qt = (2, −2, 1, −1): a perfect fit with one component.
- Coefficients: p = Xᵀt/tᵀt = (2, 1)/√5, so pᵀw = 1 and β = w·q = (2, 1).
PCA cannot choose here: both feature directions have the same variance. If it took PC1 = (1, 0), its one-component fit would explain only 8/10 of y’s variance.
The steps in plain English:
- Centre X and y.
- Weight = Xᵀy, normalised: the direction along which X covaries most with y.
- Scores t = Xw. Regress y on t (coefficient q) and each feature on t (loadings p).
- Remove what t explains from X and y (deflation), and repeat for the next component.
- Combine: β = W(PᵀW)⁻¹q. Choose the number of components by cross-validation.
- 1. The first PLS weight is proportional to…
- 2. Deflation removes…
- 3. In the hand example, one PLS component gives R² =
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.NIPALS for PLS1
For a = 1, …, k (with Xₐ, yₐ the deflated data, X₁ = X and y₁ = y, centred):
| Quantity | Formula | Meaning |
|---|---|---|
| weight | wₐ = Xₐᵀyₐ/‖Xₐᵀyₐ‖ | direction of maximal covariance |
| score | tₐ = Xₐwₐ | latent variable |
| X-loading | pₐ = Xₐᵀtₐ/tₐᵀtₐ | how features load on it |
| y-loading | qₐ = yₐᵀtₐ/tₐᵀtₐ | its regression coefficient |
| deflation | Xₐ₊₁ = Xₐ − tₐpₐᵀ, yₐ₊₁ = yₐ − qₐtₐ | remove what is explained |
Coefficients on the original features: β = W(PᵀW)⁻¹q. Predict with ŷ = ȳ + (x − x̄)ᵀβ.
The scores are mutually orthogonal and the weights are orthonormal. With k = rank(X), PLS equals OLS.
from sklearn.cross_decomposition import PLSRegression
from sklearn.model_selection import cross_val_score
pls = PLSRegression(n_components=6, scale=False).fit(X, y) # spectra: keep the physical scale
scores = [cross_val_score(PLSRegression(k, scale=False), X, y, cv=5, scoring="neg_root_mean_squared_error").mean() for k in range(1, 16)]
pls.x_weights_, pls.x_loadings_, pls.coef_Use it when there are many collinear features (spectra, sensor arrays), possibly p ≫ n, and you need a calibrated linear predictor and interpretable latent variables. Watch the number of components: PLS overfits faster than PCR as k grows (exercise 2).
- 1. PLS coefficients on the features are…
- 2. PLS scores are…
- 3. For spectra in the same units, PLSRegression is often used with…
Level 3: Advanced
★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.What PLS really computes
Krylov view (Helland, 1988). The PLS1 fit with k components is the least-squares solution restricted to the Krylov subspace
𝒦ₖ = the span of Xᵀy, (XᵀX)Xᵀy, …, (XᵀX)ᵏ⁻¹Xᵀy.
So PLS is exactly conjugate gradients on the normal equations, stopped after k steps. Early stopping is the regulariser.
PLS versus PCR fit. For every k, PLS’s training R² is at least PCR’s (De Jong, 1993). The Krylov subspace adapts to y; the leading principal subspace does not.
Shrinkage. In the principal basis, PLS multiplies each OLS component by a factor fⱼ that depends on y. Unlike ridge and PCR, these factors can exceed 1 and oscillate (Frank and Friedman, 1993; Butler and Denham, 2000). PLS therefore shrinks less predictably and can overfit as k grows.
Objective view. The a-th weight maximises cov(Xw, y)², which equals var(Xw)·corr(Xw, y)²·var(y), subject to ‖w‖ = 1 and orthogonality to the earlier scores. Compare:
- PCR maximises var(Xw) only;
- OLS (canonical correlation) maximises corr(Xw, y) only.
Interpretation tools:
- VIP scores (variable importance in projection) summarise how much each feature contributes over all components. A common rule of thumb flags VIP > 1 as important.
- Loadings and weights plots show which wavelengths make up each latent variable.
Variants:
- PLS2 handles several responses at once (SIMPLS; de Jong, 1993);
- sparse PLS adds an L1 penalty on the weights;
- kernel PLS handles non-linear relationships;
- PLS-DA is used for classification.
Interview questions.
- PLS or ridge? Their prediction error is often similar. Ridge’s shrinkage is smoother and more stable. PLS gives a few interpretable latent variables and is very fast for p ≫ n.
- Why do both PLS and PCR need at least 6 components in exercise 2? Six minerals overlap spectrally. To isolate one abundance, the model must span all six interfering directions.
- 1. k-component PLS1 equals least squares restricted to…
- 2. PLS shrinkage factors in the principal basis…
- 3. A common VIP threshold for 'important' is…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Counting components on rover spectra
History.
- Herman Wold developed NIPALS and PLS path modelling in the 1960s–70s for econometrics.
- Svante Wold, Martens and others adapted PLS regression to chemistry around 1983, founding chemometrics.
- Helland (1988) linked PLS to Krylov subspaces.
- De Jong (1993) introduced SIMPLS.
- Frank and Friedman (1993) analysed PLS statistically.
- PLS models calibrate ChemCam and SuperCam laser-induced breakdown spectroscopy on Curiosity and Perseverance (together with other multivariate methods).
Exercise 1. Five correlated features. PLS with k = 5 reproduces OLS exactly, and the scores are orthogonal. The first PLS direction has covariance 3.11 with y against 2.53 for PC1, and beats 200 random directions. With one component, the training MSE is 0.636 for PLS against 1.130 for PCR.
Exercise 2: number of components. Setup: the rover-spectra trace-mineral scenario from D1.17; 50 training spectra, 30 repetitions. The table shows the mean test RMSE (target standard deviation 0.29).
| k | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 15 |
|---|---|---|---|---|---|---|---|---|---|
| PLS | 0.298 | 0.305 | 0.304 | 0.277 | 0.179 | 0.081 | 0.083 | 0.087 | 0.093 |
| PCR | 0.293 | 0.297 | 0.301 | 0.305 | 0.309 | 0.083 | 0.083 | 0.083 | 0.082 |
Cross-validation picks a median k of 6.5 for PLS (test RMSE 0.083) and 13 for PCR (0.082).
- Neither method can predict the trace mineral with fewer than 6 components: the 6 overlapping mineral spectra must all be modelled to separate one of them.
- PLS starts to find the signal earlier (k = 5: 0.18 against 0.31) and CV picks about half as many components for the same accuracy.
- PLS overfits past its optimum (0.081 at k = 6 rising to 0.093 at k = 15). PCR’s error stays flat, because its extra components are low-variance noise directions with small fitted coefficients.
- PLS is more economical but not more accurate here. The common claim that “PLS beats PCR” is about the number of components, not the best achievable error.
PLS in AI, robotics and aerospace
- Planetary spectroscopy: elemental composition from LIBS, NIR and Raman spectra.
- Soft sensors: estimating hard-to-measure quantities (e.g. propellant quality) from many process sensors.
- Hyperspectral remote sensing: vegetation, mineral and water-quality retrieval.
- Multi-output calibration (PLS2): several properties predicted jointly from one spectrum.
References
- S. Wold, M. Sjöström, L. Eriksson (2001). “PLS-regression: a basic tool of chemometrics.” Chemometrics and Intelligent Laboratory Systems 58(2).
- I. S. Helland (1988). “On the structure of partial least squares regression.” Communications in Statistics – Simulation and Computation 17(2).
- S. de Jong (1993). “SIMPLS: an alternative approach to partial least squares regression.” Chemometrics and Intelligent Laboratory Systems 18(3).
- S. de Jong (1993). “PLS fits closer than PCR.” Journal of Chemometrics 7(6).
- I. E. Frank, J. H. Friedman (1993). “A statistical view of some chemometrics regression tools.” Technometrics 35(2).