ML Foundations
Understand min–max scaling of a constant feature
Inspect the fitted range and later values when a training feature is constant.

Evidence and testing
Review record: Tensor Almanac automated evidence gate (no independent human review). Example versions, recorded outputs and limitations appear below.
A constant training feature has no observed range
Min–max scaling learns a minimum and a range from the training data. When every training value is the same, the observed range is zero, so the usual normalization formula has a zero denominator. A constant training feature contains no observed variation in that sample. [1, 2]
For the default feature range and the finite fixture below, scikit-learn maps the constant training values to zero. This does not establish that later observations will also be constant, or that the feature is useless for every future dataset. [1]
Check the fitted transformation on later input
Run python examples/minmax_constant_feature.py. Both training values equal five, so the fixture uses a denominator of one for its zero-range case. The training values become zero; applying the same fitted transformation to later values five and seven produces zero and two.
The example implements this single-feature calculation in NumPy. A separate local scikit-learn MinMaxScaler check with default settings produced the same values. The later value is outside zero to one because the default transformer does not clip held-out inputs. [1]
Executed with local Python and NumPy; stdout and checksum are stored in private evidence.
import numpy as np
train = np.array([5.0, 5.0])
new = np.array([5.0, 7.0])
minimum = train.min()
span = train.max() - minimum
safe_span = 1.0 if span == 0 else span
train_scaled = (train - minimum) / safe_span
new_scaled = (new - minimum) / safe_span
assert np.array_equal(train_scaled, np.array([0.0, 0.0]))
assert np.array_equal(new_scaled, np.array([0.0, 2.0]))
print("training range:", float(span))
print("training transformed:", train_scaled.tolist())
print("new transformed:", new_scaled.tolist())
Recorded output
training range: 0.0 training transformed: [0.0, 0.0] new transformed: [0.0, 2.0]
References: [1]
Decide how to handle the feature
Fit transformations using the training data and reuse the fitted transformation for later samples. If retaining a bounded output is a requirement, review the scaler clipping option and its effects before turning it on. [1]
VarianceThreshold can identify features that are constant in the fitted sample. Whether to remove one is a modeling decision, especially when future values may differ. This small example uses a finite single feature, the default range and no missing values; it does not establish generalization performance. [1, 2]