0
0
MLOpsdevops~10 mins

Feature engineering pipelines in MLOps - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a simple feature pipeline step using scikit-learn.

MLOps
from sklearn.preprocessing import [1]

scaler = [1]()
Drag options to blanks, or click blank then click option'
AStandardScaler
BMinMaxScaler
CPCA
DOneHotEncoder
Attempts:
3 left
💡 Hint
Common Mistakes
Using PCA here instead of a scaler.
Choosing OneHotEncoder which is for categorical data, not scaling.
2fill in blank
medium

Complete the code to combine two feature transformers into a pipeline.

MLOps
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA

pipeline = Pipeline(steps=[('scaler', StandardScaler()), ('[1]', PCA(n_components=2))])
Drag options to blanks, or click blank then click option'
Apca
Btransformer
Creducer
Dencoder
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic names like 'transformer' which are less descriptive.
Using 'encoder' which is unrelated to PCA.
3fill in blank
hard

Fix the error in the pipeline code by completing the missing method call.

MLOps
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA

pipeline = Pipeline(steps=[('scaler', StandardScaler()), ('pca', PCA(n_components=2))])
X_transformed = pipeline.[1](X_train)
Drag options to blanks, or click blank then click option'
Atransform
Bfit
Cfit_transform
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' alone returns the pipeline itself, not transformed data.
Using 'predict' is for models, not transformers.
4fill in blank
hard

Fill both blanks to create a ColumnTransformer that applies scaling to numeric and encoding to categorical features.

MLOps
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import StandardScaler, OneHotEncoder

preprocessor = ColumnTransformer(transformers=[('num', [1], numeric_features), ('cat', [2], categorical_features)])
Drag options to blanks, or click blank then click option'
AStandardScaler
BOneHotEncoder
CPCA
DMinMaxScaler
Attempts:
3 left
💡 Hint
Common Mistakes
Using PCA for categorical data.
Mixing up scaler and encoder roles.
5fill in blank
hard

Fill all three blanks to build a pipeline that preprocesses data and fits a logistic regression model.

MLOps
from sklearn.pipeline import Pipeline
from sklearn.linear_model import LogisticRegression

pipeline = Pipeline(steps=[('preprocessor', [1]), ('classifier', LogisticRegression([2]=[3]))])
Drag options to blanks, or click blank then click option'
Apreprocessor
Bmax_iter
C100
DStandardScaler
Attempts:
3 left
💡 Hint
Common Mistakes
Passing scaler directly instead of the preprocessor pipeline.
Using wrong parameter names for LogisticRegression.