Question bank

Pick an answer to see if you're right — with an explanation.

Machine LearningMedium
What is wrong with this workflow?
X_res, y_res = SMOTE().fit_resample(X, y)
X_tr, X_te, y_tr, y_te = train_test_split(X_res, y_res)
aSMOTE needs scaled data
btrain_test_split cannot handle arrays
cNothing, this is the standard approach
dSynthetic samples derived from test rows leak into training, inflating scores
Machine LearningHard
Why put the scaler inside the Pipeline instead of scaling X once beforehand?
model = Pipeline([('scale', StandardScaler()), ('clf', LogisticRegression())])
scores = cross_val_score(model, X, y, cv=5)
aEach fold fits the scaler on its training part only, so validation statistics do not leak into training
bStandardScaler cannot be called on its own
cIt makes cross_val_score run faster
dPipelines are required for logistic regression
Machine LearningHard
In gradient boosting, lowering `learning_rate` from 0.3 to 0.03 usually requires…
aMore boosting iterations to reach similar performance
bFewer iterations
cRemoving early stopping
dDeeper trees only
Machine LearningHard
As a model is made more flexible (deeper trees, more features), what usually happens?
aBoth bias and variance fall
bBias falls while variance rises
cBias rises while variance falls
dNeither changes
Machine LearningHard
You `joblib.dump` a fitted pipeline with scikit-learn 1.5 and load it in production. What is the safest practice?
aLoad it with any newer scikit-learn version
bConvert it to CSV first
cPin the same library versions in production and only load files from trusted sources
dRe-fit the pipeline on each request