Foundations to Frontier
Tests
D. Classical Machine Learning › D7 Ensemble Methods

Random Subspace Method

The random subspace method (Ho, 1998) builds an ensemble by training each member on all the samples but only a random subset of the features, then averaging. It perturbs the feature space instead of the data, so it works with any base learner, including ones that bagging barely helps, such as k-nearest neighbours and linear discriminants. It is especially useful when there are many features relative to samples. This page covers the method, why feature subsets create diversity and fix ill-conditioned learners, how to choose the subspace size, and how it relates to random forests and random patches. In the exercises you rescue LDA in a p > n setting with subspace ensembles; then you compare subspace sizes and bagging for k-NN and LDA in 200 dimensions.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Each expert looks at a few gauges

Imagine diagnosing an engine from 200 sensor readings, of which only a handful matter. A nearest-neighbour model comparing all 200 readings is swamped by irrelevant noise. The random subspace method gives each ensemble member a random handful of sensors to look at. Many members miss the important ones, but the ones that catch them see far less noise, and the averaged vote finds the signal.

Random subspaces: give each model a few features
0.50.60.70.80.91subspace size d (log) →
5-NN on all 40 features 68.7% · ensemble of 40 on 10-feature subspaces 70.7%
Only 4 features carry signal. With many noise features, distances on all features are dominated by noise and one 5-NN struggles. Very small subspaces usually miss the informative features, so most members vote at random. Moderate subspaces (around 10–15 of 40) mix in a few informative features with less noise, and averaging 40 of them gains a few points. Very large ones are no different from a single model. The gain is modest, and with 150 test points each accuracy wobbles by about ±4 points, so read the shape of the curve, not single values. As p shrinks toward 4 the benefit disappears.
Why engineers care

High-dimensional, small-sample problems are common: spectra with thousands of wavelengths, hundreds of telemetry channels, few labelled faults. Random subspaces make distance-based and covariance-based learners usable there, parallelise trivially, and need no change to the base learner.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Random subspace members are trained on…
  2. 2. It helps most when features are…
  3. 3. In the demo, very small subspaces…

Level 1: Beginner

★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.

Subset arithmetic by hand

Do members see the signal? With p = 200 features of which k = 10 are informative, a random subset of d features contains on average d·k/p of them:

  • d = 10: 0.5 informative features on average. The chance of none is Π over i = 0..9 of (190 − i)/(200 − i) ≈ 0.59;
  • d = 50: 2.5 on average, and the chance of none drops below 6%.

Do all features get used? A feature is in at least one of B members with probability 1 − (1 − d/p)^B. For d = 10, p = 100 and B = 5: 1 − 0.9⁵ = 0.41. With B = 100 coverage is essentially complete.

Fixing a singular learner. LDA inverts the pooled covariance, a p × p matrix estimated from n samples, which is singular when p ≥ n − 2. On a d-feature subspace with d well below n it is invertible. An average of such LDAs works where full LDA fails (exercise 1: 0.49 for full LDA against 0.76 for the ensemble, with p = 100 and n = 60).

The steps in plain English:

  1. Choose the subspace size d (often p/2 for trees, smaller for k-NN or LDA in high dimension) and the number of members B.
  2. For each member, draw d features without replacement and train the base learner on all samples restricted to them.
  3. Predict by averaging the members’ probabilities (or by voting).
  4. Tune d on validation data. It trades how much signal a member sees against how much noise it sees.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Expected informative features in a random 50 of 200 (10 informative)?
  2. 2. Coverage 1 − (1 − d/p)^B for d/p = 0.1, B = 5?
  3. 3. Full LDA fails when…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

The method and its relatives

Algorithm (Ho, 1998). For b = 1..B: choose a feature set S_b of size d uniformly at random and fit h_b on (X[:, S_b], y). Predict with the average over b of h_b(x restricted to S_b). Ho used decision trees with d ≈ p/2 and found that subspace forests beat single trees and bagging on many datasets.

Why it creates diversity. Different feature sets force members to rely on different evidence, so errors decorrelate even when every member sees all samples. For k-NN, bootstrapping hardly changes neighbourhoods (k-NN is stable under resampling), but feature subsets change distances substantially.

Choosing d.

  • Too small: most members miss the informative features and are weak.
  • Too large: little diversity, and in high dimension each member is dominated by noise or ill-conditioned (LDA with d near n).
  • The optimum is usually intermediate (exercise 2: d = 50 of 200 for both k-NN and LDA).

Relatives.

Method samples per member features
Bagging bootstrap all
Random subspace all random subset per member
Random patches subsample random subset per member
Random forest bootstrap random subset per split
Rotation forest bootstrap PCA-rotated subsets
from sklearn.ensemble import BaggingClassifier
from sklearn.neighbors import KNeighborsClassifier
rsm = BaggingClassifier(KNeighborsClassifier(5), n_estimators=50, bootstrap=False,
                        max_features=0.25, bootstrap_features=False).fit(X, y)   # random subspaces
🐍 Exercise 1: rescuing LDA with random subspaces
Implement LDA (with optional ridge), a random-subspace ensemble of LDAs and its averaged prediction, plus the coverage probability; with p = 100 features and n = 60 samples, show that full LDA fails while the subspace ensemble works, and compare with ridge-regularised LDA.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Random patches combine…
  2. 2. Bagging k-NN helps little because k-NN is…
  3. 3. Random forests randomise features…

Level 3: Advanced

★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.

Theory

Diversity versus strength. As with forests, member strength rises with d and diversity falls. With k informative of p features, a member’s chance of seeing at least one informative feature is 1 − C(p − k, d)/C(p, d). This rises steeply with d, while noise per member rises linearly. For distance-based learners, the signal-to-noise ratio of distances is roughly k_S/d, where k_S is the number of informative features in the subspace, which favours moderate d.

Ill-conditioning. For LDA, the pooled covariance estimate needs n much larger than d to be well conditioned. Its smallest eigenvalues are badly underestimated when d/n is not small (Marchenko–Pastur). Exercise 2 saw LDA collapse to 0.81 at d = 100 = n, while d = 50 gave 0.915. Ridge (shrinkage) LDA is the competing fix and was slightly better in exercise 1 (0.79 against 0.76). Subspaces and shrinkage can be combined.

When subspaces fail. When the signal requires many features at once, as in additive effects spread over hundreds of features, small subspaces are uniformly weak. And when all features are informative and few, feature subsets just throw information away.

Interview questions.

  • How does the random subspace method differ from random forests? It fixes one feature subset per member, for any learner, whereas forests redraw features at every split of a tree.
  • What would you try first for k-NN in 500 dimensions with few informative features? Feature selection or metric learning if possible. Otherwise random-subspace k-NN ensembles with d tuned on validation, compared against bagging (which will barely help).
📝 Quick check (Level 3)
0/3 answered
  1. 1. LDA on d features is well conditioned when…
  2. 2. Subspaces fail when the signal needs…
  3. 3. A competing fix for singular LDA is…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Subspace size, k-NN and LDA in 200 dimensions

History.

  • Ho (1995) introduced random decision forests, and (1998) the random subspace method.
  • Bryll, Gutierrez-Osuna and Quek (2003) used attribute bagging for hand-gesture recognition.
  • Skurichina and Duin (2002) studied bagging, boosting and random subspaces for linear classifiers.
  • Louppe and Geurts (2012) introduced random patches.
  • Random subspace ensembles are standard for high-dimensional biomedical and spectral data.

Exercise 1.

  • With p = 100 and n = 60 the pooled covariance is singular: full LDA scored 0.488.
  • An ensemble of 100 LDAs on random 30-feature subspaces scored 0.760.
  • Ridge-regularised LDA, a different remedy, scored 0.790.

Exercise 2. Setup: p = 200, 10 informative features, n = 100, 50 members, 3 repetitions. The table shows test accuracy.

Base learner single (all features) bagging d = 10 d = 25 d = 50 d = 100
5-NN 0.828 0.836 0.807 0.844 0.901 0.890
LDA (ridge 10⁻³) 0.861 0.907 0.901 0.891 0.915 0.813
  • Moderate subspaces (d = 50) were best for both learners, by 5–7 points over a single model.
  • Bagging barely helped k-NN (+0.8 points), as stability theory predicts, but subspaces helped it by 7 points.
  • For LDA, bagging also helped, because its near-singular covariance makes it unstable. At d = 100 = n, LDA was ill-conditioned again and fell to 0.81.
  • d = 10 was too small for k-NN: members average only 0.5 informative features.
🐍 Exercise 2 (research): subspace size, bagging, k-NN and LDA
In 200 dimensions with 10 informative features and 100 samples, compare a single model, bagging and random-subspace ensembles (d in {10, 25, 50, 100}) for 5-NN and near-unregularised LDA (3 repetitions).

Random subspaces in AI, robotics and aerospace

  • Spectral classification (hyperspectral imagery, mass spectra) with thousands of bands and few labels.
  • Fault diagnosis from hundreds of telemetry channels with few labelled failures.
  • Sensor-failure robustness: members using different sensor subsets degrade gracefully when sensors drop out.
  • Biomedical microarray and EEG analysis in small-n, large-p settings.

References

  1. T. K. Ho (1998). “The random subspace method for constructing decision forests.” IEEE TPAMI 20(8).
  2. M. Skurichina, R. P. W. Duin (2002). “Bagging, boosting and the random subspace method for linear classifiers.” Pattern Analysis and Applications 5.
  3. R. Bryll, R. Gutierrez-Osuna, F. Quek (2003). “Attribute bagging.” Pattern Recognition 36(6).
  4. G. Louppe, P. Geurts (2012). “Ensembles on random patches.” ECML PKDD.
  5. L. I. Kuncheva (2014). Combining Pattern Classifiers, 2nd ed. Wiley.