Detecting Out of Distribution Samples using Class Centered Residual Energy in the Discarded PCA Subspace with Weight Alignment
Authors: Shreen Gul, Mohamed Elmahallawy, Ardhendu Tripathy, Sanjay Madria
Abstract
Principal component analysis (PCA) has recently been adopted for out-of-distribution (OOD) detection, yet most existing methods focus on dominant, high-variance directions of the feature space. This energy-retaining perspective overlooks a crucial fact: discriminative signals separating in distribution (ID) and OOD samples often lie in low variance residual components that are typically discarded. Furthermore, prior PCA-based scores rely solely on feature geometry, limiting robustness under distributional shift. In this work, we revisit PCA for OOD detection from an uncertainty aware perspective. Specifically, we propose a residual-aware OOD detection framework that explicitly models the discarded subspace of a shared within-class PCA basis. By constructing a residual variation score, we capture deviations that are ignored by the leading principal components. To further enhance reliability, we introduce a complementary classifier-weight alignment score that measures the consistency between the selected class-centered residual and the corresponding classifier weight vector. This dual-signal design enables reliable detection even when OOD samples exhibit high energy in the dominant subspaces. Extensive experiments across convolutional and transformer backbones show consistent improvements over strong baselines in AUROC and FPR at 95