MACHINE LEARNING
STATISTICS

Data Scientist Interview Questions: Machine Learning, Statistics & Python

Master data science interviews with machine learning algorithms, statistical analysis, Python coding, and business case studies. Practice for Google, Amazon, Microsoft, and other top tech companies.

Data Scientist Interview Questions

1. Explain the bias-variance tradeoff in machine learning
Arrow for FAQ top
Expert Answer: Bias is error from oversimplified assumptions, causing underfitting. Variance is error from sensitivity to small data fluctuations, causing overfitting. High bias, low variance models (like linear regression) miss complex patterns but are stable. Low bias, high variance models (like decision trees) capture patterns but overfit. The optimal model balances both.

Example: "In our customer churn prediction model, I initially used logistic regression (high bias, low variance) which had consistent but poor performance across datasets. Then I tried random forest (lower bias, higher variance) which performed excellently on training but poorly on validation. I found the sweet spot using regularized ensemble methods, achieving 85% accuracy with good generalization by tuning regularization parameters through cross-validation."
2. How do you handle missing data in datasets?
Arrow for FAQ top
Expert Answer: First identify missing data patterns: MCAR (completely at random), MAR (at random), MNAR (not at random). Then choose appropriate strategy: deletion for minimal missing data, mean/median/mode imputation for MCAR, model-based imputation (KNN, regression) for MAR, or domain-specific approaches for MNAR. Always validate impact on model performance.

Example: "In our e-commerce dataset with 30% missing age values, I discovered they weren't random - younger users skipped this field. Simple mean imputation would bias results. I used KNN imputation based on purchase behavior and location, then compared model performance. This improved our recommendation system accuracy from 72% to 79% compared to dropping missing values, while preserving the dataset size for training."
3. What is the difference between supervised and unsupervised learning?
Arrow for FAQ top
Expert Answer: Supervised learning uses labeled data to learn input-output mappings for prediction (classification/regression). Unsupervised learning finds hidden patterns in unlabeled data through clustering, dimensionality reduction, or association rules. Semi-supervised combines both approaches when you have limited labeled data.

Example: "I used supervised learning to build a fraud detection classifier using historical labeled transactions (fraud/legitimate), achieving 94% accuracy. For customer segmentation, I applied unsupervised K-means clustering on purchase behavior to identify 5 distinct customer groups without predefined labels. Then I used semi-supervised learning to improve model performance when we only had fraud labels for 10% of transactions, leveraging the unlabeled data to boost accuracy to 96%."
4. How do you evaluate machine learning model performance?
Arrow for FAQ top
Expert Answer: Use appropriate metrics for your problem type. Classification: accuracy, precision, recall, F1-score, AUC-ROC for balanced data; precision-recall curves for imbalanced data. Regression: MAE, MSE, RMSE, R-squared. Always use cross-validation to ensure robust estimates and avoid overfitting.

Example: "For our medical diagnosis model with 95% negative cases, accuracy was misleading - a model predicting 'healthy' for everyone achieved 95% accuracy but missed all diseases. I focused on recall (sensitivity) to minimize false negatives and used AUC-PR instead of AUC-ROC. Through 5-fold cross-validation, I achieved 92% recall with 78% precision, meaning we caught 92% of actual cases while keeping false alarms manageable for clinical workflow."
5. Explain feature engineering and its importance
Arrow for FAQ top
Expert Answer: Feature engineering creates new features from raw data to improve model performance. Techniques include normalization, encoding categorical variables, creating interaction terms, polynomial features, binning, and dimensionality reduction. Good features can make simple models outperform complex ones with poor features.

Example: "In our house price prediction model, raw square footage alone gave R² of 0.6. I engineered features like price per square foot, age of house, interaction between location and size, and binned neighborhood income levels. These new features improved our linear regression R² to 0.85, outperforming a neural network with raw features (R² = 0.73). Domain knowledge was crucial - I created 'walkability score' by combining distance to schools, shops, and transit, which became our most predictive feature."
6. How do you handle imbalanced datasets?
Arrow for FAQ top
Expert Answer: Address imbalanced data through sampling techniques (SMOTE, undersampling, oversampling), algorithmic approaches (cost-sensitive learning, threshold tuning), or ensemble methods. Choose evaluation metrics that reflect business costs - precision/recall over accuracy. Consider the problem context when deciding between false positives vs false negatives.

Example: "Our credit fraud dataset had 0.1% positive cases. I tried SMOTE to oversample minorities, achieving balanced training data, but the model had too many false positives in production. Instead, I used cost-sensitive learning with XGBoost, setting class weights 1000:1 for fraud:normal, and optimized the decision threshold based on business costs ($100 per false positive investigation vs $5000 per missed fraud). This reduced false positives by 60% while maintaining 95% fraud detection rate."
7. What is regularization and why is it important?
Arrow for FAQ top
Expert Answer: Regularization adds penalty terms to the loss function to prevent overfitting by constraining model complexity. L1 (Lasso) promotes sparsity and feature selection. L2 (Ridge) shrinks coefficients toward zero. Elastic Net combines both. Other techniques include dropout for neural networks and early stopping during training.

Example: "In our high-dimensional genomics dataset with 20,000 features and 500 samples, our random forest was overfitting badly. I applied L1 regularization (Lasso regression) which automatically selected the 50 most important genes and improved test accuracy from 65% to 82%. For our deep learning model, I used dropout (0.3) and L2 regularization (0.001) together, reducing validation loss by 40% and achieving stable training convergence in half the epochs."
8. How do you approach an A/B testing experiment?
Arrow for FAQ top
Expert Answer: Start with clear hypothesis and success metrics. Calculate required sample size using power analysis. Design proper randomization to avoid bias. Monitor for external factors and ensure statistical assumptions. Analyze results considering both statistical and practical significance. Account for multiple testing if running multiple experiments.

Example: "For our checkout page redesign, I hypothesized the new design would increase conversion by 2%. Power analysis showed we needed 10,000 users per group for 80% power at α=0.05. I randomized by user ID to avoid spillover effects, ran for 2 weeks to account for weekly patterns, and used a two-tailed t-test. The new design showed 2.3% improvement (p=0.03), but I also calculated confidence intervals and effect size to ensure practical significance before recommending the change."
9. Explain the Central Limit Theorem and its applications
Arrow for FAQ top
Expert Answer: CLT states that sample means from any distribution approach normal distribution as sample size increases, regardless of the population distribution shape. This enables statistical inference through confidence intervals and hypothesis testing even when the underlying data isn't normally distributed. Standard error decreases as 1/√n.

Example: "In our user engagement analysis, individual session times were heavily right-skewed (not normal), but I could still use t-tests and confidence intervals because sample means of daily averages (n=50+ users per day) followed normal distribution due to CLT. This allowed me to detect a 15% improvement in average session time after our product update with 95% confidence, even though individual session data was non-normal. I also used bootstrapping to validate CLT assumptions with our actual data distribution."
10. How do you choose the right machine learning algorithm?
Arrow for FAQ top
Expert Answer: Consider problem type (classification/regression), data size, dimensionality, linearity, interpretability requirements, training time, and prediction speed. Start with simple baselines, then increase complexity. Use cross-validation to compare algorithms. Consider ensemble methods for best performance vs single interpretable models for explainability.

Example: "For our loan approval system, I needed both accuracy and interpretability for regulatory compliance. I compared logistic regression (interpretable, fast), random forest (good performance, some interpretability), and XGBoost (best performance, less interpretable). While XGBoost achieved 89% accuracy vs 85% for logistic regression, I chose regularized logistic regression because stakeholders could understand feature importance, and the 4% accuracy difference was acceptable for the gained transparency and faster inference time (2ms vs 50ms)."