40 Questions to test a Data Scientist on Machine Learning
Instead of using 1-NN black box we want to use the j-NN (j>1) algorithm as black box. Which of the following option is correct for finding k-NN using j-NN? J must be a proper factor of k J > k Not possible A) 1 B) 2 C) 3
(A)
2) Which of the following is an example of a deterministic algorithm? A) PCA B) K-Means C) None of the above
(A) A deterministic algorithm is that in which output does not change on different runs. PCA would give the same result if we run again, but not k-means.
Adding a non-important feature to a linear regression model may result in. Increase in R-square Decrease in R-square A) Only 1 is correct B) Only 2 is correct C) Either 1 or 2 D) None of these
(A) After adding a feature in feature space, whether that feature is important or unimportant features the R-squared always increase.
Suppose we have a dataset which can be trained with 100% accuracy with help of a decision tree of depth 6. Now consider the points below and choose the option based on these points. Note: All other hyper parameters are same and other factors are not affected. Depth 4 will have high bias and low variance Depth 4 will have low bias and low variance A) Only 1 B) Only 2 C) Both 1 and 2 D) None of the above
(A) If you fit decision tree of depth 4 in such data means it will more likely to underfit the data. So, in case of underfitting you will have high bias and low variance.
Which of the following statement(s) is / are true for Gradient Decent (GD) and Stochastic Gradient Decent (SGD)? In GD and SGD, you update a set of parameters in an iterative manner to minimize the error function. In SGD, you have to run through all the samples in your training set for a single update of a parameter in each iteration. In GD, you either use the entire data or a subset of training data to update a parameter in each iteration. A) Only 1 B) Only 2 C) Only 3 D) 1 and 2 E) 2 and 3 F) 1,2 and 3
(A) In SGD for each iteration you choose the batch which is generally contain the random sample of data But in case of GD each iteration contain the all of the training observations.
Assume there is a black box algorithm, which takes training data with multiple observations (t1, t2, t3,........ tn) and a new observation (q1). The black box outputs the nearest neighbor of q1 (say ti) and its corresponding class label ci. You can also think that this black box algorithm is same as 1-NN (1-nearest neighbor). It is possible to construct a k-NN classification algorithm based on this black box alone. Note: Where n (number of training observations) is very large compared to k. A) TRUE B) FALSE
(A) In first step, you pass an observation (q1) in the black box algorithm so this algorithm would return a nearest observation and its class. In second step, you through it out nearest observation from train data and again input the observation (q1). The black box algorithm will again return the a nearest observation and it's class. You need to repeat this procedure k times
Imagine, you are solving a classification problems with highly imbalanced class. The majority class is observed 99% of times in the training data. Your model has 99% accuracy after taking the predictions on test data. Which of the following is true in such a case? Accuracy metric is not a good idea for imbalanced class problems. Accuracy metric is a good idea for imbalanced class problems. Precision and recall metrics are good for imbalanced class problems. Precision and recall metrics aren't good for imbalanced class problems. A) 1 and 3 B) 1 and 4 C) 2 and 3 D) 2 and 4
(A) Refer the question number 4 from in this article.
Imagine, you have a 28 * 28 image and you run a 3 * 3 convolution neural network on it with the input depth of 3 and output depth of 8. Note: Stride is 1 and you are using same padding. What is the dimension of output feature map when you are using the given parameters. A) 28 width, 28 height and 8 depth B) 13 width, 13 height and 8 depth C) 28 width, 13 height and 8 depth D) 13 width, 28 height and 8 depth
(A) The formula for calculating output size is output size = (N - F)/S + 1 where, N is input size, F is filter size and S is stride. Read this article to get a better understanding.
Below are the 8 actual values of target variable in the train file. [0,0,0,1,1,1,1,1] What is the entropy of the target variable? A) -(5/8 log(5/8) + 3/8 log(3/8)) B) 5/8 log(5/8) + 3/8 log(3/8) C) 3/8 log(5/8) + 5/8 log(3/8) D) 5/8 log(3/8) - 3/8 log(5/8)
(A) The formula for entropy is So the answer is A.
In ensemble learning, you aggregate the predictions for weak learners, so that an ensemble of these models will give a better prediction than prediction of individual models. Which of the following statements is / are true for weak learners used in ensemble model? They don't usually overfit. They have high bias, so they cannot solve complex learning problems They usually overfit. A) 1 and 2 B) 1 and 3 C) 2 and 3 D) Only 1 E) Only 2 F) None of the above
(A) Weak learners are sure about particular part of a problem. So, they usually don't overfit which means that weak learners have low variance and high bias.
What would you do in PCA to get the same projection as SVD? A) Transform data to zero mean B) Transform data to zero median C) Not possible D) None of these
(A) When the data has a zero mean vector PCA will have same projections as SVD, otherwise you have to centre the data first before taking SVD.
[True or False] A Pearson correlation between two variables is zero but, still their values can still be related to each other.
(A) Y=X2. Note that, they are not only associated, but one is a function of the other and Pearson correlation between them is 0.
Imagine, you are working with "Analytics Vidhya" and you want to develop a machine learning algorithm which predicts the number of views on the articles. Your analysis is based on features like author name, number of articles written by the same author on Analytics Vidhya in past and a few other features. Which of the following evaluation metric would you choose in that case? Mean Square Error Accuracy F1 Score A) Only 1 B) Only 2 C) Only 3 D) 1 and 3 E) 2 and 3 F) 1 and 2
(A) You can think that the number of views of articles is the continuous target variable which fall under the regression problem. So, mean squared error will be used as an evaluation metrics.
Imagine, you have a 28 * 28 image and you run a 3 * 3 convolution neural network on it with the input depth of 3 and output depth of 8. Note: Stride is 1 and you are using same padding. What is the dimensions of output feature map when you are using following parameters. A) 28 width, 28 height and 8 depth B) 13 width, 13 height and 8 depth C) 28 width, 13 height and 8 depth D) 13 width, 28 height and 8 depth
(B)
[True or False] LogLoss evaluation metric can have negative values. A) TRUE B) FALSE
(B) Log loss cannot have negative values.
A feature F1 can take certain value: A, B, C, D, E, & F and represents grade of students from a college. 1) Which of the following statement is true in following case? A) Feature F1 is an example of nominal variable. B) Feature F1 is an example of ordinal variable. C) It doesn't belong to any of the above category. D) Both of these
(B) Ordinal variables are the variables which has some order in their categories. For example, grade A should be consider as high grade than grade B.
Let's say, you are using activation function X in hidden layers of neural network. At a particular neuron for any given input, you get the output as "-0.0001". Which of the following activation function could X represent? A) ReLU B) tanh C) SIGMOID D) None of these
(B) The function is a tanh because the this function output range is between (-1,-1).
Which of the following hyper parameter(s), when increased may cause random forest to over fit the data? Number of Trees Depth of Tree Learning Rate A) Only 1 B) Only 2 C) Only 3 D) 1 and 2 E) 2 and 3 F) 1,2 and 3
(B) Usually, if we increase the depth of tree it will cause overfitting. Learning rate is not an hyperparameter in random forest. Increase in the number of tree will cause under fitting.
Suppose you want to project high dimensional data into lower dimensions. The two most famous dimensionality reduction algorithms used here are PCA and t-SNE. Let's say you have applied both algorithms respectively on data "X" and you got the datasets "X_projected_PCA" , "X_projected_tSNE". Which of the following statements is true for "X_projected_PCA" & "X_projected_tSNE" ? A) X_projected_PCA will have interpretation in the nearest neighbour space. B) X_projected_tSNE will have interpretation in the nearest neighbour space. C) Both will have interpretation in the nearest neighbour space. D) None of them will have interpretation in the nearest neighbour space.
(B) t-SNE algorithm consider nearest neighbour points to reduce the dimensionality of the data. So, after using t-SNE we can think that reduced dimensions will also have interpretation in nearest neighbour space. But in case of PCA it is not the case.
Cross-validation is an important step in machine learning for hyper parameter tuning. Let's say you are tuning a hyper-parameter "max_depth" for GBM by selecting it from 10 different depth values (values are greater than 2) for tree based model using 5-fold cross validation. Time taken by an algorithm for training (on a model with max_depth 2) 4-fold is 10 seconds and for the prediction on remaining 1-fold is 2 seconds. In previous question, if you train the same algorithm for tuning 2 hyper parameters say "max_depth" and "learning_rate". You want to select the right value against "max_depth" (from given 10 depth values) and learning rate (from given 5 different learning rates). In such cases, which of the following will represent the overall time? A) 1000-1500 second B) 1500-3000 Second C) More than or equal to 3000 Second D) None of these
(D)
Which of the following options can be used to get global minima in k-Means Algorithm? 1. Try to run algorithm for different centroid initialization 2. Adjust number of iterations 3. Find out the optimal number of clusters A) 2 and 3 B) 1 and 3 C) 1 and 2 D) All of above
(D) All of the option can be tuned to find the global minima.
Let's say, you are working with categorical feature(s) and you have not looked at the distribution of the categorical variable in the test data. You want to apply one hot encoding (OHE) on the categorical feature(s). What challenges you may face if you have applied OHE on a categorical variable of train dataset? A) All categories of categorical variable are not present in the test dataset. B) Frequency distribution of categories is different in train as compared to the test dataset. C) Train and Test always have same distribution. D) Both A and B E) None of these
(D) Both are true, The OHE will fail to encode the categories which is present in test but not in train so it could be one of the main challenges while applying OHE. The challenge given in option B is also true you need to more careful while applying OHE if frequency distribution doesn't same in train and test.
Cross-validation is an important step in machine learning for hyper parameter tuning. Let's say you are tuning a hyper-parameter "max_depth" for GBM by selecting it from 10 different depth values (values are greater than 2) for tree based model using 5-fold cross validation. Time taken by an algorithm for training (on a model with max_depth 2) 4-fold is 10 seconds and for the prediction on remaining 1-fold is 2 seconds. Note: Ignore hardware dependencies from the equation. 23) Which of the following option is true for overall execution time for 5-fold cross validation with 10 different values of "max_depth"? A) Less than 100 seconds B) 100 - 300 seconds C) 300 - 600 seconds D) More than or equal to 600 seconds C) None of the above D) Can't estimate
(D) Each iteration for depth "2" in 5-fold cross validation will take 10 secs for training and 2 second for testing. So, 5 folds will take 12*5 = 60 seconds. Since we are searching over the 10 depth values so the algorithm would take 60*10 = 600 seconds. But training and testing a model on depth greater than 2 will take more time than depth "2" so overall timing would be greater than 600.
Which of the following options is/are true for K-fold cross-validation? Increase in K will result in higher time required to cross validate the result. Higher values of K will result in higher confidence on the cross-validation result as compared to lower value of K. If K=N, then it is called Leave one out cross validation, where N is the number of observations. A) 1 and 2 B) 2 and 3 C) 1 and 3 D) 1,2 and 3
(D) Larger k value means less bias towards overestimating the true expected error (as training folds will be closer to the total dataset) and higher running time (as you are getting closer to the limit case: Leave-One-Out CV). We also need to consider the variance between the k folds accuracy while selecting the k.
Which of the following is/are one of the important step(s) to pre-process the text in NLP based projects? Stemming Stop word removal Object Standardization A) 1 and 2 B) 1 and 3 C) 2 and 3 D) 1,2 and 3
(D) Stemming is a rudimentary rule-based process of stripping the suffixes ("ing", "ly", "es", "s" etc) from a word. Stop words are those words which will have not relevant to the context of the data for example is/am/are. Object Standardization is also one of the good way to pre-process the text.
Suppose, you are given three variables X, Y and Z. The Pearson correlation coefficients for (X, Y), (Y, Z) and (X, Z) are C1, C2 & C3 respectively. Now, you have added 2 in all values of X (i.enew values become X+2), subtracted 2 from all values of Y (i.e. new values are Y-2) and Z remains the same. The new coefficients for (X,Y), (Y,Z) and (X,Z) are given by D1, D2 & D3 respectively. How do the values of D1, D2 & D3 relate to C1, C2 & C3? A) D1= C1, D2 < C2, D3 > C3 B) D1 = C1, D2 > C2, D3 > C3 C) D1 = C1, D2 > C2, D3 < C3 D) D1 = C1, D2 < C2, D3 < C3 E) D1 = C1, D2 = C2, D3 = C3 F) Cannot be determined
(E) Correlation between the features won't change if you add or subtract a value in the features.
For which of the following hyperparameters, higher value is better for decision tree algorithm? 1. Number of samples used for split 2. Depth of tree 3. Samples for leaf A)1 and 2 B) 2 and 3 C) 1 and 3 D) 1, 2 and 3 E) Can't say
(E) For all three options A, B and C, it is not necessary that if you increase the value of parameter the performance may increase. For example, if we have a very high value of depth of tree, the resulting tree may overfit the data, and would not generalize well. On the other hand, if we have a very low value, the tree may underfit the data. So, we can't say for sure that "higher is better".
Which of the following statements is/are true about "Type-1" and "Type-2" errors? Type1 is known as false positive and Type2 is known as false negative. Type1 is known as false negative and Type2 is known as false positive. Type1 error occurs when we reject a null hypothesis when it is actually true. A) Only 1 B) Only 2 C) Only 3 D) 1 and 2 E) 1 and 3 F) 2 and 3
(E) In statistical hypothesis testing, a type I error is the incorrect rejection of a true null hypothesis (a "false positive"), while a type II error is incorrectly retaining a false null hypothesis (a "false negative").