- Home
- Subjects
- Data Science
Data Science MCQs · Page 19
1,613 multiple choice questions with answers across 28 topics.
-
A
It merges the smallest class into the largest one before splitting
-
B
It warns, producing folds where that class is absent from some splits
Correct answer
-
C
It raises a ValueError, since each class needs at least n_splits rows
-
D
It reduces n_splits automatically to the size of the smallest class
-
A
As a mean weighted by each class's support, so large classes dominate
-
B
As a mean weighted by each class's predicted count rather than support
-
C
As the ratio of total true positives to total predicted positives
-
D
As an unweighted mean, so every class counts equally whatever its size
Correct answer
-
A
It sums to 1.0 only when whitening is enabled on the transform call
-
B
It sums to the number of features, since each ratio is left unnormalised
-
C
It always sums to under 1, because centring discards some variance
-
D
It sums to 1.0, because the retained components span the whole space
Correct answer
-
A
It marks an outlier that the algorithm reassigns on a second pass
-
B
It is noise, because no core point within eps counted it as a neighbour
Correct answer
-
C
It is the first cluster, since DBSCAN numbers its clusters from -1 up
-
D
It marks a border point, which belongs to more than one cluster at once
-
A
One divided by the number of features times the variance of the data X
Correct answer
-
B
One divided by the number of support vectors that the fit selects
-
C
One divided by the number of features alone, ignoring the spread of the data
-
D
One divided by the squared mean distance between all training points
-
A
Ordinary least squares, because the penalty term vanishes from the loss
Correct answer
-
B
A null model, because the coefficients are scaled down by alpha itself
-
C
Lasso, because a smaller alpha selects features more aggressively
-
D
A saturated model, since the coefficients grow without any bound at all
-
A
It applies weak regularisation, allowing the coefficients to grow freely
-
B
It disables regularisation entirely, matching unpenalised maximum likelihood
-
C
It caps the number of solver iterations, so the fit stops early in training
-
D
It applies strong regularisation, shrinking the coefficients toward zero
Correct answer
-
A
Columns prefixed with x_ and y_, aligned on the shared index labels
-
B
A dictionary of the two frames keyed by x and y instead of a frame
-
C
A MultiIndex whose outer level records which frame each row came from
Correct answer
-
D
A new column named keys holding x or y for each contributing row of both
-
A
Both must share a MultiIndex, since asof merges only on index keys
-
B
Both must contain no duplicate keys, because asof performs an inner join
-
C
Both must be sorted by the key column, which has to hold ordered data
Correct answer
-
D
Both must have identical dtypes for every shared column in the frames
-
A
It shifts the values one row down and leaves the index labels untouched
-
B
It resamples the series to daily frequency before shifting the values
-
C
It fills the vacated rows with the previous value instead of with NaN
-
D
It shifts the index labels by a day, keeping values with their labels
Correct answer
-
A
A running count within its own group, starting again at zero per group
Correct answer
-
B
A running count across the whole frame, ignoring the group boundaries
-
C
The total number of rows in its group, broadcast back to every member
-
D
A cumulative sum of those counts, so the last row holds the group size
-
A
NaN entries are replaced by whatever the function happens to return for a NaN
-
B
NaN entries pass through untouched instead of being sent to the function
Correct answer
-
C
NaN entries raise an error rather than being silently forwarded to func
-
D
The mapping dictionary's NaN key is used, overriding any default value
-
A
The interval from 0 up to 10, because right=False moves the closed edge
-
B
The interval from 10 up to 20, because right=False makes bins left-closed
Correct answer
-
C
The interval from 0 up to 10, since the default includes the right edge
-
D
A missing category, because the value 10 sits exactly on a bin boundary point
-
A
All three 9 values, because ties are always retained by nlargest
-
B
Two 9 values, chosen by their index labels rather than by position
-
C
Three rows followed by a truncation warning from pandas about ties
-
D
Two of the tied 9 values, ordered by their position in the Series
Correct answer
-
A
where keeps values where the condition holds; mask replaces them there
Correct answer
-
B
where replaces values where the condition holds; mask keeps them
-
C
where drops the rows failing the condition; mask keeps them and fills in
-
D
The two are aliases, and only their argument order differs from each other
-
A
The original shape, with the missing values dropped by the round trip
-
B
A transposed frame, because unstack reverses the axes rather than stack
-
C
A frame with one extra level, since stack keeps every level intact
-
D
The original shape, with the same missing values still in place there
Correct answer
-
A
The frame sorted by the year level, keeping only the first matching rows
-
B
The year level reset into an ordinary column of the same DataFrame
-
C
A grouped object that aggregates the values for 2021 by the other index level
-
D
A cross-section at one index level, with that level dropped from the result
Correct answer
-
A
NaN in the extracted column, because a non-match yields a missing value
Correct answer
-
B
An empty string, because extract returns the unmatched part of the input
-
C
The original value unchanged, since extract only rewrites matching rows
-
D
An error, because extract requires every value to match the pattern
-
A
It splits each string on commas into separate columns, one per element
-
B
It flattens the whole column into a single Series of concatenated list values
-
C
It expands the lists into new columns named tags_0, tags_1 and so on
-
D
It gives each list element its own row, repeating the other column values
Correct answer
-
A
tz_convert on the index, because it attaches a zone to a naive index
-
B
astype to a datetime64 value with the UTC unit, which attaches the zone
-
C
tz_localize(None), which labels the index as UTC without adding a zone
-
D
tz_localize on the index, because tz_convert needs an aware index first
Correct answer
-
A
Calling agg twice, since the second call renames the resulting columns
-
B
Named aggregation, with keywords mapping each name to a column and func
Correct answer
-
C
Passing a dictionary of column names to functions, then renaming afterwards
-
D
Passing a list of function names, which yields already-named columns
-
A
They are treated as unknown, so every NULL row survives in the resulting output
-
B
They abort the query, because set operators reject NULL values in any column
-
C
They are duplicated, since set operators never collapse duplicate NULLs
-
D
They are treated as equal, so the NULL row is removed from the difference
Correct answer
-
A
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, which also includes rows tied on day
Correct answer
-
B
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, counting only physical rows read
-
C
RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, which totals the whole partition
-
D
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING, a reverse running total by default
-
A
An error, because dividing two integers requires an explicit CAST in standard SQL
-
B
3, because integer division truncates; cast one operand to numeric to get 3.5
Correct answer
-
C
3.5, because SQL always performs division in floating point internally
-
D
4, because SQL rounds the exact quotient half up when both operands are ints
-
A
Every row whose email appears more than once in the table, one row per duplicate
-
B
One row per distinct email, including those that appear exactly once in users
-
C
One row per email, with the count replaced by the number of distinct duplicates
-
D
One row per duplicated email, with the number of occurrences in the count column
Correct answer