fit
Builtin index · Statistics & ML
result = pipe.fit(X, y)
Input: X, y · Output: result
What it is
Runs a pipeline Record pipe (from pipeline(...)) on an N-row feature matrix X and a length-N target vector y: applies every transform stage in order, then calls the final estimator stage.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = pipe.fit(X, y) | X Record, matrix, or vectornot documented yety Record, matrix, or vectornot documented yet | result Record | Returns a fitted pipeline Record whose .predict/.score replay the same transform stages before delegating to the fitted model inside. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
centre(X) := X - mean(X)
final(X, y) := ridge_model(X, y, 0.1)
pipe = pipeline("centre", "final")
fitted = pipe.fit(X, y)
print("pipeline R^2 {fitted.score(X, y):.4f}")
pipeline R^2 0.9992
from specialized
standardize_cols(M) := (M - mean(M)) ./ std(M)
final(A, b) := ridge_model(A, b, 0.1)
pipe = pipeline("standardize_cols", "final")
fitted = pipe.fit(split.X_train, split.y_train)
print("held-out R2: {round(fitted.score(split.X_test, split.y_test), 4)}")
held-out R2: 0.991
from statistics-ml
How it works
fit(pipelineSpec, X, y) — callable as pipe.fit(X, y). Runs every transform stage in order (each stage's output feeds the next), then calls the final stage with (transformed_X, y) and wraps whatever Model it returns — .predict/.score on the *fitted* pipeline replay the same transform stages before delegating to that wrapped model.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.