61. What is the difference between bagging and boosting in ensemble methods?
- Bagging trains models sequentially; boosting trains them in parallel
- Bagging trains multiple models in parallel on random data subsets and averages results to reduce variance; boosting trains models sequentially where each corrects the errors of the previous to reduce bias
- Boosting reduces variance; bagging reduces bias in ensemble learning
- Bagging and boosting are identical techniques with different implementation details
Answer : B Explanation: Both are ensemble methods that combine multiple models for better performance. Bagging (Bootstrap Aggregating): trains base learners independently in parallel on random bootstrap samples of the data, then combines predictions by averaging (regression) or majority voting (classification). Reduces variance and prevents overfitting. Example: Random Forest. Boosting: trains base learners sequentially, each focusing on the mistakes of the previous one by upweighting misclassified examples. Reduces bias. Examples: AdaBoost, Gradient Boosting, XGBoost, LightGBM. Boosting often achieves higher accuracy than bagging but is more prone to overfitting on noisy data. Both are among the top-performing ML approaches for structured/tabular data.
62. What is XGBoost and why is it popular in data science competitions?
- A deep learning framework developed by Facebook for large-scale image classification
- An optimized gradient boosting library that is extremely fast, handles missing values natively, includes built-in regularization, and consistently achieves top performance on structured/tabular data
- A data visualization tool used for creating extreme gradient plots in data analysis
- A Python library for extreme-scale distributed computing on large datasets
Answer : B Explanation: XGBoost (Extreme Gradient Boosting) is one of the most widely used and award-winning ML algorithms in data science competitions (Kaggle). It builds trees sequentially where each new tree corrects the residual errors of the previous ensemble. Key advantages: speed and efficiency (parallel tree construction, cache-aware algorithms), built-in L1/L2 regularization (preventing overfitting), handles missing values natively, supports early stopping, provides feature importance, and works out of the box for classification, regression, and ranking. LightGBM and CatBoost are modern alternatives that offer even faster training for large datasets.
63. What is the purpose of the confusion matrix in data science?
- A matrix that shows how confused a model is about which features to use
- A table that summarizes a classification model’s performance by showing the counts of true positives, true negatives, false positives, and false negatives
- A correlation matrix showing which pairs of features are most confusingly similar
- A matrix comparing multiple model performances across different evaluation metrics
Answer : B Explanation: The Confusion Matrix provides a complete picture of classifier performance beyond simple accuracy. For a binary classifier it shows: True Positive (TP) — correctly predicted positive; True Negative (TN) — correctly predicted negative; False Positive (FP) — incorrectly predicted positive (Type I error); False Negative (FN) — incorrectly predicted negative (Type II error). From these, key metrics are derived: Accuracy = (TP+TN)/Total; Precision = TP/(TP+FP); Recall = TP/(TP+FN); F1-Score = 2×Precision×Recall/(Precision+Recall); Specificity = TN/(TN+FP). Confusion matrices are essential for evaluating imbalanced datasets where accuracy alone is misleading.
64. What is the ROC-AUC metric in data science classification?
- A metric that measures the speed of a classification algorithm on different hardware
- ROC (Receiver Operating Characteristic) curve plots True Positive Rate vs False Positive Rate at various thresholds; AUC (Area Under the Curve) summarizes overall model performance — AUC=1 is perfect; AUC=0.5 is random
- A regression metric that measures the residual of output classifications
- A measure of how quickly a classification model converges during training
Answer : B Explanation: The ROC curve is created by plotting TPR (True Positive Rate = Recall) on the Y-axis against FPR (False Positive Rate = 1-Specificity) on the X-axis at every possible classification threshold from 0 to 1. AUC (Area Under the ROC Curve) is a single number summarizing the ROC curve: AUC = 1.0 means perfect classification; AUC = 0.5 means random guessing (diagonal line); AUC < 0.5 means consistently wrong. ROC-AUC is threshold-independent — it evaluates the model across all thresholds simultaneously — making it ideal for comparing different models and handling imbalanced datasets. Use sklearn.metrics.roc_auc_score() in Python.
65. What is SQL and why is it important in data science?
- A statistical quality language used exclusively for data quality assessment in datasets
- Structured Query Language — a standard language for querying and managing relational databases, essential for data scientists to extract, filter, aggregate, and join data from organizational databases
- A machine learning scripting language that queries models for prediction results
- A Python library that provides SQL-like syntax for querying Pandas DataFrames
Answer : B Explanation: SQL (Structured Query Language) is the most essential non-Python skill for data scientists. Most organizational data lives in relational databases (MySQL, PostgreSQL, SQL Server, BigQuery) — data scientists must query this data before analysis. Critical SQL skills include: SELECT with WHERE (filtering), GROUP BY with aggregate functions (COUNT, SUM, AVG, MAX, MIN), JOIN (combining tables — INNER, LEFT, RIGHT, FULL OUTER), Subqueries and CTEs (WITH clauses), Window Functions (RANK(), ROW_NUMBER(), LAG(), LEAD()), and ORDER BY/LIMIT. Data science interviews almost universally include SQL questions alongside Python and statistics.
66. What is the purpose of the GROUP BY clause in SQL for data science?
- To sort query results in ascending or descending order by one or more columns
- To group rows with the same values in specified columns into summary rows, enabling aggregate functions to compute statistics for each group
- To group multiple SQL queries into a single batch operation for efficiency
- To filter rows before returning query results based on a grouping condition
Answer : B Explanation: GROUP BY is one of the most important SQL clauses for data analysis. It groups rows sharing the same values in specified columns, then applies aggregate functions to each group. Example: SELECT department, COUNT(*) AS employee_count, AVG(salary) AS avg_salary FROM employees GROUP BY department — returns one row per department with counts and averages. The HAVING clause filters groups after aggregation (unlike WHERE which filters rows before grouping). GROUP BY is used for cohort analysis, sales by region/product, user behavior by segment, and virtually every analytical query a data scientist writes. Knowing GROUP BY with multiple aggregates is essential for data science interviews.
67. What is dimensionality reduction in data science and why is it important?
- Reducing the size of a machine learning model by removing hidden layers
- The process of reducing the number of features (dimensions) in a dataset while preserving as much important information as possible, to combat the curse of dimensionality and improve model efficiency
- A technique for reducing dataset size by removing duplicate rows from large files
- The process of reducing a model’s prediction output to a single scalar value
Answer : B Explanation: High-dimensional data causes the “curse of dimensionality” — models become computationally expensive, prone to overfitting, and distance metrics lose meaning. Dimensionality Reduction techniques address this. Principal Component Analysis (PCA): projects data onto new orthogonal axes (principal components) capturing maximum variance — most common technique. t-SNE (t-Distributed Stochastic Neighbor Embedding): preserves local structure for 2D/3D visualization. UMAP: faster than t-SNE for visualization. LDA (Linear Discriminant Analysis): supervised technique that maximizes class separability. Autoencoders: deep learning-based compression. Applications include image compression, noise reduction, visualization, and speeding up downstream ML algorithms.
68. What is the difference between a parameter and a hyperparameter in machine learning?
- Parameters are set before training; hyperparameters are learned during training
- Parameters are learned automatically from training data (like weights in a neural network); hyperparameters are set before training by the practitioner and control the learning process (like learning rate, number of trees)
- Hyperparameters control data preprocessing; parameters control model evaluation
- Parameters and hyperparameters are synonymous terms used interchangeably in ML
Answer : B Explanation: Parameters are internal model variables learned from training data — like weights (w) and biases (b) in a neural network, or coefficients in logistic regression. You never set them manually. Hyperparameters are external configuration settings set before training that control the learning process — like learning rate (α), number of trees in Random Forest, max_depth of a decision tree, regularization strength (C in SVM), or number of hidden layers. Hyperparameter tuning methods: Grid Search (exhaustive search), Random Search (random sampling), and Bayesian Optimization (intelligent search). Finding optimal hyperparameters is a key challenge in building effective ML models.
69. What is regularization in machine learning and what are its main types?
- A process for normalizing training data to a standard scale before model training
- A technique that adds a penalty to the model’s loss function to discourage overly complex models, reducing overfitting by shrinking or eliminating coefficient values
- A method of regularizing random seeds to ensure reproducibility in ML experiments
- A technique for making models more complex to improve their training accuracy
Answer : B Explanation: Regularization penalizes model complexity to prevent overfitting. L1 Regularization (Lasso): adds the sum of absolute values of coefficients (λΣ|wᵢ|) to the loss function. It performs feature selection by driving some coefficients to exactly zero — producing sparse models. L2 Regularization (Ridge): adds the sum of squared coefficients (λΣwᵢ²) to the loss function. It shrinks coefficients toward zero but rarely to exactly zero. Elastic Net: combines L1 and L2 penalties. The regularization strength λ is a hyperparameter — higher λ means more penalty and simpler models. Both L1 and L2 are implemented in sklearn’s LogisticRegression (penalty=’l1′ or ‘l2’) and LinearRegression variants (Lasso, Ridge).
70. What is data leakage in data science and why is it dangerous?
- A data security breach where sensitive training data is exposed to unauthorized users
- A situation where information from the test set (or future data) inadvertently leaks into the training process, causing artificially inflated model performance that fails in production
- A network issue that causes training data to be corrupted during data pipeline transfers
- A scenario where a model’s predictions leak out to users before the model is officially deployed
Answer : B Explanation: Data Leakage occurs when the model is trained on information it should not have access to — typically future information or test set information. Common causes: (1) Target leakage (features created after the target event — e.g., using “loan default date” to predict loan default), (2) Train-test contamination (fitting a scaler on the entire dataset before splitting, then the test statistics influence scaling), (3) Duplicates spanning both train and test. Prevention: always fit preprocessing (scalers, encoders, imputers) ONLY on training data then transform test data separately; use pipelines (sklearn.pipeline.Pipeline); be careful with time-ordered data (always use temporal train-test splits). Leakage is one of the most dangerous and common mistakes in data science.
