- Home
- MCQs by exam
- NTS
- Data Science
NTS MCQs – Data Science · Page 5
266 multiple choice questions typical of the NTS exam, with answers and explanations. Switch on practice mode to test yourself first.
-
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
An error, because the series is shorter than the window
-
B
NaN, because min_periods defaults to the window size
Correct answer
-
C
The mean of the available values, because partial windows are used
-
D
Zero, because missing window values are treated as zero
-
A
To skip that column entirely while reading, so it never appears in the frame
-
B
To speed up parsing by disabling the C engine and using the Python parser
-
C
To stop pandas inferring ZIP codes as integers and stripping leading zeros
Correct answer
-
D
To force every column in the file to be parsed as text rather than numbers
-
A
Relative frequencies excluding NaN, so the resulting proportions sum to less than one overall
-
B
Boolean flags indicating whether each value is missing, aligned to the original index
-
C
Absolute counts per value, excluding NaN, sorted in ascending order of frequency
-
D
Relative frequencies per distinct value, including NaN as its own category, summing to 1
Correct answer
-
A
Only labels present in both frames are kept, as an inner join on the index
-
B
The frames are concatenated positionally and the index is ignored, so no alignment occurs
-
C
The index union is used and missing labels produce NaN, as an outer join on the index
Correct answer
-
D
An error is raised because the indexes are not identical, and the frames must be reindexed
-
A
A NumPy array of the whole frame
-
B
A tuple of the row values in column order
-
C
A Series for each row, indexed by the column labels
Correct answer
-
D
A Series for each column, indexed by the row labels
-
A
The data and index are copied, but the Python objects inside object columns are not recursively copied, so they remain shared
Correct answer
-
B
deep=True is not allowed for object dtype columns, because pandas cannot deep-copy arbitrary Python objects
-
C
Every nested list is deep-copied, guaranteeing full independence, so mutating one frame never affects the contents of the other
-
D
deep=True copies only the index and shares all of the column data, while deep=False copies the column arrays
-
A
Columns containing at least three non-missing values
-
B
Rows containing at least three non-missing values
Correct answer
-
C
Rows containing fewer than three missing values
-
D
Rows containing exactly three non-missing values
-
A
res.droplevel('year') returns a Series indexed by month only
Correct answer
-
B
res.reset_index(level='year') removes the level without adding a column
-
C
res.drop('year') drops the level from the index
-
D
res.swaplevel() removes the level entirely
-
A
It converts the bad entries to zero
-
B
It replaces them with NaN and returns a numeric dtype column
Correct answer
-
C
It leaves the column as object and keeps the original strings
-
D
It raises a ValueError listing the offending values
-
A
It converts every string to an interned string object, for faster hashing and lower memory use
-
B
It stores integer codes plus a dictionary of categories, cutting memory and enabling ordered comparisons
Correct answer
-
C
It drops duplicate values from the column, keeping only the first occurrence of every distinct string value
-
D
It permanently sorts the DataFrame by that column and rebuilds the row index in sorted order
-
A
A boolean column showing whether the join key was unique in both of the input frames
-
B
It raises an error if any of the keys fail to match, instead of reporting them in the result
-
C
It sorts the result by the join key automatically and resets the index of the output
-
D
A _merge column whose values are left_only, right_only or both, showing each row's origin
Correct answer
-
A
Both return one row per group, differing only in the index name that the resulting object carries afterwards
-
B
transform can only be used with user-defined functions, while apply also accepts built-in method strings
-
C
transform returns a Series aligned to the original index with the same length, while apply returns one value per group
Correct answer
-
D
apply returns a column the same length as the input frame itself, while transform reduces the result to one row per group
-
A
loc returns rows 0, 1 and 2 inclusive, while iloc returns rows 0 and 1 only
Correct answer
-
B
Both return rows 0, 1 and 2
-
C
loc returns rows 0 and 1, while iloc returns 0, 1 and 2
-
D
Both return rows 0 and 1, because slices always exclude the endpoint
-
A
Because boolean indexing always returns a tuple of arrays, so assignment cannot tell which of the two arrays to modify in place here
-
B
Because column b does not exist in df, so pandas must decide whether to create it on the copy or on the parent frame
-
C
Boolean indexing returns a new object that may still reference the parent's data, so chained assignment has an ambiguous target
Correct answer
-
D
Because assigning a scalar to a new column is not allowed after filtering, and pandas raises a warning instead
-
A
93.33, because the denominator includes the NULL row
-
B
NULL, because any NULL makes the average unknown
-
C
90, because the NULL row is ignored in both parts
Correct answer
-
D
60, because NULL is counted as zero
-
A
Whether the subquery returns exactly one row
-
B
Whether the orders table contains a column literally named 1
-
C
Whether every customer has the same order count
-
D
Whether at least one matching order exists per customer
Correct answer
-
A
UNION sorts the output; UNION ALL reverses the sort
-
B
UNION removes duplicate rows; UNION ALL keeps every row
Correct answer
-
C
UNION keeps duplicates; UNION ALL removes them
-
D
UNION works on columns; UNION ALL only on single values
-
A
NULL is a reserved keyword and causes a syntax error
-
B
The column must be cast to text before comparison
-
C
A comparison with NULL is unknown, never true
Correct answer
-
D
NULL is treated as zero in comparisons
-
A
NULL, because the first argument is NULL
-
B
the last argument, unknown
-
C
a comma-separated list of all its arguments
-
D
the first non-NULL argument, a@b.com
Correct answer