Understand the idea
If every row records a temperature of 20 degrees, that column cannot explain why anything else differs: nothing about it varies, so nothing about it can line up with variation in your outcome.
Worse, many formulas divide by the spread. When the spread is exactly zero the arithmetic is undefined, and the result is either an error or a nonsense value like infinity or NaN.
It usually means something went wrong upstream: a filter left only one group, a sensor was stuck, a default value was never overwritten, or a column was imported as a constant label. Find out which before deleting it, because the cause often affects other columns too.
KernelStats names a constant predictor rather than quietly dropping it: linear regression stops with a message naming the column, and most other models show a warning on the result card. A method that silently accepts one will report a model that looks fine and is not.
A constant column, where every value is the same, has no variance and so carries no information for telling rows apart. When one predictor is an exact combination of others (perfect collinearity), a regression cannot find a unique answer, and software reports a singular matrix. A predictor that is constant, or almost constant, is sometimes called a degenerate predictor.
Practitioner explanation
In regression a constant column is perfectly collinear with the intercept, so the design matrix loses rank and the normal equations have no unique solution. Implementations diverge sharply here and that divergence is the real hazard: R's lm() reports the aliased coefficient as NA, while statsmodels' default pseudo-inverse solver and several scikit-learn estimators accept the column and return a fitted model with an arbitrary (minimum-norm or zero) coefficient, giving a confident output built on a singular system.
Related degeneracies behave the same way and deserve the same suspicion: near-zero variance (a column that is constant except for two or three rows), a factor level with a single observation, and a group whose response is constant, which makes a pooled or within-group variance zero and sends t or F to infinity. Standardization and PCA both divide by the standard deviation and fail identically.
KernelStats surfaces this in two ways. Linear Regression refuses the fit with an error naming the constant numeric predictor(s), because the design matrix is singular. Most other model engines (GLMs, ridge/lasso/elastic net, trees and ensembles, mixed models, Cox, discriminant analysis and others) run the governance stamp, which adds a zero_variance limitation to the card naming the column. Both are deliberately disclosures rather than silent drops, because the analyst needs to know the column was present and useless, not merely that it is absent from the output.
When to use it
Consider it when
Check for constant and near-constant columns during import and after any filter, subset, or join: those are the operations that create them.
Use caution when
Do not simply delete the column and continue. A column that should vary and does not is evidence of an upstream data problem that probably touched other columns too.
Alternatives
- Exploratory Data Analysis (EDA). Before modeling, to see per-column variability, distinct counts and missingness in one pass and catch constants early.
- Descriptive Summary. You want to confirm the standard deviation and distinct-value count of a suspect column directly.
Worked example
Scenario
A regression of yield on temperature, pressure and line_speed, run after the data were filtered to a single production line that always runs at one speed.
Result
line_speed is now constant. Linear Regression refuses the fit with a message naming line_speed as a constant (zero-variance) predictor; a model engine that runs the governance stamp, such as Ridge Regression, instead fits and adds a zero_variance limitation naming the column.
Interpretation
The filter, not the data, created the constant. Drop line_speed from the model for this subset and note that the analysis now describes one line only: the scope of the conclusion narrowed at the same moment the column went constant.
Common misconceptions
Misconception
A constant column is harmless: the model will just ignore it.
Correction
Some libraries do effectively ignore it, but others return NaN coefficients or an arbitrary fitted value from a singular system. 'Harmless' depends on the implementation, which is exactly why the condition is reported rather than assumed away.
Misconception
Zero variance and missing data are the same problem.
Correction
Missing data has values you did not observe; a constant column has values you did observe that never differ. The remedies are unrelated: imputation does nothing for a constant, and dropping rows does not create variation.
References
- NIST/SEMATECH e-Handbook of Statistical Methods, §4.4.4 multicollinearity and ill-conditioning in regression, NIST/SEMATECH (2012), §4.4.4.
