Â
Â
1. What Are the Different Types of Machine Learning?
Â
Â
Supervised Learning
Â
Â
Â
Unsupervised Learning
Â
Â
Â
Reinforcement Learning
Â
UsingÂ reinforcement learning, the model can learn based on the rewards it received for its previous action.
Â
Â
Consider an environment where an agent is working. The agent is given a target to achieve. Every time the agent takes some action toward the target, it is given positive feedback. And, if the action taken is going away from the goal, the agent is given negative feedback.Â
Â
2. What is Overfitting, and How Can You Avoid It?Â
Â
TheÂ OverfittingÂ is a situation that occurs when a model learns the training set too well, taking up random fluctuations in the training data as concepts. These impact the modelâ€™s ability to generalize and donâ€™t apply to new data.Â
Â
When a model is given the training data, it shows 100 percent accuracyâ€”technically a slight loss. But, when we use the test data, there may be an error and low efficiency. This condition is known as overfitting.
Â
There are multiple ways of avoiding overfitting, such as:
Â

 Regularization. It involves a cost term for the features involved with the objective function

 Making a simple model. With lesser variables and parameters, the variance can be reducedÂ

 Crossvalidation methods like kfolds can also be used

 If some model parameters are likely to cause overfitting, techniques for regularization like LASSO can be used that penalize these parameters
Â
3. What is â€˜training Setâ€™ and â€˜test Setâ€™ in a Machine Learning Model? How Much Data Will You Allocate for Your Training, Validation, and Test Sets?
Â
There is a threestep process followed to create a model:
Â

 Train the model

 Test the modelÂ

 Deploy the model
Â
Training Set  Test Set 
The training set is examples given to the model to analyze and learn70% of the total data is typically taken as the training dataset. This is labeled data used to train the model  The test set is used to test the accuracy of the hypothesis generated by the model. Remaining 30% is taken as testing dataset. We test without labeled data and then verify results with labels 
Â
Consider a case where you have labeled data for 1,000 records. One way to train the model is to expose all 1,000 records during the training process. Then you take a small set of the same data to test the model, which would give good results in this case.
Â
But, this is not an accurate way of testing. So, we set aside a portion of that data called the â€˜test setâ€™ before starting the training process. The remaining data is called the â€˜training setâ€™ that we use for training the model. The training set passes through the model multiple times until the accuracy is high, and errors are minimized.
Â
Â
Now, we pass the test data to check if the model can accurately predict the values and determine if training is effective. If you get errors, you either need to change your model or retrain it with more data.
Â
Â
Regarding the question of how to split the data into a training set and test set, there is no fixed rule, and the ratio can vary based on individual preferences.Â
Â
4. How Do You Handle Missing or Corrupted Data in a Dataset?
Â
One of the easiest ways to handle missing or corrupted data is to drop those rows or columns or replace them entirely with some other value.
Â
There are two useful methods in Pandas:
Â

 IsNull() and dropna() will help to find the columns/rows with missing data and drop them

 Fillna() will replace the wrong values with a placeholder value
Â
Â
5. How Can You Choose a Classifier Based on a Training Set Data Size?
Â
When the training set is small, a model that has a right bias and low variance seems to work better because they are less likely to overfit.Â
Â
For example,Â Naive BayesÂ works best when the training set is large. Models with low bias and high variance tend to perform better as they work fine with complex relationships.
Â
6. Explain the Confusion Matrix with Respect to Machine Learning Algorithms.
Â
AÂ confusion matrixÂ (or error matrix) is a specific table that is used to measure the performance of an algorithm. It is mostly used in supervised learning; in unsupervised learning, itâ€™s called the matching matrix.
Â
The confusion matrix has two parameters:
Â

 Actual

 PredictedÂ
Â
It also has identical sets of features in both of these dimensions.
Â
Consider a confusion matrix (binary matrix) shown below:
Â
Â
Here,
Â
For actual values:
Â
Total Yes = 12+1 = 13
Â
Total No = 3+9 = 12Â
Â
Similarly, for predicted values:
Â
Total Yes = 12+3 = 15
Â
Total No = 1+9 = 10Â
Â
For a model to be accurate, the values across the diagonals should be high. The total sum of all the values in the matrix equals the total observations in the test data set.Â
Â
For the above matrix, total observations = 12+3+1+9 = 25
Â
Now, accuracy = sum of the values across the diagonal/total dataset
Â
= (12+9) / 25
Â
= 21 / 25
Â
= 84%
Â
Â
Â
7. What Is a False Positive and False Negative and How Are They Significant?
Â
False positives are those cases that wrongly get classified as True but are False.Â
Â
False negatives are those cases that wrongly get classified as False but are True.
Â
In the term â€˜False Positive,â€™ the word â€˜Positiveâ€™ refers to the â€˜Yesâ€™ row of the predicted value in the confusion matrix. The complete term indicates that the system has predicted it as a positive, but the actual value is negative.Â
Â
Â
So, looking at the confusion matrix, we get:
Â
Falsepositive = 3
Â
True positive = 12
Â
Similarly, in the term â€˜False Negative,â€™ the word â€˜Negativeâ€™ refers to the â€˜Noâ€™ row of the predicted value in the confusion matrix. And the complete term indicates that the system has predicted it as negative, but the actual value is positive.
Â
So, looking at the confusion matrix, we get:
Â
False Negative = 1
Â
True Negative = 9
Â
8. What Are the Three Stages of Building a Model in Machine Learning?
Â
The three stages of building aÂ machine learning modelÂ are:
Â
Model Building
Â

 Choose a suitable algorithm for the model and train it according to the requirementÂ
Â
Model Testing
Â

 Check the accuracy of the model through the test dataÂ
Â
Applying the Model
Â

 Make the required changes after testing and use the final model for realtime projects
Â
Here, itâ€™s important to remember that once in a while, the model needs to be checked to make sure itâ€™s working correctly. It should be modified to make sure that it is uptodate.
Â
9. What is Deep Learning?
Â
TheÂ Deep learningÂ is a subset of machine learning that involves systems that think and learn like humans using artificial neural networks. The term â€˜deepâ€™ comes from the fact that you can have several layers of neural networks.Â
Â
One of the primaryÂ differences between machine learning and deep learningÂ is that feature engineering is done manually in machine learning. In the case of deep learning, the model consisting of neural networks will automatically determine which features to use (and which not to use).Â
Â
This is a commonly asked question asked in both Machine Learning Interviews as well asÂ Deep Learning Interview Questions
Â
10. What Are the Differences Between Machine Learning and Deep Learning?
Â
Learn more:Â Difference Between AI,ML and Deep Learning
Â
Machine LearningÂ  Deep Learning 
Enables machines to take decisions on their own, based on past data needs only a small amount of data for training works well on the lowend system, so you don’t need large machinesÂ Most features need to be identified in advance and manually coded. The problem is divided into two parts and solved individually and then combined  Enables machines to take decisions with the help of artificial Neural networks. It needs a large amount of training dataÂ Needs highend machines because it requires a lot of computing powerÂ The machine learns the features from the data it is provided the problem is solved in an endtoend manner 
Â
Artificial Intelligence Interview Questions
Â
11. What Are the Applications of Supervised Machine Learning in Modern Businesses?
Â
Applications of supervised machine learning include:
Â
Email Spam Detection
Â

 Here we train the model using historical data that consists of emails categorized as spam or not spam. This labeled information is fed as input to the model.
Â
Healthcare Diagnosis
Â

 By providing images regarding a disease, a model can be trained to detect if a person is suffering from the disease or not.
Â
Sentiment Analysis
Â

 This refers to the process of using algorithms to mine documents and determine whether theyâ€™re positive, neutral, or negative in sentiment.Â
Â
Fraud Detection
Â

 By training the model to identify suspicious patterns, we can detect instances of possible fraud.
Â
Related Interview Questions and Answers
Â
AIÂ Â Data Science
Â
12. What is Semisupervised Machine Learning?
Â
Supervised learning uses data that is completely labeled, whereas unsupervised learning uses no training data.
Â
In the case of semisupervised learning, the training data contains a small amount of labeled data and a large amount of unlabeled data.
Â
Â
13. What Are Unsupervised Machine Learning Techniques?Â
Â
There are two techniques used in unsupervised learning: clustering and association.
Â
Clustering
Â
Clustering problems involve data to be divided into subsets. These subsets, also called clusters, contain data that are similar to each other. Different clusters reveal different details about the objects, unlike classification or regression.
Â
Â
Association
Â
In an association problem, we identify patterns of associations between different variables or items.
Â
For example, an ecommerce website can suggest other items for you to buy, based on the prior purchases that you have made, spending habits, items in your wishlist, other customersâ€™ purchase habits, and so on.
Â
Â
14. What is the Difference Between Supervised and Unsupervised Machine Learning?
Â

 Supervised learning – This model learns from the labeled data and makes a future prediction as outputÂ

 Unsupervised learning – This model uses unlabeled input data and allows the algorithm to act on that information without guidance.
Â
15. What is the Difference Between Inductive Machine Learning and Deductive Machine Learning?Â
Â
Inductive Learning  Deductive Learning 
It observes instances based on defined principles to draw a conclusionExample: Explaining to a child to keep away from the fire by showing a video where fire causes damage  It concludes experiencesExample: Allow the child to play with fire. If he or she gets burned, they will learn that it is dangerous and will refrain from making the same mistake again 
Â
16. Compare Kmeans and KNN Algorithms.
Â
Kmeans  KNN 
KMeansÂ is unsupervisedKMeans is a clustering algorithmThe points in each cluster are similar to each other, and each cluster is different from its neighboring clusters  KNNÂ is supervised in natureKNN is a classification algorithmIt classifies an unlabeled observation based on its K (can be any number) surrounding neighbors 
Â
17. What Is â€˜naiveâ€™ in the Naive Bayes Classifier?
Â
The classifier is called â€˜naiveâ€™ because it makes assumptions that may or may not turn out to be correct.Â
Â
The algorithm assumes that the presence of one feature of a class is not related to the presence of any other feature (absolute independence of features), given the class variable.
Â
For instance, a fruit may be considered to be a cherry if it is red in color and round in shape, regardless of other features. This assumption may or may not be right (as an apple also matches the description).
Â
18. Explain How a System Can Play a Game of Chess Using Reinforcement Learning.
Â
Reinforcement learning has an environment and an agent. The agent performs some actions to achieve a specific goal. Every time the agent performs a task that is taking it towards the goal, it is rewarded. And, every time it takes a step that goes against that goal or in the reverse direction, it is penalized.Â
Â
Earlier, chess programs had to determine the best moves after much research on numerous factors. Building a machine designed to play such games would require many rules to be specified.Â
Â
With reinforced learning, we donâ€™t have to deal with this problem as the learning agent learns by playing the game. It will make a move (decision), check if itâ€™s the right move (feedback), and keep the outcomes in memory for the next step it takes (learning). There is a reward for every correct decision the system takes and punishment for the wrong one.Â
Â
19. How Will You Know Which Machine Learning Algorithm to Choose for Your Classification Problem?
Â
While there is no fixed rule to choose an algorithm for a classification problem, you can follow these guidelines:
Â

 If accuracy is a concern, test different algorithms and crossvalidate them

 If the training dataset is small, use models that have low variance and high bias

 If the training dataset is large, use models that have high variance and little bias
Â
20. How is Amazon Able to Recommend Other Things to Buy? How Does the Recommendation Engine Work?
Â
Once a user buys something from Amazon, Amazon stores that purchase data for future reference and finds products that are most likely also to be bought, it is possible because of the Association algorithm, which can identify patterns in a given dataset.Â
Â
Â
21. When Will You Use Classification over Regression?
Â
Classification is used when your target is categorical, while regression is used when your target variable is continuous. Both classification and regression belong to the category of supervisedÂ machine learning algorithms.Â
Â
Examples of classification problems include:
Â

 Predicting yes or no

 Estimating gender

 Breed of an animal

 Type of color
Â
Examples of regression problems include:
Â

 Estimating sales and price of a product

 Predicting the score of a team

 Predicting the amount of rainfall
Â
22. How Do You Design an Email Spam Filter?
Â
Building a spam filter involves the following process:
Â

 The email spam filter will be fed with thousands of emailsÂ

 Each of these emails already has a label: â€˜spamâ€™ or â€˜not spam.â€™

 The supervised machine learning algorithm will then determine which type of emails are being marked as spam based on spam words like the lottery, free offer, no money, full refund, etc.

 The next time an email is about to hit your inbox, the spam filter will use statistical analysis and algorithms likeÂ Decision TreesÂ andÂ SVMÂ to determine how likely the email is spam

 If the likelihood is high, it will label it as spam, and the email wonâ€™t hit your inbox

 Based on the accuracy of each model, we will use the algorithm with the highest accuracy after testing all the models
Â
Â
23. What is a Random Forest?
Â
AÂ â€˜random forestâ€™ is a supervised machine learning algorithm that is generally used for classification problems. It operates by constructing multiple decision trees during the training phase. The random forest chooses the decision of the majority of the trees as the final decision.Â
Â
Â
24. Considering a Long List of Machine Learning Algorithms, given a Data Set, How Do You Decide Which One to Use?
Â
There is no master algorithm for all situations. Choosing an algorithm depends on the following questions:
Â

 How much data do you have, and is it continuous or categorical?

 Is the problem related to classification, association, clustering, or regression?

 Predefined variables (labeled), unlabeled, or mix?

 What is the goal?
Â
Based on the above questions, the following algorithms can be used:
Â
Â
Â
25. What is Bias and Variance in a Machine Learning Model?
Â
Bias
Â
Bias in a machine learning model occurs when the predicted values are further from the actual values. Low bias indicates a model where the prediction values are very close to the actual ones.
Â
Underfitting: High bias can cause an algorithm to miss the relevant relations between features and target outputs.Â
Â
Variance
Â
Variance refers to the amount the target model will change when trained with different training data. For a good model, the variance should be minimized.Â
Â
Overfitting: High variance can cause an algorithm to model the random noise in the training data rather than the intended outputs.
Â
26. What is the Tradeoff Between Bias and Variance?
Â
TheÂ biasvarianceÂ decomposition essentially decomposes the learning error from any algorithm by adding the bias, variance, and a bit of irreducible error due to noise in the underlying dataset.Â
Â
Necessarily, if you make the model more complex and add more variables, youâ€™ll lose bias but gain variance. To get the optimallyreduced amount of error, youâ€™ll have to trade off bias and variance. Neither high bias nor high variance is desired.
Â
High bias and low variance algorithms train models that are consistent, but inaccurate on average.
Â
High variance and low bias algorithms train models that are accurate but inconsistent.Â
Â
27. Define Precision and Recall.
Â
Precision
Â
Precision is the ratio of several events you can correctly recall to the total number of events you recall (mix of correct and wrong recalls).
Â
Precision = (True Positive) / (True Positive + False Positive)
Â
Recall
Â
A recall is the ratio of the number of events you can recall the number of total events.
Â
Recall = (True Positive) / (True Positive + False Negative)
Â
Â
28. What is a Decision Tree Classification?
Â
AÂ decision tree builds classificationÂ (or regression) models as a tree structure, with datasets broken up into eversmaller subsets while developing the decision tree, literally in a treelike way with branches and nodes. Decision trees can handle both categorical and numerical data.Â
Â
29. What is Pruning in Decision Trees, and How Is It Done?
Â
Pruning is aÂ technique in machine learningÂ that reduces the size of decision trees. It reduces the complexity of the final classifier, and hence improves predictive accuracy by the reduction of overfitting.Â
Â
Pruning can occur in:
Â

 Topdown fashion. It will traverse nodes and trim subtrees starting at the root

 Bottomup fashion. It will begin at the leaf nodes
Â
There is a popular pruning algorithm called reduced error pruning, in which:
Â

 Starting at the leaves, each node is replaced with its most popular class

 If the prediction accuracy is not affected, the change is kept

 There is an advantage of simplicity and speed
Â
30. Briefly Explain Logistic Regression.
Â
Logistic regressionÂ is a classification algorithm used to predict a binary outcome for a given set of independent variables.Â
Â
The output of logistic regression is either a 0 or 1 with a threshold value of generally 0.5. Any value above 0.5 is considered as 1, and any point below 0.5 is considered as 0.
Â
Â
31. Explain the K Nearest Neighbor Algorithm.Â
Â
K nearest neighbor algorithmÂ is a classification algorithm that works in a way that a new data point is assigned to a neighboring group to which it is most similar.Â
Â
In K nearest neighbors, K can be an integer greater than 1. So, for every new data point, we want to classify, we compute to which neighboring group it is closest.Â
Â
Let us classify an object using the following example. Consider there are three clusters:
Â

 Football

 BasketballÂ

 Tennis ball
Â
Â
Let the new data point to be classified is a black ball. We use KNN to classify it. Assume K = 5 (initially).Â
Â
Next, we find the K (five) nearest data points, as shown.
Â
Â
Observe that all five selected points do not belong to the same cluster. There are three tennis balls and one each of basketball and football.Â
Â
When multiple classes are involved, we prefer the majority. Here the majority is with the tennis ball, so the new data point is assigned to this cluster.
Â
32. What is a Recommendation System?
Â
Anyone who has used Spotify or shopped at Amazon will recognize a recommendation system: Itâ€™s an information filtering system that predicts what a user might want to hear or see based on choice patterns provided by the user.
Â
33. What is Kernel SVM?
Â
Kernel SVM is the abbreviated version of the kernel support vector machine. Kernel methods are a class of algorithms for pattern analysis, and the most common one is the kernel SVM.
Â
34. What Are Some Methods of Reducing Dimensionality?
Â
You can reduce dimensionality by combining features with feature engineering, removing collinear features, or using algorithmic dimensionality reduction.
Â
Now that you have gone through these machine learning interview questions, you must have got an idea of your strengths and weaknesses in this domain.
Â
35. What is Principal Component Analysis?
Â
Principal Component Analysis or PCA is a multivariate statistical technique that is used for analyzing quantitative data. The objective of PCA is to reduce higher dimensional data to lower dimensions, remove noise, and extract crucial information such as features and attributes from large amounts of data.
Â
36. What do you understand by the F1 score?
Â
The F1 score is a metric that combines both Precision and Recall. It is also the weighted average of precision and recall.Â
Â
The F1 score can be calculated using the below formula:
Â
F1 = 2 * (P * R) / (P + R)
Â
The F1 score is one when both Precision and Recall scores are one.
Â
37. What do you understand by Type I vs Type II error?
Â
Type I Error: Type I error occurs when the null hypothesis is true and we reject it.
Â
Type II Error: Type II error occurs when the null hypothesis is false and we accept it.
Â
Â
38. Explain Correlation and Covariance?
Â
Correlation: Correlation tells us how strongly two random variables are related to each other. It takes values between 1 to +1.Â
Â
Formula to calculate Correlation:
Â
Â
Covariance: Covariance tells us the direction of the linear relationship between two random variables. It can take any value between – âˆž and + âˆž.
Â
Formula to calculate Covariance:
Â
Â
39. What are Support Vectors in SVM?
Â
Support Vectors are data points that are nearest to the hyperplane. It influences the position and orientation of the hyperplane. Removing the support vectors will alter the position of the hyperplane. The support vectors help us build our support vector machine model.
Â
Â
40. What is Ensemble learning?
Â
Ensemble learning is a combination of the results obtained from multiple machine learning models to increase the accuracy for improved decisionmaking.Â
Â
Example: A Random Forest with 100 trees can provide much better results than using just one decision tree.
Â
Â
41. What is CrossValidation?
Â
CrossValidation in Machine Learning is a statistical resampling technique that uses different parts of the dataset to train and test a machine learning algorithm on different iterations. The aim of crossvalidation is to test the modelâ€™s ability to predict a new set of data that was not used to train the model. Crossvalidation avoids the overfitting of data.
Â
KFold Cross Validation is the most popular resampling technique that divides the whole dataset into K sets of equal sizes.
Â
42. What are the different methods to split a tree in a decision tree algorithm?
Â
Variance: Splitting the nodes of a decision tree using the variance is done when the target variable is continuous.
Â
Â
Information Gain: Splitting the nodes of a decision tree using Information Gain is preferred when the target variable is categorical.
Â
Â
Gini Impurity: Splitting the nodes of a decision tree using Gini Impurity is followed when the target variable is categorical.
Â
Â
43. How does the Support Vector Machine algorithm handle selflearning?Â
Â
TheÂ SVM algorithmÂ has a learning rate and expansion rate which takes care of selflearning. The learning rate compensates or penalizes the hyperplanes for making all the incorrect moves while the expansion rate handles finding the maximum separation area between different classes.
Â
44. What are the assumptions you need to take before starting with linear regression?
Â
There are primarily 5 assumptions for a Linear Regression model:
Â

 Multivariate normality

 No autocorrelation

 Homoscedasticity

 Linear relationship

 No or little multicollinearity
Â
45. What is the difference between Lasso and Ridge regression?
Â
Lasso(also known as L1) and Ridge(also known as L2) regression are two popular regularization techniques that are used to avoid overfitting of data. These methods are used to penalize the coefficients to find the optimum solution and reduce complexity. The Lasso regression works by penalizing the sum of the absolute values of the coefficients. In Ridge or L2 regression, the penalty function is determined by the sum of the squares of the coefficients.
Â
Looking forward to a successful career in AI and Machine learning. Enrol in our AI and ML PG Program in collaboration with Purdue University now.
Â