Data Science MCQ Questions And Answers

51. What are missing values in a dataset and how are they handled in data science?

  1. Missing values are values that fall outside the expected range and are always removed
  2. Missing values are absent data points represented as NaN or None; handled by deletion (listwise/pairwise), imputation (mean/median/mode/model-based), or flagging with indicator variables
  3. Missing values only occur in categorical columns and are always replaced with the most common value
  4. Missing values are automatically filled with zeros by all machine learning algorithms

Answer : B
Explanation: Missing values (NaN in pandas) are a common data quality issue. Handling strategies depend on the amount of missing data and its mechanism (MCAR, MAR, MNAR). Deletion: dropna() removes rows/columns — appropriate when few values are missing. Mean/Median/Mode Imputation: fillna(df.mean()) — simple but can distort distributions. Median is preferred for skewed data. Forward/Backward Fill: ffill()/bfill() — used for time series. Model-Based Imputation: using KNN or regression to predict missing values. Multiple Imputation: creating several imputed datasets and pooling results. Indicator Variable: adding a binary flag column to mark missing values. The best method depends on the data and the missingness pattern.

52. What is the IQR (Interquartile Range) method for outlier detection?

  1. A method that identifies outliers using the mean and standard deviation of a dataset
  2. A method that calculates the range between Q1 (25th percentile) and Q3 (75th percentile), then flags values below Q1-1.5×IQR or above Q3+1.5×IQR as outliers
  3. A clustering method that identifies outliers as points in the smallest interquartile cluster
  4. An interval-based method that removes all values outside the 5th and 95th percentiles

Answer : B
Explanation: The IQR method is a robust, distribution-free technique for detecting outliers. IQR = Q3 – Q1, where Q1 is the 25th percentile and Q3 is the 75th percentile. Outlier boundaries: Lower Fence = Q1 – 1.5 × IQR; Upper Fence = Q3 + 1.5 × IQR. Values outside these fences are flagged as outliers. This is exactly what a boxplot visualizes — the box shows Q1-Q3, whiskers extend to the fences, and dots beyond whiskers are outliers. The IQR method is more robust than Z-score for skewed distributions because it does not depend on mean and standard deviation, which are sensitive to outliers themselves.

53. What is the difference between precision and recall in data science model evaluation?

  1. Precision measures training speed; recall measures model memory efficiency
  2. Precision is the fraction of predicted positives that are truly positive; recall is the fraction of actual positives that were correctly predicted — high precision means few false alarms; high recall means few missed positives
  3. Recall is always higher than precision for all classification models
  4. Precision and recall measure identical things using different formulas

Answer : B
Explanation: Precision = TP / (TP + FP) — of all predicted positives, what fraction were correct? High precision means the model rarely cries wolf. Recall (Sensitivity) = TP / (TP + FN) — of all actual positives, what fraction did the model catch? High recall means few cases are missed. There is a precision-recall tradeoff: lowering the classification threshold increases recall but decreases precision. Use case drives the choice: medical cancer screening needs high recall (missing a cancer is worse than a false alarm); spam filters need high precision (flagging legitimate email as spam is problematic). The F1-score = 2 × (Precision × Recall)/(Precision + Recall) balances both.

54. What is R-squared (R²) in regression analysis?

  1. The square root of the regression model’s mean squared error
  2. A statistical measure representing the proportion of variance in the dependent variable explained by the independent variables in the model, ranging from 0 to 1
  3. The correlation coefficient between two variables squared to remove negative values
  4. The number of independent variables squared used in a regression model

Answer : B
Explanation: R² (coefficient of determination) measures how well the regression model fits the data. R² = 1 – (SS_residuals / SS_total), where SS_residuals is the sum of squared residuals and SS_total is total variance. R² = 1 means the model perfectly explains all variance; R² = 0 means the model explains no variance (no better than predicting the mean). R² always increases when you add more predictors, even if they are irrelevant — which is why Adjusted R² (penalizes for unnecessary predictors) is preferred for multiple regression. R² does not indicate whether the model is appropriate — always check residual plots.

55. What is the purpose of the train-test split in data science?

  1. To split data into positive and negative examples for binary classification training
  2. To divide a dataset into separate subsets — a training set to fit the model and a test set to evaluate how well it generalizes to unseen data — preventing data leakage and overfitting evaluation
  3. To train multiple models simultaneously on different hardware configurations
  4. A technique for splitting features into training variables and testing target variables

Answer : B
Explanation: The train-test split is a fundamental data science practice. The training set (typically 70-80% of data) is used to fit the model — the algorithm learns patterns from these examples. The test set (remaining 20-30%) is completely held out during training and used only after model training to evaluate real-world generalization performance. Evaluating on training data alone gives overly optimistic results (the model has memorized training data). In practice, a three-way split is common: training (60-70%), validation (15-20%) for hyperparameter tuning, and test (15-20%) for final evaluation. Use stratify=y in train_test_split() for imbalanced datasets.

56. What is data wrangling in data science?

  1. A technique for visualizing complex datasets using advanced graphing methods
  2. The process of transforming and mapping raw, messy data into a clean, structured format suitable for analysis — including cleaning, reshaping, merging, and encoding data
  3. A method of collecting new data from multiple web sources using automated bots
  4. A process of securing and encrypting sensitive data before storing it in a database

Answer : B
Explanation: Data Wrangling (also called data munging) is the process of converting raw, messy data into a usable format. It typically consumes 60-80% of a data scientist’s time. Key steps include: Cleaning (removing duplicates, correcting errors, handling missing values), Reshaping (pivoting, melting, stacking data), Merging (joining multiple datasets using pd.merge() or pd.concat()), Type Conversion (converting strings to datetime, categories to numerical codes), Filtering (selecting relevant rows and columns), and Encoding (one-hot encoding categorical variables). pandas is the primary tool for data wrangling in Python; dplyr serves the same purpose in R.

57. What is the difference between RMSE and MAE in regression model evaluation?

  1. RMSE is for classification models; MAE is for regression models
  2. RMSE (Root Mean Squared Error) penalizes large errors more heavily due to squaring; MAE (Mean Absolute Error) treats all errors equally regardless of magnitude
  3. MAE is always larger than RMSE for the same model and dataset
  4. RMSE and MAE always produce the same numerical value for any given dataset

Answer : B
Explanation: Both RMSE and MAE measure prediction error in regression. MAE = (1/n) × Σ|yᵢ – ŷᵢ| — the average absolute difference between predictions and actual values. It is robust to outliers. RMSE = √[(1/n) × Σ(yᵢ – ŷᵢ)²] — squares the errors before averaging, giving more weight to large errors. It is more sensitive to outliers. RMSE is always ≥ MAE. Use RMSE when large errors are particularly undesirable (e.g., predicting stock prices). Use MAE when all errors are equally important (e.g., predicting temperature). RMSE is more commonly used in ML model evaluation due to its mathematical properties and compatibility with gradient-based optimization.

58. What is A/B testing in data science?

  1. A technique for testing two machine learning algorithms against each other on the same dataset
  2. A controlled experiment that compares two versions (A and B) of a product, feature, or strategy by exposing different user groups to each and measuring which performs better using statistical testing
  3. An automated testing framework that validates data pipeline code using A and B test suites
  4. A technique for splitting a dataset alphabetically into two equal halves for training

Answer : B
Explanation: A/B testing is the gold standard for data-driven decision making in product development and marketing. Users are randomly split into control (A — current version) and treatment (B — new version) groups. Key steps: Define hypothesis and success metric, Determine sample size (statistical power analysis), Run the experiment for sufficient duration, Analyze results using hypothesis testing (t-test, chi-squared test), and Check statistical significance (p-value) and practical significance (effect size). A/B testing is used to test website features (button colors, page layouts), email subject lines, pricing strategies, and recommendation algorithms. Common pitfalls include peeking (stopping early) and multiple comparisons.

59. What is feature importance in machine learning and data science?

  1. A ranking of features based on how frequently they appear in the training dataset
  2. A measure of how much each input feature contributes to a machine learning model’s predictions, used for model interpretation, feature selection, and understanding data relationships
  3. The number of unique values present in each feature column of a dataset
  4. A data preprocessing step that ranks features by their correlation to other features

Answer : B
Explanation: Feature Importance quantifies how much each feature contributes to the model’s predictive power. Methods vary by algorithm: Tree-based models (Random Forest, XGBoost) provide built-in feature_importances_ scores based on how much each feature reduces impurity across all trees. Permutation Importance measures the decrease in model accuracy when a feature’s values are randomly shuffled. SHAP values provide consistent, game-theory-based feature importance for any model. Coefficient magnitude in linear/logistic regression (after standardization). Feature importance guides feature selection (removing unimportant features), model interpretation (explaining predictions), and business insights.

60. What is one-hot encoding and when is it used?

  1. An encoding technique that converts all numerical features to binary (0 or 1) values
  2. A technique that converts categorical variables into multiple binary (0/1) columns — one for each category — allowing machine learning algorithms that require numerical input to process categorical data
  3. A method of encoding passwords and sensitive data fields in a database
  4. A compression technique that encodes repeated values as a single bit

Answer : B
Explanation: One-Hot Encoding converts a categorical column with n unique categories into n binary columns. Example: a “Color” column with values {Red, Blue, Green} becomes three columns: Color_Red, Color_Blue, Color_Green, where only one is 1 (hot) for each row. Most ML algorithms require numerical input and cannot handle string categories. Use pd.get_dummies() or sklearn’s OneHotEncoder. Important: avoid the “dummy variable trap” by dropping one column (drop_first=True) for linear models to prevent multicollinearity. For high-cardinality categorical features (many unique values), Target Encoding or Embeddings are preferred alternatives to avoid creating too many columns.