Top 35 Machine learning Interview Questions & Answers

Verzeo
8 min readJun 19, 2020

--

Clearing a machine learning interview is not that tough as it might seem.

All you need is a strong foundation on Machine Learning and you can easily clear the interview.

But sometimes, in spite of having a strong base, you might find yourself in trouble during the interview.

The interviewer will focus on the basics first and as the interview proceeds, you will be challenged with more and more difficult questions.

The interviewer will try his best to put you under pressure.

But you need not worry. To help you tackle this, I have compiled a list of interview questions to help you clear interviews on Machine Learning easily.

I have divided these list of questions into 2 sections: Algorithm and theory-based, and practical based.

I hope by the end of this blog you will have answers to all the important interview questions on Machine Learning which will help you in landing that dream job.

Algorithm and Theory based Machine Learning interview questions

Q. What are the different types of Machine Learning Algorithms?

There are three different types of Machine Learning algorithms:

i. Supervised Learning: In this machine learns under the guidance of labelled data. In this, a model makes predictions and decisions based on past data. Labelled data means sets of data that are numbered or labelled for reference. It can be further divided into two types: Classification and Regression

ii. Unsupervised Learning: In unsupervised machine learning there is no such provision of labelled data. In this, the model input data needs to be given so that the machine can learn. It further consists of clustering algorithms.

iii. Reinforcement Learning: In this, the machine learns from a hit and trial method. The machine learns from the rewards or penalties it received from its previous actions.

Q. What is overfitting and how can you avoid it?

Overfitting is when the model learns too well. It happens when the model learns the details and noise in training data to an extent that it begins to negatively impact the performance of the model.

The most popular solutions to prevent overfitting are:

i. Cross-Validation

ii. Train with more data

iii. Remove features

iv. Early stopping of the machine when you find out something is going wrong

v. Regularization of algorithms so that your model can be simpler

Q. What is the difference between classification and regression in Machine Learning?

Classification and regression are the two main prediction problems which are most commonly faced while using Machine Learning.

It is the process of finding or discovering a model or function which helps in separating the data into multiple categorical classes which is discrete values

It is the process of finding a model or function for distinguishing the data into continuous real values instead of using classes or discrete values.

Nature of predicted data is unordered

Nature of predicted data is ordered

Calculate using measuring accuracy

Calculated by measurement of root mean square error

Example: Decision tree algo, logistic regression etc.

Example: Regression tree, Linear regression

Q. What is “Training set” and “Test set” in Machine Learning?

It is the examples given to the models to analyze and learn.

It is used to test the accuracy of the hypothesis generated by the model.

70% of the total data is taken as the training dataset.

The rest 30% is taken as testing dataset

This is the labelled data we use to train the model.

We test without labelled data and verify results with labels.

Q. What is Linear Regression?

Linear Regression is a supervised Machine Learning algorithm used to find out the linear relationship between the dependent and the independent variables for predictive analysis.

Linear Regression equation is given as:

Y = A + B.X

Where :

X is the input or the independent variable

Y is the output or the dependent variable

A is the intercept and,

B is the coefficient of X

Q. What are Bias and Variance?

Bias is the accuracy of our predictions

“Bias is the algorithm’s tendency to consistently learn the wrong thing by not taking into account all the information in the data (underfitting).”

A high bias means that the prediction will be inaccurate. Hence the bias value should be as low as possible to make accurate desired predictions.

Variance is the change in prediction accuracy of Machine Learning model between training data and test data.

Simply put, if the ML model prediction accuracy is “X” on training data and its prediction accuracy on test data is “Y” then

Variance = X-Y

Q. What is the difference between inductive and deductive learning?

Inductive learning uses observations to draw conclusions
Deductive learning uses conclusions to form observations

Looking for a Machine Learning certification? Enrol in our Machine Learning Certification program

Q. What is Variance Inflation Factor?

Variance Inflation Factor (VIF) is an estimate of the volume of multicollinearity in the collection of regression variables.

It is given as;
VIF = Variance of model / Variance of the model with a single independent variable

Q. How do you handle missing data or corrupted data in the dataset?

You can use the Pandas library in Python to handle the missing data.There are two methods to handle the missing data:

i. isNull(): For detecting the missing values.
ii. dropna(): We use dropna() method for removing the columns/rows with null values.

Q. Explain the Confusion Matrix with Respect to Machine Learning Algorithms.

To measure the performance of an algorithm we use a confusion matrix. In supervised learning, it is called Confusion Matrix. In unsupervised learning, it is called matching matrix.

The confusion matrix has two parameters:
Actual
Predicted
The confusion matrix visualises the accuracy by comparing the actual and predicted classes.

Below I have shown confusion table for a binary confusion matrix:

TP: True Positive: Predicted values correctly predicted as actual positive
FP: Predicted values incorrectly predicted an actual positive. i.e., Negative values predicted as positive
FN: False Negative: Positive values predicted as negative
TN: True Negative: Predicted values correctly predicted as an actual negative

You can use the confusion matrix to compute the accuracy-test:

Q. Compare K-means and KNN algorithms.

It is unsupervised in nature

It is supervised in nature

It is a clustering algorithm

KNN is a classification algorithm

It needs unlabelled data to train

It needs labelled data to train

Q. What is ROC curve? What does it represent?

Receiver Operating Characteristic curve (or ROC curve) is a fundamental tool which is used for diagnostic test evaluation. It is a plot of Sensitivity vs Specificity i.e it is a plot of the true positive rate against the false-positive rate.

Q. What is the difference between type I and type II error?

Type I error is a false positive. Type I error is claiming something has happened when it hasn’t.

Type II error is a false negative error. Type II error is claiming nothing when in fact something has happened.

Q. What are collinearity and multicollinearity?

Collinearity is when two predictor variables in a multiple regression have some relation between them.

Multicollinearity occurs when more than two predictor variables are inter-correlated.

Q. What Is a Random Forest?

It is a supervised machine learning algorithm which is generally used for classification problems. It creates multiple decision trees during its training phase. The random forest chooses the decision of the majority of trees and makes a final decision based on that.

Q. When Will You Use Classification over Regression?

When the target is categorical we will use classification, whereas when the target variable is continuous we will use regression.

Both these belong to supervised machine learning algorithms.

Examples of Classification problem include predicting:

1. Type of colour
2. Breed of animal
3. Gender of person
4. A statement is true or false
5. Yes or no
6. Type of flower

Whereas examples of regression problems include predicting:

1. Score of team
2. Amount of rainfall
3. Amount of revenue generated
4. Price of a product

Q. What are Eigenvectors and Eigenvalues?

Eigenvectors: Their direction remains the same even when a linear transformation is performed on them

Eigenvalues: It is a scalar that is used for the transformation of an eigenvector.

The Eigenvector of a square matrix B is a non zero vector such that for some number we have the following:

Ax = x

where is an Eigenvalue.

Q. What is SVM (Support Vector Machines)?

SVM is a supervised machine learning algorithm which is used for classification. They can be used to analyse data for classification and regression analysis.

In SVM each data item is plotted in n-dimensional space with the value of each feature being the value of a particular coordinate.

After this, we perform classification by finding the hyper-plane that differentiates the two classes. (Follow the below graph)

Support Vectors are the co-ordinates of individual observations.

Q. Implement the KNN classification algorithm.

In the following code snippet, we are using Iris dataset to implement the KNN classification algorithm.

# KNN classification algorithm

from sklearn.datasets import load_iris

from sklearn.neighbors import KNeighborsClassifier

import numpy as np

from sklearn.model_selection import train_test_split

iris_dataset=load_iris()

X_train, X_test, Y_train, Y_test = train_test_split(iris_dataset[“data”], iris_dataset[“target”], random_state=0)

kn = KNeighborsClassifier(n_neighbors=1)

kn.fit(X_train, Y_train)

X_new = np.array([[8, 2.5, 1, 1.2]])

prediction = kn.predict(X_new)

print(“Predicted target value: {}\n”.format(prediction))

print(“Predicted feature name: {}\n”.format

(iris_dataset[“target_names”][prediction]))

print(“Test score: {:.2f}”.format(kn.score(X_test, Y_test)))

Output:

Predicted Target Name: [0]

Predicted Feature Name: [‘ Setosa’]

Test Score: 0.92

Q. What is cluster sampling?

Cluster sampling is a process of randomly selecting intact groups within a defined population sharing similar characteristics.

Cluster sampling is a probability sample where each unit is a cluster of elements.

In this, the total population is divided into groups known as clusters. The elements in these clusters are then sampled. If all the elements in these clusters are sampled then this is referred to as a “one-stage” cluster sampling plan. If in these clusters a random set of subgroups is selected, then it is called “two-stage” cluster sampling plan.

The common aim for the cluster sampling is to reduce the cost and attain a desired level of accuracy.

Now that we have discussed various Machine learning interview questions based on theory and algorithms, we will step up a bit and discuss certain machine learning questions based on real-life applications.

Read this section carefully because I am sure you will be asked most of the questions from this section.

To read more visit verzeo.in

Originally published at https://www.verzeo.in.

--

--

Verzeo
Verzeo

No responses yet