DecodeAI
← Question Bank

Machine Learning

General Concepts In Machine Learning

Interview questions on General Concepts In Machine Learning.

72 questions

Basics

Q1. Explain supervised, unsupervised, weakly supervised, semi-supervised, and active learning.

Sign in to bookmark

Basics

Q2. Empirical risk minimization.

Sign in to bookmark
  1. What’s the risk in empirical risk minimization?
  2. Why is it empirical?
  3. 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?

Sign in to bookmark

Basics

Q4. Explain the tradeoff between model's flexibility vs interpretability?

Sign in to bookmark

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?

Sign in to bookmark

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?

Sign in to bookmark

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?

Sign in to bookmark

Basics

Q8. What are saddle points and local minima? Which are thought to cause more problems for training large NNs?

Sign in to bookmark

Basics

Q9. Hyper-parameters.

Sign in to bookmark
  1. What are the differences between parameters and hyper-parameters?
  2. Why is hyperparameter tuning important?
  3. List down methods for tuning hyper-parameters.

Basics

Q10. Classification vs. regression.

Sign in to bookmark
  1. What makes a classification problem different from a regression problem?
  2. Can a classification problem be turned into a regression problem and vice versa?

Basics

Q11. Parametric vs. non-parametric methods.

Sign in to bookmark
  1. What’s the difference between parametric methods and non-parametric methods? Give an example of each method.
  2. When should we use one and when should we use the other?

Basics

Q12. Why does an ML model’s performance degrade in production?

Sign in to bookmark

Basics

Q13. What problems might we run into when deploying large machine learning models?

Sign in to bookmark

Basics

Q14. Your model performs really well on the test set but poorly in production.

Sign in to bookmark
  1. What are your hypotheses about the causes?
  2. How do you validate whether your hypotheses are correct?
  3. 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?

Sign in to bookmark

Cross Validation

Q16. Below Fig depicts two different cross-validation approaches. Name them.

Sign in to bookmark

Cross Validation

Q17. 1. What is the purpose of following Python code snippet?

Sign in to bookmark
        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.

Sign in to bookmark

Cross Validation

Q19. **True or False:** In a K-fold CV approach, the final test error is:

Sign in to bookmark

CVk=1ki=1kMSEiCV_k = \frac{1}{k}\sum_{i=1}^{k}MSE_i

Cross Validation

Q20. Mark all the correct choices regarding a cross-validation approach:

Sign in to bookmark
  1. A 5-fold cross-validation approach results in 5-different model instances being fitted.
  2. A 5-fold cross-validation approach results in 1 model instance being fitted over and over again 5 times.
  3. A 5-fold cross-validation approach results in 5-different model instances being fitted over and over again 5 times.
  4. 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:

Sign in to bookmark
  1. We compute the cross-validation performance as the arithmetic mean over the K performance estimates from the validation sets.
  2. 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.

Sign in to bookmark

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.

Sign in to bookmark
  1. True or false: It is always possible to find an optimal value nn ,K=n K = n in K-fold cross-validation.

Cross Validation

Q24. What is the main difference between RandomizedSearchCV and GridSearchCV?

Sign in to bookmark

Cross Validation

Q25. When would you prefer to use RandomizedSearchCV over GridSearchCV, and vice versa?

Sign in to bookmark

Cross Validation

Q26. What are the advantages of RandomizedSearchCV?

Sign in to bookmark

Cross Validation

Q28. What is cross-validation in the context of hyperparameter tuning?

Sign in to bookmark

Cross Validation

Q29. Can you combine RandomizedSearchCV and GridSearchCV techniques for hyperparameter tuning?

Sign in to bookmark

Similarity Measures

Q30. A data scientist extracts a feature vector from an image using a pre-trained ResNet34 CNN as follows

Sign in to bookmark
    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:

Sign in to bookmark

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
  1. Name the algorithm algo2 that he used and explain in detail what he used it for.
  2. Write the mathematical formulae behind it.
  3. What are the minimum and maximum values it can return?
  4. An alternative similarity measures between two vectors is: simeuc(v1,v2)=v1v2\text{simeuc}(v1, v2) = -\|v1 - v2\|. Name the measure.

Similarity Measures

Q32. 1. What is the formulae for the Jaccard similarity of two sets?

Sign in to bookmark
  1. Explain the formulae in plain words.
  2. 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.

Sign in to bookmark

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. DKL(PQ)=xXP(x)log(P(x)Q(x))D_{KL}(P \| Q) = \sum_{x \in X} P(x) \log\left(\frac{P(x)}{Q(x)}\right) 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: DKLD1(PQ)=DKL(PQ)+DKL(QP)D_{KLD1}(P \| Q) = D_{KL}(P \| Q) + D_{KL}(Q \| P) DKLD2(PQ)=xX(P(x)Q(x))log(P(x))D_{KLD2}(P \| Q) = \sum_{x \in X} (P(x) - Q(x)) \log(P(x)) DKLD3(PQ)=12[DKL(Q(P+Q2))+DKL(P(P+Q2))]D_{KLD3}(P \| Q) = \frac{1}{2} [D_{KL}\left(Q\|\right(\frac{P+Q}{2})) + D_{KL}\left(P\|\right(\frac{P+Q}{2})) ] DKLD4(PQ)=max(DKL(Q(P))+DKL(P(Q)))D_{KLD4}(P \| Q) = max(D_{KL}\left(Q\|\right(P)) + D_{KL}\left(P\|\right(Q)))

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?

Sign in to bookmark

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?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q36. Explain Markov chain Monte Carlo sampling.

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q37. If you need to sample from high-dimensional data, which sampling method would you choose?

Sign in to bookmark

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.

Sign in to bookmark

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.

Sign in to bookmark
  1. How would you sample 100K100K comments to label?
    1. Suppose you get back 100K100K labeled comments from 2020 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?

Sign in to bookmark

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?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q42. How do you know you’ve collected enough samples to train your ML model?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q43. How to determine outliers in your data samples? What to do with them?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q44. Sample duplication

Sign in to bookmark
  1. When should you remove duplicate training samples? When shouldn’t you?
  2. 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

Sign in to bookmark
  1. In your dataset, two out of 20 variables have more than 30% missing values. What would you do?
  2. 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)?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q47. Class imbalance.

Sign in to bookmark
  1. How would class imbalance affect your model?
  2. Why is it hard for ML models to perform well on data with class imbalance?
  3. Imagine you want to build a model to detect skin legions from images. In your training dataset, only 11% 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.

Sign in to bookmark
  1. 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?
  2. 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?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q50. Feature leakage

Sign in to bookmark
  1. What are some causes of feature leakage?
  2. Why does normalization help prevent feature leakage?
  3. 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?

Sign in to bookmark

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?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q53. Convergence.

Sign in to bookmark
  1. When we say an algorithm converges, what does convergence mean?
  2. How do we know when a model has converged?

Sampling Techniques and Creating Training Data

Q54. Draw the loss curves for overfitting and underfitting.

Sign in to bookmark

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?

Sign in to bookmark

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?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q57. Bias-variance trade-off

Sign in to bookmark
  1. What’s the bias-variance trade-off?
  2. How’s this tradeoff related to overfitting and underfitting?
  3. How do you know that your model is high variance, low bias? What would you do in this case?
  4. 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?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q59. Cross-validation.

Sign in to bookmark
  1. Explain different methods for cross-validation.
  2. 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?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q61. Explain the bias variance tradeoff with the choice of k in k-fold validation?

Sign in to bookmark

Sampling Techniques and Creating Training Data

Q62. Train, valid, test splits.

Sign in to bookmark
  1. What’s wrong with training and testing a model on the same data?
  2. Why do we need a validation set on top of a train set and a test set?
  3. 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? image

Feature Engineering

Q63. Feature selection.

Sign in to bookmark
  1. Why do we use feature selection?
  2. What are some of the algorithms for feature selection? Pros and cons of each.

Feature Engineering

Q64. Is feature scaling necessary for kernel methods?

Sign in to bookmark

Feature Engineering

Q65. What are the different types of feature selection techniques?

Sign in to bookmark

Bias and Variance

Q67. Why is the bias-variance tradeoff important in machine learning?

Sign in to bookmark

Bias and Variance

Q68. How can you tell if your model has a high bias or high variance problem?

Sign in to bookmark

Bias and Variance

Q69. What are some techniques to reduce bias in a model?

Sign in to bookmark

Bias and Variance

Q70. What are some techniques to reduce variance in a model?

Sign in to bookmark

Bias and Variance

Q71. Can you explain cross-validation's role in addressing the bias-variance tradeoff?

Sign in to bookmark

Bias and Variance

Q72. Is it always better to reduce bias and variance simultaneously?

Sign in to bookmark