Home
Subjects
Data Science Scikit-learn
Scikit-learn MCQs · Page 2
73 multiple choice questions with answers in Data Science.
⚔️
Challenge a friend on Scikit-learn
Same MCQs, timed, live leaderboard. Send the link on WhatsApp – no sign-up needed.
Create challenge
A
The rows are shuffled in place, so the original DataFrame's order is permanently changed
B
The same split is produced on repeated runs with the same inputs and library version
Correct answer
C
Every run is statistically independent, so no split pattern can ever repeat itself
D
The split is stratified automatically, keeping class proportions in both partitions
A
The precision-recall curve, which plots precision against recall at every threshold
B
The validation curve, which plots scores against one hyperparameter value at a time
C
The ROC curve, which plots the true positive rate against the false positive rate of the model
D
The learning curve, which plots training and validation scores against training-set size
Correct answer
A
step1 and step2, numbered in order
B
scaler and clf, fixed default aliases
C
It raises an error, because make_pipeline requires explicit names
D
standardscaler and logisticregression, the lowercased class names
Correct answer
A
It multiplies each row's contribution to the loss by its weight, without resampling the data
Correct answer
B
It sorts the rows so that heavier samples are fitted first and influence the coefficients more
C
It affects only predict, not the fitted coefficients, which are always learned unweighted
D
It physically replicates rows in proportion to their weights before the fit begins to run
A
max_features must equal the total number of features, so that every split always sees the whole feature set
B
The number of trees must be less than the number of samples, so that every tree sees fresh data
C
criterion must be set to entropy, because the Gini criterion cannot track the out-of-bag error
D
bootstrap=True, since out-of-bag samples exist only when each tree is trained on a bootstrap resample
Correct answer
A
It maps the unseen category to the first known category
B
It encodes that row as all zeros instead of raising an error
Correct answer
C
It adds a new column for the unseen category automatically
D
It raises an error, since ignore only downgrades the error to a warning
A
predict_proba returns normalised class probabilities summing to one, while decision_function returns unbounded signed distances to the decision boundary
Correct answer
B
decision_function returns probabilities between zero and one, while predict_proba returns raw margins, so the two names are swapped in most of the documentation
C
Both return probabilities, but predict_proba is only for regressors while decision_function is only for classifiers, so neither applies here
D
predict_proba is available on every estimator, while decision_function is not, which is why predict_proba is the preferred interface for scoring
A
It requires a separate hold-out set and raises NotFittedError when none is supplied alongside cv
B
The predictions are out-of-fold, but the same folds would also drive selection, so the resulting score is not a clean estimate
Correct answer
C
cross_val_predict refits on the full dataset first, so every prediction is in-sample and therefore over-optimistic
D
It returns one aggregate score per fold instead of predictions, so accuracy cannot be computed from its output
A
The estimator fitted on the first fold only
B
An ensemble average of all candidate estimators
C
It raises NotFittedError because refit must be False before predict
D
The best estimator refitted on the full training set, not just the winning fold
Correct answer
A
Because without centring the transformed features are always positive and therefore easier to interpret
B
Because with_mean=False switches to median and interquartile scaling instead of the ordinary mean
C
Centring would densify a sparse matrix, so scaling by the standard deviation alone preserves sparsity
Correct answer
D
Sparse matrices cannot be divided by a scalar, so only centring is available for them in practice
A
The training and test sets keep approximately the same class proportions as the full dataset
Correct answer
B
Only samples with non-missing labels are used, and rows with NaN labels are dropped
C
Each class appears exactly once in the test set, regardless of how many samples it has
D
The split is reproducible without setting random_state, because stratification fixes the seed
A
Pipeline refits the scaler on every validation fold to check stability across the splits
B
The pipeline scales the whole dataset once before splitting, which is equivalent and faster
C
During each fold, fit runs on the training part only and transform is applied to the held-out part
Correct answer
D
Pipeline disables scaling during cross-validation entirely, so the scaler only runs on the final fit
A
LeaveOneOut, giving one fold per sample and a very large number of separate fits
B
ShuffleSplit with a fixed random seed and a single random shuffle per call
C
StratifiedKFold with five splits, preserving class proportions in each fold
Correct answer
D
Plain KFold with ten splits, ignoring the class labels of the samples entirely
A
Test statistics leak into preprocessing, so the reported score is optimistically biased
Correct answer
B
No effect at all, because scaling cannot change model accuracy on any dataset
C
It causes the model to underfit, lowering the reported score well below the true value
D
The test set silently becomes the training set, so the model never sees genuinely new data
A
It forces the predicted probability threshold to 0.5
B
It weights classes inversely to their frequency
Correct answer
C
It duplicates minority rows until classes are equal
D
It removes majority rows before fitting
A
AUC needs ranked scores to sweep decision thresholds
Correct answer
B
Probability output is the only format it accepts numerically
C
Hard labels invert the meaning of the curve
D
Probabilities remove the effect of class imbalance
A
Whenever the model is a decision tree
B
Whenever the categories have no natural order
Correct answer
C
Whenever the categories are numeric identifiers
D
Whenever the column contains missing values
A
Uses the first combination that beats a fixed threshold
B
Trains and cross-validates every listed combination
Correct answer
C
Trains one model per parameter name, ignoring values
D
Samples random combinations until time runs out
A
It trains all steps in parallel to save wall-clock time
B
It automatically selects the best model among candidates
C
It caches the test set so it is scored only once
D
Cross-validation refits the steps on each training fold
Correct answer
A
A single score computed on the full dataset
B
Five fitted model objects returned for reuse
C
The best hyperparameter values found during the parameter search
D
Five scores, one per fold, from rotating validation splits
Correct answer
A
fit_transform returns a sparse matrix while transform does not
B
Fitting twice causes the scaler to forget its parameters
C
Fitting on test data leaks its statistics into training
Correct answer
D
transform is the only method that accepts two arguments
A
The maximum depth allowed for each tree
B
The number of features considered at each split
C
The fraction of samples drawn for bootstrapping
D
The number of decision trees in the ensemble
Correct answer
A
The average probability that the model assigned to the correct class
B
The area under the receiver operating curve
C
The mean squared difference between labels
D
The fraction of predictions that match the true labels
Correct answer
A
Replaces values with their rank within the column
B
Applies a logarithm to compress large values
C
Subtracts the mean and divides by the standard deviation
Correct answer
D
Rescales every value into the closed interval from zero to one
A
To scale features so they share a common range
B
To select the most important features from the data automatically
C
To merge several datasets into one training set
D
To hold out data for an unbiased estimate of generalisation
Correct answer