0% found this document useful (0 votes)
6 views2 pages

Advanced Numpy Interview Questions ML

The document outlines advanced NumPy interview questions relevant to machine learning, covering topics such as feature scaling, cosine similarity, batch processing, one-hot encoding, and more. It provides code examples for each question to illustrate how NumPy can be utilized in various machine learning tasks. Key concepts include mini-batch gradient descent, confusion matrix computation, synthetic data generation, dropout application, and PCA implementation.

Uploaded by

askr192001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Advanced Numpy Interview Questions ML

The document outlines advanced NumPy interview questions relevant to machine learning, covering topics such as feature scaling, cosine similarity, batch processing, one-hot encoding, and more. It provides code examples for each question to illustrate how NumPy can be utilized in various machine learning tasks. Key concepts include mini-batch gradient descent, confusion matrix computation, synthetic data generation, dropout application, and PCA implementation.

Uploaded by

askr192001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Advanced NumPy Interview Questions for Machine Learning

1. How can NumPy be used for feature scaling?

- Min-Max: (X - [Link]()) / ([Link]() - [Link]())

- Z-score: (X - [Link]()) / [Link]()

2. How to calculate cosine similarity using NumPy?

a = [Link]([1, 2, 3])

b = [Link]([4, 5, 6])

similarity = [Link](a, b) / ([Link](a) * [Link](b))

3. How can NumPy be used for batch processing in ML?

- Use vectorized ops to handle batches: [Link](W) + b

4. How to implement one-hot encoding using NumPy?

labels = [Link]([0, 2, 1])

one_hot = [Link](3)[labels]

5. How to compute pairwise Euclidean distances between two sets?

A = [Link]([[1, 2], [3, 4]])

B = [Link]([[5, 6], [7, 8]])

dists = [Link](((A[:, [Link], :] - B[[Link], :, :]) ** 2).sum(axis=2))

6. How to simulate a mini-batch gradient descent update?

weights -= learning_rate * gradients # vectorized

7. How can NumPy be used to compute the confusion matrix?

true = [Link]([0, 1, 2, 2])

pred = [Link]([0, 2, 1, 2])

conf_mat = [Link]((3,3), dtype=int)

for t, p in zip(true, pred): conf_mat[t, p] += 1

8. How to generate synthetic classification data?


X = [Link](100, 2)

y = (X[:, 0] + X[:, 1] > 0).astype(int)

9. How to apply dropout in a NumPy neural net?

mask = [Link](1, 0.8, size=[Link])

input *= mask

10. How can NumPy help in PCA (Principal Component Analysis)?

- Center data: X -= [Link](axis=0)

- Cov matrix: [Link](X.T)

- Eigen: [Link]()

You might also like