Back to the lessonPreparing the printout…

Fundamental of Machine Learning · Module 1: Data Preparation and Model Foundations

Machine Learning Pipelines in Scikit-learn

[markdown] content available only on the platform

[markdown] content available only on the platform

Flashcards · Machine Learning Pipelines in Scikit-learn

Pipeline — scikit-learn object that chains preprocessing steps and a final model so they are fitted and applied in the correct order.

Pipeline([("scaler", StandardScaler()), ("model", RandomForestClassifier())])

pipe.fit() — Fits every preprocessing step on the training data, transforms it, then trains the final model.

pipe.fit(x_train, y_train)

pipe.predict() — Transforms new data with the already-fitted steps, then makes predictions; nothing is refitted.

y_pred = pipe.predict(x_test)

cross_val_score() — Evaluates a model on several train/validation folds and returns one score per fold.

cross_val_score(pipe, x_train, y_train, cv=5)

ColumnTransformer — Applies different transformers to different groups of columns and joins the results.

("num", StandardScaler(), ["age", "income"])

handle_unknown="ignore" — OneHotEncoder option that outputs all zeros for unseen categories instead of raising an error.

OneHotEncoder(handle_unknown="ignore")

Silent data leakage — Test or validation information influencing preprocessing with no error shown, so scores look better than reality.

Scaling the whole training set before cross-validation.

Fold — One of the parts the training data is split into during cross-validation.

cv=5 creates five folds.

Fundamental of Machine Learning · Machine Learning Pipelines in Scikit-learn · printed on November 21, 2026