Basics
Machine Learning
General Concepts In Machine Learning
Interview questions on General Concepts In Machine Learning.
72 questions
Basics
Q2. Empirical risk minimization.
- What’s the risk in empirical risk minimization?
- Why is it empirical?
- How do we minimize that risk?
Basics
Q3. What are the exhaustive steps we need to perform when tackling any generic machine learning problem, specifically for both regression and classification tasks?
Basics
Q4. Explain the tradeoff between model's flexibility vs interpretability?
Basics
Q5. Occam's razor states that when the simple explanation and complex explanation both work equally well, the simple explanation is usually correct. How do we apply this principle in ML?
Basics
Q6. If we have a wide NN and a deep NN with the same number of parameters, which one is more expressive and why?
Basics
Q7. The Universal Approximation Theorem states that a neural network with 1 hidden layer can approximate any continuous function for inputs within a specific range. Then why can’t a simple neural network reach an arbitrarily small positive error?
Basics
Q8. What are saddle points and local minima? Which are thought to cause more problems for training large NNs?
Basics
Q9. Hyper-parameters.
- What are the differences between parameters and hyper-parameters?
- Why is hyperparameter tuning important?
- List down methods for tuning hyper-parameters.
Basics
Q10. Classification vs. regression.
- What makes a classification problem different from a regression problem?
- Can a classification problem be turned into a regression problem and vice versa?
Basics
Q11. Parametric vs. non-parametric methods.
- What’s the difference between parametric methods and non-parametric methods? Give an example of each method.
- When should we use one and when should we use the other?
Basics
Q12. Why does an ML model’s performance degrade in production?
Basics
Q13. What problems might we run into when deploying large machine learning models?
Basics
Q14. Your model performs really well on the test set but poorly in production.
- What are your hypotheses about the causes?
- How do you validate whether your hypotheses are correct?
- Imagine your hypotheses about the causes are correct. What would you do to address them?
Basics
Q15. What are some common encoding techniques in machine learning?
Cross Validation
Q16. Below Fig depicts two different cross-validation approaches. Name them.
Cross Validation
Q17. 1. What is the purpose of following Python code snippet?
skf = StratifiedKFold(y, n_folds=5, random_state=989, shuffle=True)
```
2. Explain the benefits of using the K-fold cross validation approach.
3. Explain the benefits of using the Stratified K-fold cross validation approach.
4. State the difference between K-fold cross validation and stratified cross validation.
5. Explain in your own words what is meant by “We adopted a 5-fold cross-validation approach to estimate the testing error of the model”.
Cross Validation
Q18. **True or False:** In a K-fold CV approach, the testing set is completely excluded from the process and only the training and validation sets are involved in this approach.
Cross Validation
Q19. **True or False:** In a K-fold CV approach, the final test error is:
Cross Validation
Q20. Mark all the correct choices regarding a cross-validation approach:
- A 5-fold cross-validation approach results in 5-different model instances being fitted.
- A 5-fold cross-validation approach results in 1 model instance being fitted over and over again 5 times.
- A 5-fold cross-validation approach results in 5-different model instances being fitted over and over again 5 times.
- Uses K-different data-folds.
Cross Validation
Q21. Mark all the correct choices regarding the approach that should be taken to compute the performance of K-fold cross-validation:
- We compute the cross-validation performance as the arithmetic mean over the K performance estimates from the validation sets.
- We compute the cross-validation performance as the best one over the K performance estimates from the validation sets.
Cross Validation
Q22. A data-scientist who is interested in classifying cross sections of histopathology image slices decides to adopt a cross-validation approach he once read about in a book.
Cross Validation
Q23. 1. **True or false**: The leave-one-out cross-validation (LOOCV) approach is a sub-case of k-fold cross-validation wherein K equals N , the sample size.
- True or false: It is always possible to find an optimal value , in K-fold cross-validation.
Cross Validation
Q24. What is the main difference between RandomizedSearchCV and GridSearchCV?
Cross Validation
Q25. When would you prefer to use RandomizedSearchCV over GridSearchCV, and vice versa?
Cross Validation
Q26. What are the advantages of RandomizedSearchCV?
Cross Validation
Q27. What are the advantages of GridSearchCV?
Cross Validation
Q28. What is cross-validation in the context of hyperparameter tuning?
Cross Validation
Q29. Can you combine RandomizedSearchCV and GridSearchCV techniques for hyperparameter tuning?
Similarity Measures
Q30. A data scientist extracts a feature vector from an image using a pre-trained ResNet34 CNN as follows
import torchvision.models as models
...
res_model = models.resnet34(pretrained=True)
```
He then applies the following algorithm, entitled xxx on the image.
```python
import math
def xxx(arr):
mod = 0.0
for i in arr:
mod += i * i
mag = math.sqrt(mod)
for i in range(len(arr)):
arr[i] /= mag
# Example usage:
arr = [1.0, 2.0, 3.0]
xxx(arr)
print(arr)
```
Which results in this list:
<table align='center'>
<tr>
<td align="center">
<img src="img/similarity-1.png" style="max-width:70%;" />
</td>
</tr>
</table>
Name the algorithm that he used and explain in detail why he used it.
Similarity Measures
Q31. Further to the above, the scientist then applies the following algorithm:
Algo 1 Data: Two vectors v1 and v2 are provided Apply algorithm xxx on the two vectors Run algorithm 2 Algo 2
def algo2(v1, v2):
mul = 0.0
for i in range(len(v1)):
mul += v1[i] * v2[i]
if mul < 0:
return 0
return mul
- Name the algorithm algo2 that he used and explain in detail what he used it for.
- Write the mathematical formulae behind it.
- What are the minimum and maximum values it can return?
- An alternative similarity measures between two vectors is: . Name the measure.
Similarity Measures
Q32. 1. What is the formulae for the Jaccard similarity of two sets?
- Explain the formulae in plain words.
- Find the Jacard similarity given the sets.
Similarity Measures
Q33. In this problem, you have to actually read 4 different papers, so you will probably not encounter such a question during an interview, however reading academic papers is an excellent skill to master for becoming a DL researcher.
The Kullback-Leibler divergence is a meas- ure of how different two probability distribution are. As noted, the KL divergence of the probability distributions P, Q on a set X is defined as shown in Equation 8.11. Note however that since KL divergence is a non-symmetric information theoretical meas- ure of distance of P from Q, then it is not strictly a distance metric. During the past years, various KL based distance measures (rather than divergence based) have been introduced in the literature generalizing this measure. Name each of the following KL based distances:
Sampling Techniques and Creating Training Data
Q34. If you have 6 shirts and 4 pairs of pants, how many ways are there to choose 2 shirts and 1 pair of pants?
Sampling Techniques and Creating Training Data
Q35. What is the difference between sampling with vs. without replacement? Name an example of when you would use one rather than the other?
Sampling Techniques and Creating Training Data
Q36. Explain Markov chain Monte Carlo sampling.
Sampling Techniques and Creating Training Data
Q37. If you need to sample from high-dimensional data, which sampling method would you choose?
Sampling Techniques and Creating Training Data
Q38. Suppose we have a classification task with many classes. An example is when you have to predict the next word in a sentence -- the next word can be one of many, many possible words. If we have to calculate the probabilities for all classes, it’ll be prohibitively expensive. Instead, we can calculate the probabilities for a small set of candidate classes. This method is called candidate sampling. Name and explain some of the candidate sampling algorithms.
Sampling Techniques and Creating Training Data
Q39. Suppose you want to build a model to classify whether a Reddit comment violates the website’s rule. You have $10$ million unlabeled comments from $10K$ users over the last $24$ months and you want to label $100K$ of them.
- How would you sample comments to label?
- Suppose you get back labeled comments from annotators and you want to look at some labels to estimate the quality of the labels. How many labels would you look at? How would you sample them?
Sampling Techniques and Creating Training Data
Q40. Suppose you work for a news site that historically has translated only $1%$ of all its articles. Your coworker argues that we should translate more articles into Chinese because translations help with the readership. On average, your translated articles have twice as many views as your non-translated articles. What might be wrong with this argument?
Sampling Techniques and Creating Training Data
Q41. How to determine whether two sets of samples (e.g. train and test splits) come from the same distribution?
Sampling Techniques and Creating Training Data
Q42. How do you know you’ve collected enough samples to train your ML model?
Sampling Techniques and Creating Training Data
Q43. How to determine outliers in your data samples? What to do with them?
Sampling Techniques and Creating Training Data
Q44. Sample duplication
- When should you remove duplicate training samples? When shouldn’t you?
- What happens if we accidentally duplicate every data point in your train set or in your test set?
Sampling Techniques and Creating Training Data
Q45. Missing data
- In your dataset, two out of 20 variables have more than 30% missing values. What would you do?
- How might techniques that handle missing data make selection bias worse? How do you handle this bias?
Sampling Techniques and Creating Training Data
Q46. Why is randomization important when designing experiments (experimental design)?
Sampling Techniques and Creating Training Data
Q47. Class imbalance.
- How would class imbalance affect your model?
- Why is it hard for ML models to perform well on data with class imbalance?
- Imagine you want to build a model to detect skin legions from images. In your training dataset, only of your images shows signs of legions. After training, your model seems to make a lot more false negatives than false positives. What are some of the techniques you'd use to improve your model?
Sampling Techniques and Creating Training Data
Q48. Training data leakage.
- Imagine you're working with a binary task where the positive class accounts for only 1% of your data. You decide to oversample the rare class then split your data into train and test splits. Your model performs well on the test split but poorly in production. What might have happened?
- You want to build a model to classify whether a comment is spam or not spam. You have a dataset of a million comments over the period of 7 days. You decide to randomly split all your data into the train and test splits. Your co-worker points out that this can lead to data leakage. How?
Sampling Techniques and Creating Training Data
Q49. How does data sparsity affect your models?
Sampling Techniques and Creating Training Data
Q50. Feature leakage
- What are some causes of feature leakage?
- Why does normalization help prevent feature leakage?
- How do you detect feature leakage?
Sampling Techniques and Creating Training Data
Q51. Suppose you want to build a model to classify whether a tweet spreads misinformation. You have 100K labeled tweets over the last 24 months. You decide to randomly shuffle on your data and pick 80% to be the train split, 10% to be the valid split, and 10% to be the test split. What might be the problem with this way of partitioning?
Sampling Techniques and Creating Training Data
Q52. Your model has been performing fairly well using just a subset of features available in your data. Your boss decided that you should use all the features available instead. What might happen to the training error? What might happen to the test error?
Sampling Techniques and Creating Training Data
Q53. Convergence.
- When we say an algorithm converges, what does convergence mean?
- How do we know when a model has converged?
Sampling Techniques and Creating Training Data
Q54. Draw the loss curves for overfitting and underfitting.
Sampling Techniques and Creating Training Data
Q55. While working on a modeling use case, you notice that your model is underfitting. What steps would you take to address this issue?
Sampling Techniques and Creating Training Data
Q56. While working on a modeling use case, you observe that your model is overfitting. What steps would you take to resolve this?
Sampling Techniques and Creating Training Data
Q57. Bias-variance trade-off
- What’s the bias-variance trade-off?
- How’s this tradeoff related to overfitting and underfitting?
- How do you know that your model is high variance, low bias? What would you do in this case?
- How do you know that your model is low variance, high bias? What would you do in this case?
Sampling Techniques and Creating Training Data
Q58. What are the potential drawbacks of using the validation set approach for estimating the test error rate?
Sampling Techniques and Creating Training Data
Q59. Cross-validation.
- Explain different methods for cross-validation.
- Why don’t we see more cross-validation in deep learning?
Sampling Techniques and Creating Training Data
Q60. Is LOOCV a special case of k-fold CV?
Sampling Techniques and Creating Training Data
Q61. Explain the bias variance tradeoff with the choice of k in k-fold validation?
Sampling Techniques and Creating Training Data
Q62. Train, valid, test splits.
- What’s wrong with training and testing a model on the same data?
- Why do we need a validation set on top of a train set and a test set?
- Your model’s loss curves on the train, valid, and test sets look like this. What might have been the cause of this? What would you do?

Feature Engineering
Q63. Feature selection.
- Why do we use feature selection?
- What are some of the algorithms for feature selection? Pros and cons of each.
Feature Engineering
Q64. Is feature scaling necessary for kernel methods?
Feature Engineering
Q65. What are the different types of feature selection techniques?
Bias and Variance
Q66. Explain Bias and Variance?
Bias and Variance
Q67. Why is the bias-variance tradeoff important in machine learning?
Bias and Variance
Q68. How can you tell if your model has a high bias or high variance problem?
Bias and Variance
Q69. What are some techniques to reduce bias in a model?
Bias and Variance
Q70. What are some techniques to reduce variance in a model?
Bias and Variance
Q71. Can you explain cross-validation's role in addressing the bias-variance tradeoff?
Bias and Variance