1. Home
  2. MCQs by exam
  3. PPSC IT
  4. Data Science

PPSC IT MCQs – Data Science · Page 5

231 multiple choice questions typical of the PPSC IT exam, with answers and explanations. Switch on practice mode to test yourself first.

Showing 101–125 of 231

A GridSearchCV object is fitted with refit=True. What does calling predict afterwards use?

  1. The estimator fitted on the first fold only
  2. An ensemble average of all candidate estimators
  3. It raises NotFittedError because refit must be False before predict
  4. The best estimator refitted on the full training set, not just the winning fold Correct answer
MCQSEXAM Read explanation

Why would you construct StandardScaler(with_mean=False)?

  1. Because without centring the transformed features are always positive and therefore easier to interpret
  2. Because with_mean=False switches to median and interquartile scaling instead of the ordinary mean
  3. Centring would densify a sparse matrix, so scaling by the standard deviation alone preserves sparsity Correct answer
  4. Sparse matrices cannot be divided by a scalar, so only centring is available for them in practice
MCQSEXAM Read explanation

What does train_test_split(X, y, stratify=y) guarantee?

  1. The training and test sets keep approximately the same class proportions as the full dataset Correct answer
  2. Only samples with non-missing labels are used, and rows with NaN labels are dropped
  3. Each class appears exactly once in the test set, regardless of how many samples it has
  4. The split is reproducible without setting random_state, because stratification fixes the seed
MCQSEXAM Read explanation

Why does putting StandardScaler and a classifier inside Pipeline prevent leakage during cross_val_score?

  1. Pipeline refits the scaler on every validation fold to check stability across the splits
  2. The pipeline scales the whole dataset once before splitting, which is equivalent and faster
  3. During each fold, fit runs on the training part only and transform is applied to the held-out part Correct answer
  4. Pipeline disables scaling during cross-validation entirely, so the scaler only runs on the final fit
MCQSEXAM Read explanation

A pipeline-free workflow calls scaler.fit_transform(X_test) before evaluating a model. What is the consequence?

  1. Test statistics leak into preprocessing, so the reported score is optimistically biased Correct answer
  2. No effect at all, because scaling cannot change model accuracy on any dataset
  3. It causes the model to underfit, lowering the reported score well below the true value
  4. The test set silently becomes the training set, so the model never sees genuinely new data
MCQSEXAM Read explanation

pd.concat([a, b], axis=1) is used on two frames whose indexes overlap only partially. What is the default result?

  1. Only labels present in both frames are kept, as an inner join on the index
  2. The frames are concatenated positionally and the index is ignored, so no alignment occurs
  3. The index union is used and missing labels produce NaN, as an outer join on the index Correct answer
  4. An error is raised because the indexes are not identical, and the frames must be reindexed
MCQSEXAM Read explanation

What caveat applies to df.copy(deep=True) for a column of dtype object holding Python lists?

  1. The data and index are copied, but the Python objects inside object columns are not recursively copied, so they remain shared Correct answer
  2. deep=True is not allowed for object dtype columns, because pandas cannot deep-copy arbitrary Python objects
  3. Every nested list is deep-copied, guaranteeing full independence, so mutating one frame never affects the contents of the other
  4. deep=True copies only the index and shares all of the column data, while deep=False copies the column arrays
MCQSEXAM Read explanation

What does converting a low-cardinality object column with astype('category') change?

  1. It converts every string to an interned string object, for faster hashing and lower memory use
  2. It stores integer codes plus a dictionary of categories, cutting memory and enabling ordered comparisons Correct answer
  3. It drops duplicate values from the column, keeping only the first occurrence of every distinct string value
  4. It permanently sorts the DataFrame by that column and rebuilds the row index in sorted order
MCQSEXAM Read explanation

What does pd.merge(left, right, how='outer', indicator=True) add to the result?

  1. A boolean column showing whether the join key was unique in both of the input frames
  2. It raises an error if any of the keys fail to match, instead of reporting them in the result
  3. It sorts the result by the join key automatically and resets the index of the output
  4. A _merge column whose values are left_only, right_only or both, showing each row's origin Correct answer
MCQSEXAM Read explanation

How does df.groupby('k')['x'].transform('mean') differ from .apply('mean')?

  1. Both return one row per group, differing only in the index name that the resulting object carries afterwards
  2. transform can only be used with user-defined functions, while apply also accepts built-in method strings
  3. transform returns a Series aligned to the original index with the same length, while apply returns one value per group Correct answer
  4. apply returns a column the same length as the input frame itself, while transform reduces the result to one row per group
MCQSEXAM Read explanation

df2 = df[df.a > 0]; df2['b'] = 1; raises SettingWithCopyWarning. Why?

  1. Because boolean indexing always returns a tuple of arrays, so assignment cannot tell which of the two arrays to modify in place here
  2. Because column b does not exist in df, so pandas must decide whether to create it on the copy or on the parent frame
  3. Boolean indexing returns a new object that may still reference the parent's data, so chained assignment has an ambiguous target Correct answer
  4. Because assigning a scalar to a new column is not allowed after filtering, and pandas raises a warning instead
MCQSEXAM Read explanation