Krazy Kaksha

Interview Prep

Machine Learning Interview Questions and Answers for Freshers

Krazy Kaksha 6 min read

Machine Learning Interview Questions and Answers for Freshers

Machine learning is now asked in many fresher interviews, not only for data science roles. Even for software developer roles, interviewers often ask a few ML basics if your resume has an AI project. Below are the 35 most asked machine learning interview questions for freshers with short, simple answers.

For every algorithm, be ready to say three things: what problem it solves, how it works in one line, and one real example. That is what interviewers look for.

Quick summary

AreaWhat they ask most
BasicsTypes of learning, features and labels, train and test split
Model problemsOverfitting, underfitting, bias vs variance, regularisation
MetricsAccuracy, precision, recall, F1 score, confusion matrix
AlgorithmsLinear and logistic regression, decision tree, random forest, KNN, SVM, K-means
Deep learningNeural network, activation function, backpropagation, CNN

Machine Learning Basics

1. What is machine learning?
A way for computers to learn patterns from data and make predictions without being programmed with fixed rules.

2. What are the types of machine learning?
Supervised learning (labelled data, like spam detection), unsupervised learning (no labels, like customer grouping) and reinforcement learning (learning by reward, like game playing).

3. What is the difference between classification and regression?
Classification predicts a class (spam or not spam). Regression predicts a number (house price).

4. What are features and labels?
Features are the inputs (size, location of a house). The label is the answer we want to predict (price).

5. Why do we split data into train and test sets?
To check how the model works on new data it has not seen. A common split is 80 percent train and 20 percent test.

6. What is a validation set and cross-validation?
A validation set is used to tune the model. In k-fold cross-validation, data is split into k parts and each part is used once for testing.

Model Problems

7. What is overfitting?
The model learns the training data too well, including noise, so it does badly on new data. High train accuracy, low test accuracy.

8. What is underfitting?
The model is too simple to learn the pattern, so it does badly on both train and test data.

9. How do you reduce overfitting?
More data, simpler model, regularisation, cross-validation, dropout (in neural networks) and early stopping.

10. Explain the bias-variance tradeoff.
Bias is error from a too simple model; variance is error from a too sensitive model. We try to keep both low and find the balance.

11. What is regularisation? L1 vs L2?
Adding a penalty for large weights. L1 (Lasso) can make some weights zero, so it also selects features. L2 (Ridge) makes weights small but not zero.

12. What is feature scaling and why is it needed?
Bringing features to a similar range (normalisation or standardisation) so that big numbers do not dominate, which matters for KNN, SVM and gradient descent.

13. How do you handle missing values?
Remove rows, or fill with mean, median or mode, or use a model to predict them.

Evaluation Metrics

14. What is a confusion matrix?
A table with true positives, true negatives, false positives and false negatives.

15. What are precision and recall?
Precision = TP / (TP + FP): of the predicted positives, how many were right. Recall = TP / (TP + FN): of the real positives, how many we found.

16. What is the F1 score?
The harmonic mean of precision and recall. Useful when classes are imbalanced.

17. Why is accuracy not always a good metric?
If 99 percent of emails are not spam, a model that always says “not spam” gets 99 percent accuracy but is useless.

18. What is ROC-AUC?
The ROC curve plots true positive rate vs false positive rate. AUC is the area under it; closer to 1 is better.

19. Which metrics are used for regression?
MAE, MSE, RMSE and R squared.

Algorithms

20. Explain linear regression.
It fits a straight line y = mx + c that best fits the data by reducing squared error.

21. Why is logistic regression used for classification?
It uses the sigmoid function to turn the output into a probability between 0 and 1.

22. How does a decision tree work?
It splits data on the feature that gives the best separation, using Gini index or information gain, until it reaches a decision.

23. What is a random forest?
Many decision trees trained on random samples of data and features; the final answer is by voting. It reduces overfitting.

24. Explain KNN.
To classify a new point, look at its K nearest neighbours and take the majority class. No training step, so it is called a lazy learner.

25. What is SVM?
Support Vector Machine finds the line (hyperplane) that separates classes with the widest margin. Kernels help with non-linear data.

26. What is Naive Bayes?
A classifier based on Bayes theorem that assumes features are independent. Works well for text and spam filtering.

27. Explain K-means clustering.
Pick K centres, assign each point to the nearest centre, move centres to the mean of their points, and repeat until stable.

28. What is gradient descent?
An optimisation method that moves the weights step by step in the direction that reduces the error. The step size is the learning rate.

29. What is the difference between bagging and boosting?
Bagging trains models in parallel on random samples (random forest). Boosting trains models one after another, each fixing the errors of the last (XGBoost, AdaBoost).

30. What is PCA?
Principal Component Analysis reduces the number of features while keeping most of the information.

Deep Learning Basics

31. What is a neural network?
Layers of connected nodes (neurons) with weights. Input layer, hidden layers and output layer.

32. What is an activation function? Name some.
It adds non-linearity so the network can learn complex patterns. ReLU, sigmoid, tanh and softmax.

33. What is backpropagation?
The method of finding how much each weight caused the error and updating it, going backwards from the output layer.

34. What is a CNN used for?
Convolutional Neural Networks are used for images. They use filters to find edges, shapes and objects.

35. What is the difference between AI, ML and deep learning?
AI is the big idea of smart machines. ML is a part of AI that learns from data. Deep learning is a part of ML that uses many layer neural networks.

Tips for the interview

  • Explain one ML project from your resume end to end: data, model, metric, result.
  • Always say why you chose a metric, not only its value.
  • Keep formulas for precision, recall and F1 ready on your fingertips.

Keep preparing

Save this page and go through it once before every interview round.

Doubts? Ask here

Leave a comment

Your email is not shown. Comments appear after a quick check.