5 Most Asked ML Interview Questions
This article contains five most asked questions ML interview questions that you must not at all skip if you want to ace your Interviews.
Table of contents
No headings in the article.
Ques1: What is K in K-Means? How do you arrive at an optimal K? What is plotted in the X and Y axis of an Elbow plot? Explain what the Y-axis component means and how it is computed.
Ans: K in K-means is the number of clusters. To arrive at an optimal number of clusters elbow method is used. In this method, a metric called WCSS (Within-Cluster-Sum of Squared Errors) is used. WCSS is the sum of the square of distances of a point from the centroids of predicted clusters. To measure distance euclidean or manhattan distance etc can be used. The Y-axis component is WCSS and the X-axis is 'k' i.e. different number of clusters. For the different number of clusters, the WCSS value is computed and a graph is plotted. The curve plotted pictorially looks like an elbow shape. Initially, there are massive drops or jumps in the graph and suddenly from a certain point smaller drops are that. That point is chosen to be the optimal number of clusters i.e. the actual 'K' in our K means clustering algorithm.
Ques2: How would you assess a Linear Regression model? In other words, how would you know if the model is good or bad? What parameters do you look for?
Ans: To assess a Linear Regression model there are multiple methods used. Some of them to mention here are MAE (Mean Absolute Error), MSE (Mean Squared Error), RMSE (Root mean squared error), R^2 and adjusted R^2. The mean absolute error is the total distance between the actual value and the predicted value divided by the total number of values. Mean squared error is the total of the square of distances between the actual value and predicted value divided by the total number of values and Root mean squared error is the square root of Mean Squared error. R^2 formula is [1-(SSres/ SStotal)]. SSres is the sum of residuals or errors and SStotal is the sum of the average total. To know whether a model is good or bad one of the above parameters can be used to evaluate the model. For eg is R^2 is used its value lies between 0 and 1. The nearer the value of R^2 is to 1, the better the model. The parameter we look for is whether the line is the best fit for the model. We try to minimize the error. The lesser the error, the better the model.
Ques3:How would you assess a Classification model?
Ans: To assess a classification model several performance metrics can be used such as confusion matrix, precision, recall, f1-score, etc. The confusion matrix is also known as the error matrix. In the confusion matrix a2x2 matrix is constructed where the rows represent the actual class and the columns represent the predicted class. The four types of error are True Positive, True Negatives, False positives and False negatives. True positive means the real value was positive and your model also predicted it to be positive. True negative is the real value was negative and your model predicted also predicted it to be negative. False positive is the actual value was negative but your model predicted it to be positive. A false negative is the actual value was positive but your model predicted it to be negative. Precision is TP divided by the sum of TP and FP. It tells us how accurate our model is. The recall is TP divided by the sum of TP and FN. It is also called sensitivity. The F1 score is the harmonic mean of precision and recall.
Ques4:What is the difference between Association and Clustering? Give examples.
Ans: In the clustering algorithm, the data values are segregated from one another based on similarities and are arranged in form of clusters. For eg., a mall may use customer data to recognize what category of customers spend more or less. They may maintain a dataset that has customer ID, gender age, annual income and how much they spend. Based on this they may conclude that people with low annual income spend less, the ones with high annual income may spend more and those who earn average may spend average. They may also identify two other groups of customers, the ones who earn less but spend more and the ones who earn more and spend less. These all data can be used to know which kind of customers should be targeted to increase sales. In association with learning the concept of "people who bought this also bought" kind of concept is used. In this rules are made based on parameters such as support, confidence and lift. For example, a mall may analyze all items their customer buy and they may find that many people buying bread also buy butter or people buying fruits buy vegetables. Then using this information they may place bread and butter together i.e. at one place and fruits and vegetables at one place so that people are likely to buy both items and this increases their sales.
Ques5:In a Linear Regression model, what is a 'coefficient estimate' and how do you interpret it? Also, how do you interpret the 'constant' in the equation?
Ans: In a linear regression model 'coefficient estimate' is the coefficient of the independent variable i.e. the unknown population parameter. The coefficient estimate characterizes the relationship between the predicted value and the independent variable. If the value of the coefficient is positive then it is understood that as the value of the independent variable increases the value of the result also increases whereas if the value of the coefficient is negative as the value of the independent variable increases the value of the result decreases. The constant value is the value that becomes the result or dependent variable in the case when all the independent variables' value together becomes 0.