Qu

transform

Builtin index · Statistics & ML

result = scaler.transform(newX) or model.transform(Xnew)

Input: newX · Output: result

What it is

Applies a fitted scaler Record scaler's stored parameters to a new matrix/vector/table newX with the same columns it was fitted on. Never refits, even if newX's own statistics differ.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = scaler.transform(newX) or model.transform(Xnew)
newX Record, matrix, or vectornot documented yet
result —
Returns a value the same shape as newX. For an lda, pls or ica model, model.transform(Xnew) projects Xnew onto the model's discriminant axes, X-scores or independent sources instead.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

split = train_test_split(X, y, test_size = 0.25, seed = 1)
scaler = fit_scaler(split.X_train, method = "standard")
print("training column means: {round(scaler.mean, 3)}")

Xtr = scaler.transform(split.X_train)
Xte = scaler.transform(split.X_test)
print("train columns after scaling: {round(mean(Xtr, axis = 0), 3)}")
print("test columns after scaling:  {round(mean(Xte, axis = 0), 3)}")
output
training column means: [-0.23, 0.011, 0]
train columns after scaling: [0, 0, 0]
test columns after scaling:  [0.428, 0.053, -0.046]

from statistics-ml

How it works

scaler.transform(newX) — applies the *fitted* parameters to newX (never re-fits on it). newX's feature-column count must match what the scaler was fit on.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.