DecodeAI
← Question Bank

Machine Learning

General Concepts In Machine Learning

Interview questions on General Concepts In Machine Learning.

4 questions

Similarity Measures

Q1. 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

Q2. 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

Q3. 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

Q4. 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)))