- Home
- MCQs by exam
- NTS
- Data Science
NTS MCQs – Data Science · Page 3
266 multiple choice questions typical of the NTS exam, with answers and explanations. Switch on practice mode to test yourself first.
-
A
LIMIT samples rows randomly unless a repeatable seed is supplied with the statement
-
B
Without ORDER BY no row order is guaranteed, so the plan may return any ten rows
Correct answer
-
C
LIMIT is applied before the WHERE clause, so different rows qualify on each run
-
D
The table's primary key is used implicitly, and keys are regenerated on each read
-
A
Only the city column, because DISTINCT applies to the first selected expression only
-
B
Only the country column, since the last expression in the list takes precedence
-
C
Both columns independently, producing the cross product of unique values
-
D
Whole (city, country) pairs, so a city may still appear once per distinct country
Correct answer
-
A
It forms implicit groups from every selected column of the query output
-
B
It filters the single implicit group, returning either one row or no rows at all
Correct answer
-
C
It is a syntax error, because HAVING always requires an explicit GROUP BY clause
-
D
It filters individual rows before aggregation, exactly as a WHERE clause would
-
A
1.0, because balanced weighting only rescales the intercept term of the model
-
B
0.1, because the minority class is down-weighted to match the majority count
-
C
5.0, computed as n_samples divided by the product of classes and positives
Correct answer
-
D
10.0, computed as the ratio of negatives to positives in the training data
-
A
Exactly 95 components, because an integer below 1 is read as a component count
-
B
Components that individually explain at least 95% of the total variance each
-
C
95% of the original columns, chosen by their correlation with the first component
-
D
The smallest number of components whose cumulative explained variance reaches 95%
Correct answer
-
A
Only numeric columns, since passthrough drops anything it cannot encode
-
B
Encoded columns followed by every unlisted column appended unchanged in order
Correct answer
-
C
Only the encoded columns, because remainder='passthrough' keeps no other column at all
-
D
The encoded columns plus a copy of the input frame, so all columns appear twice
-
A
pipeline.set_params(model.C=0.1), using dotted attribute notation for the step
-
B
pipeline.set_params('model__C'=0.1), passing the parameter name as a quoted string
-
C
pipeline.set_params(model__C=0.1), using the step name and a double underscore
Correct answer
-
D
pipeline.set_params(C=0.1), because parameters are flattened onto the pipeline itself
-
A
StratifiedKFold with 5 splits, which preserves each class ratio inside every fold
Correct answer
-
B
KFold with 5 splits and no shuffling, which keeps the original row ordering fully intact
-
C
LeaveOneOut, because grid search always maximises the number of fitted models
-
D
TimeSeriesSplit, because f1 scoring requires chronologically ordered folds here
-
A
The score is compared with the training mean, which recentres the decision boundary
-
B
The sign of the score decides the class, with positive scores mapped to classes_[1] here
Correct answer
-
C
The score is thresholded at 0.5, exactly mirroring a probability cut-off on a calibrated model
-
D
The class with the larger absolute score wins, regardless of the score's overall sign
-
A
It fills the column with zeros, because an undefined mean is replaced by zero
-
B
It raises a ValueError, since no statistic at all can be computed from an empty column
-
C
It keeps the column and fills it with NaN, preserving the missing-value marker
-
D
It drops the column from the transformed output and ignores it during transform
Correct answer
-
A
The number of clusters tested, since n_init is simply an alias for n_clusters in the API
-
B
The number of bootstrap samples used to estimate cluster stability scores
-
C
The number of independent initialisations, with the lowest-inertia run being kept
Correct answer
-
D
The number of iterations allowed inside a single Lloyd run before it stops
-
A
It imposes an arbitrary ordinal order, which the model then treats as numeric distance
Correct answer
-
B
It fails on columns that contain more than two distinct categories at once
-
C
It returns one-hot columns, which cause perfect multicollinearity in the design matrix
-
D
It only works on the target vector, so calling it on a feature column raises an error
-
A
It sets the number of trees to the core count, overriding n_estimators entirely
-
B
It spreads independent fits over all available cores, without changing the results
Correct answer
-
C
It repeats the fit once per available core and averages the resulting forests together
-
D
It disables parallel execution, because -1 means a single worker thread here
-
A
The scaler requires the test set to be a subset of the training rows it was fitted on
-
B
Fitting on the test set leaks its statistics into preprocessing and inflates scores
Correct answer
-
C
transform must be called before fit on the training set to establish the column order
-
D
fit_transform on the test set is slower, yet returns an identical result
-
A
The confusion matrix sum, which grows whenever accuracy is artificially high
-
B
R-squared, which measures how much variance the fraud labels explain overall
-
C
Balanced accuracy, which averages recall across both classes and lands near 0.50
Correct answer
-
D
Precision, which stays high because most of the predicted negatives are truly negative
-
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 @ prefix escapes the name, allowing identifiers that are not valid Python
-
B
The @ prefix resolves the name in the caller's scope instead of as a column label
Correct answer
-
C
The @ prefix marks the referenced name as a pandas Series, so query can broadcast it
-
D
The @ prefix disables parsing of the expression, passing it to Python's eval directly
-
A
It drops the grouping columns entirely, since apply only ever sees the remaining value columns
-
B
It raises an error, because apply callbacks returning DataFrames are no longer supported
-
C
It duplicates the keys as columns and as index levels, producing redundant result fields
-
D
It prepends the group keys to the result index, so include_groups=False changes the output
Correct answer
-
A
The whole column b is set to 1 for every row, since the mask is ignored here
-
B
Nothing changes in df, because the chained assignment writes to a temporary copy
Correct answer
-
C
Column b is updated for the matching rows, exactly as an equivalent .loc assignment would
-
D
A SettingWithCopyWarning is raised and the assignment is then silently applied
-
A
The last row of the frame only, because keep applies to the whole frame rather than rows
-
B
Both the first and last occurrences, since keep='last' keeps the boundary rows intact
-
C
The last occurrence of each email in the current row order, dropping the earlier ones
Correct answer
-
D
The first occurrence of each email address, because keep names the copy inspected
-
A
The two frames hold different row counts, which the validation step forbids
-
B
The key columns have different dtypes, so pandas cannot compare their values at all
-
C
The merge produced more columns than expected, exceeding the validation threshold
-
D
At least one side repeats a key value, so the join would produce duplicate rows
Correct answer
-
A
The cast truncates NaN to zero, raising a warning rather than an error
-
B
The fix is to cast to float16 first, because float16 supports missing values natively
-
C
int64 has no NaN representation, so the nullable Int64 dtype must be used instead
Correct answer
-
D
int64 holds NaN perfectly well, but the cast is refused because of an unrelated mismatch
-
A
The call groups by calendar month names, treating the strings as categorical data
-
B
An empty frame is returned, because no rows fall on the month-end timestamps
-
C
A TypeError about the index, because resample needs a DatetimeIndex on the axis
Correct answer
-
D
The string column is parsed automatically and the monthly totals are returned
-
A
1, 2, 2, 3, because dense ranking never leaves gaps after ties are collapsed
Correct answer
-
B
1, 2, 2, 4, because the next distinct value keeps its positional rank number
-
C
1, 2.5, 2.5, 4, because tied values receive the average of the positions they take
-
D
1, 1, 2, 3, because ties are ordered by their appearance and then renumbered
-
A
Because observed=True drops rows whose category does not appear among the group keys chosen
-
B
Because grouping a categorical converts it to an object column, losing category metadata
-
C
Because observed=True sorts the categories and then truncates the output index
-
D
Because the default expands every category combination, producing empty groups too
Correct answer