*Data Science Interview: Part-2*
*Machine Learning Interview Questions with Answers*
13️⃣*Question: What is machine learning, and how is it different from
traditional programming?*
Answer:
Machine Learning (ML) is a branch of AI where algorithms learn patterns
from data and improve automatically with experience, rather than being
explicitly programmed.
Traditional programming: Input + Rules → Output
ML: Input + Output → Algorithm learns Rules/Patterns → Predict new
Output
14️⃣*Question: Explain the bias–variance trade-off*
Answer:
Bias: Error due to overly simplistic model assumptions (underfitting)
Variance: Error due to model sensitivity to training data (overfitting)
A good model balances bias and variance to minimize total error
🎯 Goal: Low bias + low variance (e.g., using cross-validation,
regularization)
15️⃣*Question: What are the different types of machine learning
algorithms?*
Answer:
Supervised Learning: Train on labeled data (e.g., Regression, Classification)
Unsupervised Learning: Find hidden patterns in unlabeled data (e.g.,
Clustering, Dimensionality Reduction)
Reinforcement Learning: Learn by interacting with environment and
receiving rewards/punishments
Semi-supervised / Self-supervised: Mix of labeled & unlabeled data
16️⃣*Question: What is overfitting, and how can you prevent it?*
Answer:
Overfitting occurs when a model performs well on training data but poorly
on unseen data because it memorized noise
✅ Prevention methods:
• Use cross-validation
• Regularization (L1/L2)
• Prune decision trees
• Collect more data
• Early stopping in neural networks
17️⃣*Question: Describe the k-fold cross-validation technique*
Answer:
Split the dataset into k equal folds: train the model on k–1 folds and
validate on the remaining fold. Repeat k times so each fold serves as a
validation set once
🎯 Ensures robust performance estimation and reduces overfitting risk
18️⃣*Question: What is regularization, and why is it important in machine
learning?*
Answer:
Regularization adds a penalty term to the loss function to discourage
overly complex models and reduce overfitting
• L1 (Lasso): Adds |weights| penalty → feature selection
• L2 (Ridge): Adds weights² penalty → shrinks coefficients
• Elastic Net: Combines L1 & L2
19️⃣*Question: Explain the concept of feature engineering*
Answer:
Feature engineering is the process of creating new input variables or
transforming existing ones to improve model performance
Examples:
• Binning continuous data
• Creating interaction terms
• Encoding categorical data
• Extracting date/time features
20️⃣*Question: What is gradient descent, and how does it work in machine
learning?*
Answer:
Gradient descent is an optimization algorithm used to minimize a loss
function by iteratively updating parameters in the direction of the steepest
descent
Update rule:
Where α is the learning rate. Variants include Batch, Stochastic (SGD), and
Mini-batch
21️⃣*Question: What is a decision tree, and how does it work?*
Answer:
A decision tree splits data into branches based on feature values to make
predictions
• Nodes: Feature tests
• Leaves: Predictions
Splits chosen using metrics like Gini impurity or Information Gain
🎯 Easy to interpret but prone to overfitting
22️⃣*Question: What are ensemble methods in machine learning? Provide
examples*
Answer:
Ensemble methods combine multiple models to improve accuracy and
reduce variance/bias
Examples:
• Bagging (Bootstrap Aggregating): Random Forest
• Boosting: XGBoost, AdaBoost, Gradient Boosting
• Stacking: Combine predictions of several base models using a meta-
model
23️⃣*Question: Explain the difference between supervised and
unsupervised learning*
Answer:
Supervised: Model is trained on labeled data to predict outcomes (e.g.,
spam detection, price prediction)
Unsupervised: Model finds hidden patterns or groupings without labels
(e.g., clustering, PCA)
24️⃣*Question: What is deep learning, and how does it differ from
traditional neural networks?*
Answer:
Deep learning uses neural networks with multiple hidden layers to
automatically learn hierarchical features
Difference: Traditional shallow networks have 1–2 layers; deep learning
networks can have dozens or hundreds, enabling complex tasks like image
recognition and NLP
25️⃣*Question: What is a convolutional neural network (CNN), and where is
it commonly used?*
Answer:
CNN is a deep learning architecture specifically designed for image and
spatial data
Uses convolutional layers to detect patterns like edges, shapes, objects
Applications: Image recognition, medical imaging, video analysis
26️⃣*Question: What is a recurrent neural network (RNN), and where is it
commonly used?*
Answer:
RNNs are designed for sequential data where past information influences
the present
Uses feedback loops to remember previous outputs
Applications: Time series prediction, natural language processing, speech
recognition
27️⃣*Question: What is the vanishing gradient problem in deep learning?*
Answer:
During backpropagation, gradients can become extremely small, causing
early layers of deep networks to learn very slowly or not at all
Solutions:
• Use ReLU or variants instead of sigmoid/tanh
• Apply batch normalization
• Use architectures like LSTM/GRU for sequences
28️⃣*Question: Describe the concept of transfer learning in deep learning*
Answer:
Transfer learning uses a pre-trained model on a large dataset and fine-
tunes it for a related but smaller task
Example: Using a model trained on ImageNet to classify medical images
🎯 Saves training time, reduces data needs, and improves accuracy when
labeled data is scarce