Question bank
Pick an answer to see if you're right — with an explanation.
All topicsPythonSQL / MySQLData ScienceNumPyPandasMatplotlibMachine LearningDeep LearningArtificial IntelligenceLarge Language ModelsDjangoAPIsGit & GitHubPower BIExcelStatistics
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
Explanation: Resampling must happen only on the training data (ideally inside CV folds) or the evaluation is optimistic.
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
Explanation: Scaling all of X first uses validation rows to compute the mean and standard deviation, which inflates the scores.
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
Explanation: Each tree contributes less, so more trees are needed; the trade-off often improves generalisation.
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
Explanation: A more flexible model fits the training data more closely (lower bias) but reacts more to the particular sample (higher variance).
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
Explanation: Pickled models are version-sensitive and unpickling can execute code, so pin versions and trust the source.