Unit 1 - Practice Quiz

CSE274 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 Which of the following is an example of Nominal categorical data?

Types of data Easy
A. Customer satisfaction rating (Low, Medium, High)
B. Size of a T-shirt (Small, Medium, Large)
C. Educational level (High School, Bachelor's, Master's)
D. Colors of a car (Red, Blue, Green)

2 The number of students in a classroom is an example of what type of data?

Types of data Easy
A. Nominal categorical data
B. Ordinal categorical data
C. Discrete numerical data
D. Continuous numerical data

3 What is the primary purpose of data pre-processing in machine learning?

Data pre-processing Easy
A. To select the best machine learning algorithm
B. To visualize the final results of a model
C. To transform raw data into a clean and suitable format for a model
D. To train the machine learning model

4 Which of the following is NOT a typical data pre-processing step?

Data pre-processing Easy
A. Model evaluation and deployment
B. Handling missing values
C. Feature scaling
D. Encoding categorical variables

5 What is data leakage in machine learning?

data leakage concept Easy
A. When data is lost due to a hardware failure
B. When the dataset is too small to train a model
C. When information from outside the training dataset is used to create the model
D. When the model's accuracy is too low

6 To prevent data leakage, when should you split your data into training and testing sets?

data leakage concept Easy
A. It does not matter when you split the data
B. Before performing any pre-processing like scaling or imputation
C. After training the model
D. After performing feature scaling on the entire dataset

7 The technique of replacing missing values with a substitute value, like the mean or median, is called:

handling missing values Easy
A. Normalization
B. Binning
C. Imputation
D. Deletion

8 Which imputation method is most suitable for a numerical feature with significant outliers?

handling missing values Easy
A. Mode imputation
B. Zero imputation
C. Median imputation
D. Mean imputation

9 What is the simplest strategy for handling rows with missing values?

handling missing values Easy
A. Using a predictive model to estimate them
B. Deleting the rows
C. Replacing them with the mean
D. Replacing them with the mode

10 What is an outlier in a dataset?

outliers handling Easy
A. The average value of a feature
B. A data point that is missing a value
C. A categorical data point
D. A data point that is significantly different from other data points

11 Why is it often important to handle outliers?

outliers handling Easy
A. They can skew statistical measures and negatively affect model performance
B. They always represent incorrect data entry
C. They help improve the accuracy of all models
D. They make the dataset larger

12 Which encoding technique converts a categorical feature with N unique categories into N new binary features?

handling categorical data Easy
A. Label Encoding
B. Target Encoding
C. One-Hot Encoding
D. Ordinal Encoding

13 When would Label Encoding be an appropriate choice over One-Hot Encoding?

handling categorical data Easy
A. When the number of categories is very small (e.g., 2)
B. When the categorical variable is nominal
C. When the categorical variable is ordinal
D. When using tree-based models, always

14 What is the primary goal of feature scaling?

scaling and normalization Easy
A. To handle missing values
B. To bring all features to a similar scale or range
C. To remove outliers from the data
D. To encode categorical data

15 Min-Max Scaling typically scales the data to which of the following ranges?

scaling and normalization Easy
A. [-1, 1]
B. [0, 100]
C. [0, 1]
D. Mean of 0 and Standard Deviation of 1

16 Which technique transforms features to have a mean of 0 and a standard deviation of 1?

scaling and normalization Easy
A. Min-Max Scaling
B. One-Hot Encoding
C. Robust Scaling
D. Standardization (Z-score Normalization)

17 What does 'class imbalance' refer to in a classification problem?

class imbalance handling Easy
A. When the number of observations per class is not equally distributed
B. When the dataset contains many outliers
C. When features are not on the same scale
D. When there are too many categorical features

18 Which technique involves creating new synthetic data points in the minority class to balance a dataset?

class imbalance handling Easy
A. Oversampling (e.g., SMOTE)
B. Feature Scaling
C. Undersampling
D. Principal Component Analysis (PCA)

19 The Interquartile Range (IQR) method is commonly used for what purpose?

outliers handling Easy
A. To scale numerical data
B. To handle missing values
C. To encode categorical data
D. To identify potential outliers

20 What is the primary disadvantage of One-Hot Encoding?

handling categorical data Easy
A. It only works for numerical data
B. It implies an incorrect order among categories
C. It can lead to a very high number of features (curse of dimensionality)
D. It cannot handle more than two categories

21 You are working with a dataset containing a feature for 'Annual Income' which has a right-skewed distribution and several missing values. Which imputation method would be the most robust and appropriate choice to fill in the missing data?

Handling missing values Medium
A. Mean imputation
B. Dropping all rows with missing values
C. Median imputation
D. Mode imputation

22 A data scientist is building a model to predict customer churn. Before splitting the data into training and test sets, they apply StandardScaler to the entire dataset. Why is this a problematic approach?

Data leakage concept Medium
A. It is computationally inefficient to scale the entire dataset at once.
B. It causes data leakage because information from the test set (its mean and variance) is used to transform the training set.
C. StandardScaler cannot be applied before splitting the data.
D. It will permanently alter the original data, making it impossible to interpret the model's coefficients.

23 You are preparing data for a linear regression model. A nominal categorical feature, 'Country', has 5 unique values. Why is One-Hot Encoding preferred over Label Encoding in this scenario?

Handling categorical data Medium
A. One-Hot Encoding preserves the original 'Country' column in the dataset.
B. Label Encoding would introduce an arbitrary ordinal relationship (e.g., 1 < 2 < 3) that the linear model might misinterpret as a meaningful ranking.
C. Label Encoding would create a large number of new features, leading to dimensionality issues.
D. One-Hot Encoding is computationally faster for linear models.

24 You have a dataset with features on vastly different scales, and some of these features contain significant outliers. You need to prepare the data for an SVM model. Which scaling technique would be the most appropriate?

Scaling and normalization Medium
A. StandardScaler
B. MinMaxScaler
C. Normalizer
D. RobustScaler

25 When applying the Synthetic Minority Over-sampling Technique (SMOTE), what is the correct procedure to avoid data leakage and get a reliable estimate of model performance?

Class imbalance handling Medium
A. Apply SMOTE to the entire dataset before performing a train-test split.
B. Apply SMOTE to the test set only to ensure it is balanced.
C. Perform the train-test split first, and then apply SMOTE only to the training data.
D. Apply SMOTE to both the training and test data independently after the split.

26 You are analyzing a feature that is not normally distributed. Which method is generally more reliable for identifying outliers in this case?

Outliers handling Medium
A. Removing the top and bottom 1% of the data, regardless of distribution.
B. Using the Interquartile Range (IQR) method.
C. Using the Z-score with a threshold of 3.
D. Visual inspection using a bar chart.

27 A dataset contains a feature 'Product_Rating' with possible values: 'Poor', 'Average', 'Good', 'Excellent'. Which data type best describes this feature and why?

Types of data Medium
A. Ratio, because there is a true zero point in the ratings.
B. Ordinal, because the categories have a clear, meaningful order.
C. Nominal, because the values are distinct categories.
D. Interval, because the difference between 'Good' and 'Average' is quantifiable.

28 In a competition to predict if a patient has a certain disease, a feature treatment_administered is found to be highly predictive. However, this treatment is only administered after a diagnosis is confirmed. Including this feature in the model is an example of what?

Data leakage concept Medium
A. Outlier-driven correlation
B. Multicollinearity
C. The curse of dimensionality
D. Target leakage

29 You are dealing with a high-cardinality categorical feature like 'UserID', which has thousands of unique values. Applying One-Hot Encoding is infeasible due to the massive number of new features it would create. Which of the following is a viable alternative strategy?

Handling categorical data Medium
A. Label Encoding, as it only creates one new feature.
B. Binary Encoding, which creates fewer columns than One-Hot Encoding by using binary representations.
C. Dropping the feature, as high-cardinality features are never useful.
D. Converting the feature to an integer and using it directly in a linear model.

30 For which of the following machine learning algorithms is feature scaling generally NOT required for the model to perform well?

Scaling and normalization Medium
A. Principal Component Analysis (PCA)
B. Random Forest
C. K-Nearest Neighbors (KNN)
D. Support Vector Machines (SVM) with an RBF kernel

31 You observe that missing values in a 'Salary' column occur more frequently for participants who did not report their 'Level of Education'. This situation, where the probability of a value being missing depends on another observed feature, is known as:

Handling missing values Medium
A. Missing Not At Random (MNAR)
B. Systematically Missing Data (SMD)
C. Missing Completely At Random (MCAR)
D. Missing At Random (MAR)

32 What is the primary mechanism by which the Synthetic Minority Over-sampling Technique (SMOTE) works?

Class imbalance handling Medium
A. It removes majority class samples that are close to minority class samples.
B. It creates new, synthetic minority class samples by interpolating between existing minority samples and their nearest neighbors.
C. It duplicates existing minority class samples at random.
D. It assigns higher weights to the minority class samples during model training.

33 Instead of removing outliers from a 'house_price' feature, a data scientist applies a log transformation (). What is the primary benefit of this approach?

Outliers handling Medium
A. It guarantees that the transformed feature will have a mean of 0 and a standard deviation of 1.
B. It pulls in the high-value outliers, reducing the skewness of the distribution and making it more symmetric.
C. It converts the feature into a categorical variable.
D. It completely removes the influence of the outliers on the model.

34 To ensure a robust and generalizable machine learning model, what is the correct order of these common pre-processing steps?

Data pre-processing Medium
A. 1. Impute missing values, 2. Split data into train/test sets, 3. Scale features
B. 1. Split data into train/test sets, 2. Scale features on the entire dataset, 3. Train the model
C. 1. Split data into train/test sets, 2. Scale features on the training set, 3. Apply the same scaling to the test set
D. 1. Scale features, 2. Impute missing values, 3. Split data into train/test sets

35 You are implementing Target Encoding for a categorical feature. What is a common technique to mitigate the risk of overfitting, especially for categories with few samples?

Handling categorical data Medium
A. Removing all categories that appear less than 10 times in the dataset.
B. Using the median of the target variable instead of the mean for encoding.
C. Using One-Hot Encoding as a backup for rare categories.
D. Applying a smoothing or credibility factor, which blends the category's mean with the global mean of the target.

36 What is the primary difference in the output of StandardScaler versus MinMaxScaler?

Scaling and normalization Medium
A. MinMaxScaler removes outliers, while StandardScaler does not.
B. StandardScaler transforms data to have a mean of 0 and a standard deviation of 1, while MinMaxScaler scales data to a fixed range, typically [0, 1].
C. StandardScaler requires the data to be normally distributed, while MinMaxScaler does not.
D. MinMaxScaler is a linear transformation, while StandardScaler is non-linear.

37 You are building a time-series forecasting model and have missing values. Simple mean or median imputation is not ideal. Which of the following would be a more suitable approach for this type of data?

Handling missing values Medium
A. Last Observation Carried Forward (LOCF) or interpolation.
B. Replacing missing values with a constant like -999.
C. K-Nearest Neighbors (KNN) imputation.
D. Dropping the time steps with missing data.

38 You are working on a credit card fraud detection project where fraud cases (positive class) are only 0.1% of the data. You train a model and achieve 99.9% accuracy. Why is accuracy a misleading metric in this context?

Class imbalance handling Medium
A. The model might be achieving high accuracy simply by predicting 'not fraud' for every single transaction.
B. Accuracy is computationally expensive to calculate on imbalanced datasets.
C. Accuracy can only be used for models that output probabilities.
D. The dataset is too small for accuracy to be a stable metric.

39 A feature in your dataset is 'postal_code'. While it is numerical, why is it incorrect to treat it as a continuous or ratio variable in a machine learning model?

Types of data Medium
A. Because postal codes are always integers and models require floating-point numbers.
B. Because postal codes have a true zero, making them ratio data by definition.
C. Because the numerical difference between two postal codes (e.g., 90210 vs 90211) is not a meaningful measure of distance or magnitude.
D. Because postal codes often contain missing values that must be imputed first.

40 Which of the following models is inherently more robust to outliers in the feature space, often requiring less stringent outlier pre-processing?

Outliers handling Medium
A. Linear Regression
B. Decision Tree based models (e.g., Random Forest)
C. K-Means Clustering
D. Support Vector Machines (SVM)

41 You are building a credit default model. You engineer a new feature z_score_income_by_profession by calculating the Z-score of each individual's income relative to the mean and standard deviation of income within their stated profession. You calculate these means and standard deviations using the entire dataset and then perform a 5-fold cross-validation. Why is this approach a form of data leakage?

data leakage concept Hard
A. Using profession as a grouping variable introduces societal biases into the model.
B. The mean and standard deviation for a profession are calculated using data from all 5 folds, so information from the validation fold 'leaks' into the feature creation for the training folds.
C. This is not data leakage; it is a valid form of feature engineering known as target-unaware group-wise normalization.
D. Z-score transformation is a form of scaling and should only be applied after the model has been trained.

42 You are working with a high-cardinality categorical feature 'user_id' (over 1 million unique IDs). You choose to use Target Encoding to convert it into a numerical feature for a gradient boosting model. What is the most critical step to prevent severe overfitting and data leakage when using this technique?

handling categorical data Hard
A. Using One-Hot Encoding instead, as it is immune to overfitting.
B. Applying a smoothing factor or a Bayesian averaging approach, especially for categories with few samples.
C. Hashing the 'user_id' feature before applying the target encoding.
D. Normalizing the encoded feature using StandardScaler after the transformation.

43 Consider a dataset where missing values in a feature 'serum_level' are suspected to be Missing Not At Random (MNAR). Specifically, patients with very high or very low serum levels are less likely to have their values recorded. In this scenario, why would MICE (Multivariate Imputation by Chained Equations) likely produce biased estimates if used naively?

handling missing values Hard
A. Because MICE requires the data to be normally distributed, which is unlikely for 'serum_level'.
B. Because MICE's underlying assumption is that data is Missing at Random (MAR) or Missing Completely at Random (MCAR), and it cannot model the mechanism causing the missingness itself.
C. Because MICE can only handle numerical data and 'serum_level' might be stored as a string.
D. Because MICE is a deterministic method and will always impute the same value for a given pattern, ignoring the inherent uncertainty.

44 You are using SMOTE (Synthetic Minority Oversampling TEchnique) to handle a severely imbalanced dataset. A colleague warns you that SMOTE can be detrimental when the minority class is very noisy and overlaps significantly with the majority class. What is the primary reason for this warning?

class imbalance handling Hard
A. SMOTE will change the distribution of the majority class, leading to information loss.
B. SMOTE may generate synthetic samples in the overlapping region, effectively blurring the decision boundary and making class separation harder.
C. SMOTE is computationally too expensive for datasets with significant class overlap.
D. SMOTE only works by duplicating existing minority samples, not creating new ones.

45 You are preparing a dataset with several features for a Support Vector Machine (SVM) with an RBF kernel. One feature, 'user_age', ranges from 18-90, while another, 'account_balance', ranges from -5,000 to 2,000,000. Both features contain significant outliers. Which scaling method is most appropriate and why?

scaling and normalization Hard
A. StandardScaler, because it centers the data at zero, which is a strict requirement for SVMs.
B. MinMaxScaler, because it scales data to a fixed range [0, 1], which guarantees the fastest convergence for the SVM algorithm.
C. RobustScaler, because it uses the interquartile range (IQR) to scale, making it insensitive to the influence of extreme outliers.
D. No scaling is needed, as tree-based kernels like RBF are immune to feature scale.

46 Instead of removing outliers, a data scientist decides to use Winsorization at the 98th percentile for a right-skewed feature. What is a key theoretical advantage of this method over simply capping the values at a fixed threshold (e.g., a domain-knowledge-based maximum)?

outliers handling Hard
A. Winsorization is a non-parametric method, while capping at a fixed threshold is parametric.
B. Winsorization pulls outliers towards the tail of the distribution, rather than clustering them at an arbitrary point, which can better preserve the feature's variance structure.
C. Winsorization is guaranteed to improve the performance of any linear model.
D. Winsorization guarantees that the feature will have a normal distribution after transformation.

47 In a time-series forecasting problem, you create features like a 7-day rolling average of sales. For a given day t, you calculate this average using data from days t-3 to t+3. You then use this feature to predict sales on day t. This is a classic example of data leakage. What is the correct way to engineer this feature?

data leakage concept Hard
A. Calculate the rolling average over the entire dataset to get a stable global baseline.
B. Use a 'centered' window but with a much larger window size, such as 30 days, to smooth out the noise.
C. Use a 'trailing' or 'lagged' window, calculating the average for day t using data from days t-7 to t-1.
D. Apply a Box-Cox transformation to the sales data before calculating the rolling average.

48 You are comparing One-Hot Encoding (OHE) and Dummy Coding for a categorical feature with 5 categories (A, B, C, D, E) for a multiple linear regression model. What is the primary statistical advantage of using Dummy Coding (which creates k-1 new features) over OHE (which creates k features) in this context?

handling categorical data Hard
A. It automatically assigns a baseline category that has the highest frequency, improving model accuracy.
B. It avoids the 'dummy variable trap' (perfect multicollinearity), which can make the model's coefficient estimates unstable and uninterpretable.
C. It preserves the ordinal nature of the categories, which OHE fails to do.
D. It is more computationally efficient because it generates fewer columns.

49 You are training a model on an imbalanced dataset and decide to use ADASYN (Adaptive Synthetic Sampling) instead of SMOTE. In which scenario would ADASYN be theoretically superior to SMOTE?

class imbalance handling Hard
A. When the dataset is extremely large, as ADASYN is computationally simpler than SMOTE.
B. When the feature space has a mix of categorical and numerical features.
C. When the minority class samples that are harder to learn (i.e., those with more majority class neighbors) should be prioritized for synthetic sample generation.
D. When the goal is to generate synthetic samples that are exact duplicates of the original minority samples.

50 A dataset contains features with drastically different distributions (e.g., one is uniform, one is bimodal, one is heavily skewed). You want to use a method that forces all features to follow a uniform or normal distribution. Which pre-processing technique would achieve this, and what is its primary use case?

scaling and normalization Hard
A. StandardScaler, used to center data around a mean of 0 and standard deviation of 1.
B. Normalizer (per-sample), used to scale samples to have unit norm, which is required for text classification.
C. QuantileTransformer, used to handle non-Gaussian distributed features and reduce the impact of outliers for distance-based models.
D. PowerTransformer with the 'box-cox' method, used exclusively for positive, skewed data to make it linear.

51 You have a longitudinal dataset tracking patient measurements over time. The 'blood_pressure' feature has missing values. A simple approach is to use LOCF (Last Observation Carried Forward). What is the most significant statistical risk associated with this imputation method in time-series analysis?

handling missing values Hard
A. It can only be applied if the first observation in the series is not missing.
B. It artificially reduces the variance of the feature and creates spurious temporal correlations, potentially leading to an underestimation of confidence intervals.
C. It is computationally intensive for long time series.
D. It introduces a systematic bias by always imputing values that are lower than the true mean.

52 You are using the Isolation Forest algorithm for outlier detection. The algorithm works by building an ensemble of 'isolation trees' and identifies outliers as points that have a short average path length from the root node. Why is this method particularly effective for large, high-dimensional datasets compared to distance-based methods like DBSCAN or Local Outlier Factor (LOF)?

outliers handling Hard
A. Isolation Forest requires the data to be scaled and normalized, which is a simpler pre-processing step than the parameter tuning required for DBSCAN.
B. Isolation Forest can only detect global outliers, not local ones, which simplifies the problem in high dimensions.
C. Isolation Forest is a supervised algorithm that learns from a small set of labeled outliers, making it more accurate.
D. Isolation Forest does not rely on distance calculations, which suffer from the 'curse of dimensionality' where distances between all points become almost equal.

53 A feature in your dataset is 'customer_satisfaction_rating' with values [1, 2, 3, 4, 5], representing 'Very Unsatisfied' to 'Very Satisfied'. A colleague treats this feature as a continuous numerical variable and applies StandardScaler. What is the primary theoretical flaw in this approach?

Types of data Hard
A. StandardScaler cannot handle integer data; it requires floating-point inputs.
B. The data is categorical, and One-Hot Encoding should have been used.
C. The data is ordinal, not interval or ratio. StandardScaler assumes mathematical operations like mean and standard deviation are meaningful, but the 'distance' between 1 and 2 may not be the same as between 4 and 5.
D. The range is too small (1-5), and scaling will have no significant effect on any model.

54 You are designing a data pre-processing pipeline for a logistic regression model. The pipeline must include missing value imputation (using the mean), one-hot encoding for a categorical feature, and feature scaling using StandardScaler. What is the correct order of these operations, and why is any other order incorrect?

Data pre-processing Hard
A. Imputation -> One-Hot Encoding -> Scaling. Encoding before imputation would be complex, and scaling before encoding would ignore the binary nature of the new columns.
B. The order does not matter as all three operations are linear transformations.
C. One-Hot Encoding -> Imputation -> Scaling. This is the most efficient order as it allows for parallel processing.
D. Scaling -> Imputation -> One-Hot Encoding. Scaling first ensures that the imputation value (the mean) is calculated on the scaled data.

55 When would using Hash Encoding be a clearly superior choice over One-Hot Encoding (OHE) for a categorical feature?

handling categorical data Hard
A. When training a linear regression model, as hash collisions have a regularizing effect similar to L2 regularization.
B. When the categorical feature has a clear ordinal relationship that must be preserved.
C. For any feature with fewer than 10 categories, as it is more computationally efficient.
D. In an online learning environment with a very high-cardinality feature where new categories appear frequently and memory is a major constraint.

56 You are working on a fraud detection problem. Instead of using a data-level technique like SMOTE or ADASYN, you opt for an algorithmic-level approach by adjusting the class_weight parameter in your logistic regression model. How does setting class_weight='balanced' typically affect the model's decision-making process?

class imbalance handling Hard
A. It changes the optimization algorithm from gradient descent to a weighted least squares method.
B. It internally resamples the dataset to be balanced before each training epoch.
C. It adds a regularization term to the loss function that is proportional to the class imbalance ratio.
D. It increases the penalty for misclassifying the minority class by a factor inversely proportional to its frequency, forcing the decision boundary to shift towards the majority class.

57 When using KNNImputer, what is a significant potential risk if the feature space is high-dimensional and features are not scaled properly before imputation?

handling missing values Hard
A. The curse of dimensionality will cause all nearest-neighbor distances to converge to zero, preventing the algorithm from finding any neighbors.
B. The imputer will default to mean imputation if the number of dimensions exceeds a certain threshold (typically 100).
C. The algorithm's time complexity will increase from to , making it unusable.
D. The distance metric will be dominated by features with large scales, causing the 'nearest neighbors' to be chosen based on only a few features, leading to irrelevant imputations.

58 You have a very sparse dataset (many zero values), common in text analysis (e.g., TF-IDF vectors) or transaction data. You need to apply scaling before feeding it to a model. Why is StandardScaler generally a poor choice for this type of data, and which scaler would be more appropriate?

scaling and normalization Hard
A. StandardScaler cannot handle zero values and will raise a 'division by zero' error during transformation.
B. StandardScaler is computationally inefficient for sparse matrices. RobustScaler would be a better choice.
C. Sparse data does not require scaling, as the zero values act as a natural baseline.
D. StandardScaler will center the data by subtracting the mean, which destroys sparsity by converting all zero entries into non-zero, dense floating-point numbers. MaxAbsScaler is more appropriate.

59 Combining undersampling of the majority class with oversampling of the minority class is a common hybrid strategy. Which of the following pairs represents a sophisticated and synergistic combination for cleaning noisy datasets?

class imbalance handling Hard
A. Random Undersampling followed by Random Oversampling.
B. Tomek Links for undersampling followed by SMOTE for oversampling.
C. SMOTE for oversampling followed by Edited Nearest Neighbours (ENN) for undersampling.
D. ADASYN for oversampling followed by Cluster Centroids for undersampling.

60 During a data science competition, you discover that the row_id in the training data is perfectly correlated with the time the event occurred. For example, lower row_id values correspond to earlier dates. You decide not to use the row_id as a feature directly. However, you perform k-fold cross-validation by randomly shuffling and splitting the data. Why might your local cross-validation score be misleadingly high and not reflect your score on the future-dated, hidden test set?

data leakage concept Hard
A. The row_id is a categorical feature and should have been one-hot encoded before cross-validation.
B. K-fold cross-validation is not statistically valid for time-dependent data; bootstrap validation should be used instead.
C. The random shuffling violates the temporal ordering. The model is trained on future data to predict the past within each fold, a form of leakage that won't be possible on the real test set.
D. The model is overfitting to the row_id even though it's not an explicit feature.