1. Statistics & Probability
Q1. What is the Central Limit Theorem (CLT), and why is it essential in Data Science?
-
Key Threshold: Generally, a sample size of $n \ge 30$ is considered sufficient for the CLT to hold.
-
Why It Matters: CLT allows data scientists to make inferences about population parameters (such as calculating confidence intervals and conducting hypothesis $t$-tests) without knowing the true distribution of the underlying population data.
Q2. How do you explain the difference between Type I and Type II errors?
ACTUAL TRUTH IN POPULATION
Null True (H₀) Null False (H₀)
┌───────────────────┬───────────────────┐
Reject Null (H₀) │ TYPE I ERROR │ Correct Decision │
│ (False Positive) │ (Statistical) │
DECISION ├───────────────────┼───────────────────┤
Fail to Reject H₀ │ Correct Decision │ TYPE II ERROR │
│ (Baseline) │ (False Negative) │
└───────────────────┴───────────────────┘
-
Type I Error ($\alpha$ / False Positive): Rejecting the null hypothesis when it is actually true (e.g., flagging a legitimate email as spam).
-
Type II Error ($\beta$ / False Negative): Failing to reject the null hypothesis when it is actually false (e.g., failing to flag a malicious transaction as fraudulent).
Q3. Explain the difference between p-value and Confidence Interval.
-
p-value: The probability of obtaining test results at least as extreme as the observed results, assuming the null hypothesis ($H_0$) is true. A lower p-value (typically $\le 0.05$) indicates strong evidence against $H_0$.
-
Confidence Interval (CI): A range of values calculated from sample data that is likely to contain the true population parameter with a specified confidence level (e.g., 95%). While p-values indicate statistical significance, confidence intervals convey the magnitude and precision of the effect size.
Q4. What is A/B testing, and how do you handle Sample Ratio Mismatch (SRM)?
-
How to detect SRM: Perform a Chi-Square Goodness-of-Fit test on user assignment counts.
-
How to fix SRM: If SRM is statistically significant ($p < 0.01$), the test results are invalid due to assignment bias (e.g., bot traffic, redirection latency, or logging bugs). Root causes must be resolved before re-running the experiment.
2. Machine Learning Fundamentals
Q5. What is the Bias-Variance Tradeoff?
-
Bias: Error introduced by approximating a real-world problem with an overly simple model. High bias leads to underfitting (poor performance on both training and test data).
-
Variance: Error introduced by a model’s extreme sensitivity to small fluctuations in the training set. High variance leads to overfitting (high performance on training data, poor generalization to test data).
Q6. How do you handle severely imbalanced datasets?
-
Evaluation Metrics: Stop using accuracy. Use Precision, Recall, $F_1$-score, PR-AUC, or ROC-AUC.
-
Resampling Techniques:
-
Oversampling: Generate synthetic minority samples using SMOTE (Synthetic Minority Over-sampling Technique) or ADASYN.
-
Undersampling: Reduce majority class samples using Tomek Links or Random Undersampling.
-
-
Algorithmic Adjustments: Use class-weighted cost functions (e.g.,
scale_pos_weightin XGBoost orclass_weight='balanced'in scikit-learn). -
Ensemble Methods: Utilize Balanced Random Forest or EasyEnsemble classifiers.
Q7. Compare L1 (Lasso) vs. L2 (Ridge) Regularization.
| Metric / Feature | L1 Regularization (Lasso) | L2 Regularization (Ridge) |
| Penalty Term | Sum of absolute values of weights: $\lambda \sum \vert w_i \vert$ | Sum of squared values of weights: $\lambda \sum w_i^2$ |
| Feature Selection | Yes: Shrinks non-important feature weights strictly to zero. | No: Shrinks weights near zero, but never exactly to zero. |
| Sparsity | Produces sparse models (useful for high-dimensional data). | Produces non-sparse models with small weights distributed across features. |
| Handling Multicollinearity | Arbitrarily selects one feature from a group of correlated features. | Distributes weights evenly across correlated features. |
Q8. What is the difference between Bagging and Boosting?
-
Bagging (Bootstrap Aggregating): Trains multiple weak learners (e.g., decision trees) in parallel on bootstrap samples of dataset. Reduces variance.
-
Example: Random Forest.
-
-
Boosting: Trains weak learners sequentially, where each subsequent model focuses on correcting the prediction errors made by previous models. Reduces bias and variance.
-
Examples: XGBoost, LightGBM, CatBoost.
-
3. Machine Learning Algorithms
Q9. How does a Decision Tree split nodes, and how do Random Forests improve upon them?
-
Classification Impurity Metrics: Gini Impurity ($1 – \sum p_i^2$) or Entropy ($-\sum p_i \log_2 p_i$).
-
Regression Metric: Reduction in Variance / Mean Squared Error (MSE).
-
Bagging (Bootstrapping): Sampling rows with replacement for each tree.
-
Feature Subspacing: Selecting a random subset of features (typically $\sqrt{p}$) at each split point. This decorrelates the trees, preventing a single dominant feature from dictating every tree structure.
Q10. Explain how Logistic Regression works. Is it a regression or classification algorithm?
-
Loss Function: Optimized using Binary Cross-Entropy (Log Loss) via Gradient Descent (rather than Ordinary Least Squares, which yields non-convex loss surfaces for classification).
Q11. How does XGBoost achieve superior speed and accuracy compared to standard Gradient Boosting?
-
Regularization: Includes built-in $L_1$ and $L_2$ regularization terms in its objective function to limit model growth and prevent overfitting.
-
Second-Order Gradients: Uses Taylor expansion to compute both first-order (gradients) and second-order (Hessians) loss function derivatives for faster optimization convergence.
-
System Optimization: Supports parallelized tree building, column block structures for quick feature scanning, cache-aware memory access, and built-in handling of missing values.
Q12. Explain the execution mechanism of K-Means Clustering and its key limitations.
[ Step 1: Initialize ] ──► Choose K random centroids
▲ │
│ ▼
[ Step 4: Check ] [ Step 2: Assign Points ]
Converged? Assign to nearest centroid (Euclidean distance)
No │ │
│ ▼
└──────────────── [ Step 3: Update Centroids ]
Recompute mean position of each cluster
-
Requires manual specification of $K$ (evaluated using the Elbow Method or Silhouette Score).
-
Sensitive to initial centroid selection (mitigated by using K-Means++).
-
Assumes spherical, equal-sized clusters; fails on non-convex or complex geometric shapes (where DBSCAN or Spectral Clustering are preferred).
4. SQL & Data Engineering
Q13. What is the execution order of a SQL query?
SELECT, but database query engines evaluate statements in a specific logical order:1. FROM / JOIN ──► Locates target tables and performs joins
2. WHERE ──► Filters raw individual rows
3. GROUP BY ──► Aggregates rows into groups
4. HAVING ──► Filters aggregated groups
5. SELECT ──► Computes projection columns and expressions
6. DISTINCT ──► Removes duplicate rows
7. ORDER BY ──► Sorts output records
8. LIMIT / OFFSET──► Restricts output row counts
Q14. What are Window Functions in SQL, and how do RANK(), DENSE_RANK(), and ROW_NUMBER() differ?
GROUP BY).| Score | ROW_NUMBER() | RANK() | DENSE_RANK() | Explanation |
| 100 | 1 | 1 | 1 | All functions start at 1 for the top score. |
| 90 | 2 | 2 | 2 | First tie encountered. |
| 90 | 3 | 2 | 2 | RANK() and DENSE_RANK() assign identical rank to ties. |
| 80 | 4 | 4 | 3 | RANK() skips ranks (leaves gaps); DENSE_RANK() stays consecutive. |
Q15. Write a SQL query to find the 2nd highest salary from an employees table.
DENSE_RANK() window function ensures correct behavior even when salary values contain duplicates:SQL
WITH RankedSalaries AS (
SELECT
employee_id,
salary,
DENSE_RANK() OVER (ORDER BY salary DESC) as rank_position
FROM employees
)
SELECT salary
FROM RankedSalaries
WHERE rank_position = 2;
SQL
SELECT MAX(salary) AS second_highest_salary
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
Q16. What is the difference between Star Schema and Snowflake Schema in Data Warehousing?
-
Star Schema: A central Fact Table connected directly to denormalized Dimension Tables.
-
Pros: Simpler SQL queries, faster read performance, fewer joins.
-
-
Snowflake Schema: A central Fact Table connected to dimension tables that are further normalized into sub-dimension tables.
-
Pros: Reduces data redundancy and optimizes disk space utilization.
-
5. MLOps, Dimensionality Reduction & System Design
Q17. How does Principal Component Analysis (PCA) work intuitively?
-
Center Data: Standardize features ($z$-score scaling).
-
Covariance Matrix: Compute feature covariance relationships.
-
Eigendecomposition: Compute Eigenvectors (direction of maximum variance) and Eigenvalues (magnitude of variance explained).
-
Project: Select the top $k$ eigenvectors accounting for target variance retention (e.g., 95% of total variance) and project original features onto the new lower-dimensional axis.
Q18. How do you detect and handle Data Drift and Concept Drift in production ML models?
-
Data Drift (Covariate Shift): The input data distribution changes over time, while the target mapping remains unchanged: $P(X)$ changes, but $P(Y \vert X)$ remains stable (e.g., user demographics shift).
-
Concept Drift: The statistical relationship mapping input data to output labels changes: $P(Y \vert X)$ changes (e.g., consumer purchasing habits shift post-economic crisis).
TYPES OF DRIFT IN PRODUCTION
│
┌─────────────────────────┴─────────────────────────┐
▼ ▼
[ DATA DRIFT / COVARIATE SHIFT ] [ CONCEPT DRIFT ]
• Input distribution P(X) changes • Target relationship P(Y|X) changes
• Example: Demographic shifts • Example: Macroeconomic inflation
• Detect: Kolmogorov-Smirnov, PSI • Detect: Model metric decay (F1, MAE)
Q19. How do you address the Cold Start Problem in Recommendation Systems?
-
Hybrid Approach: Switch from purely Collaborative Filtering (matrix factorization) to Content-Based Filtering relying on metadata (item genre, user profile details) during initial onboarding.
-
Interactive Onboarding: Ask new users to select 3 to 5 baseline preference categories during registration.
-
Multi-Armed Bandits (MAB): Dynamically balance exploration (showing new items to gather click interaction data) with exploitation (showing known high-performing items).
Q20. How do you prevent Data Leakage during preprocessing and feature engineering?
-
Split First, Transform Second: Always perform train/test splits before calculating statistical parameters (e.g., mean, standard deviation for scaling, or missing value imputation medians).
-
Use Pipelines: Wrap preprocessors and estimators inside scikit-learn
PipelineorColumnTransformerobjects to ensure scaling logic is calculated exclusively on training folds during Cross-Validation. -
Time-Series Cutoffs: Use time-based split boundaries rather than random cross-validation to prevent future data features from leaking into past predictions.
Key Takeaway

-
State the core concept directly in 1–2 concise sentences.
-
Explain the underlying trade-offs (e.g., speed vs. accuracy, bias vs. variance).
-
Provide a real-world production example demonstrating practical application.

