Mindblown: a blog about philosophy.
-
Scenario-based Data Science Interview Questions and Answers
Q.12 Suppose that you have to train your neural networks over a dataset of 20 GB. You have a RAM of 3 GB. How will you resolve this problem of training large data? Ans.
-
Q.11 How will you multiply a 4×3 matrix by a 3×2 matrix ?
Ans. There are two ways to do this. The first method is for the versions of Python that are older than 3.5 – Z = np.dot(np.ones((4,3)), np.ones((3,2)))print(Z)array([[3., 3.],[3., 3.],[3., 3.],[3., 3.]]) The second method is for Python version > 3.5, Z = np.ones((4,3)) @ np.ones((3,2))
-
Q.10 Consider a (5,6,7) shape array, what is the index (x,y,z) of the 50th element?
Ans. print(np.unravel_index(50,(5,6,7)))
-
Q.9 How to add a border that is filled with 0s around an existing array?
Ans. In order to add a border to an array that is filled with 0s, we first make an array Z and initialize it with zeroes. We first import numpy as np. Z = np.ones((5,5)) Then, we perform padding on it with the help of pad() function. Z = np.pad(Z, pad_width=1, mode=’constant’, constant_values=0) print(Z)
-
Q.8 How will you create an identity matrix using numpy?
Ans. In order to create the identity matrix with numpy, we will use the identity() function. Numpy is imported as np np.identity(3) We will obtain the output as – array([[1., 0., 0.],[0., 1., 0.],[0., 0., 1.]])
-
Q.7 Given two lists [1,2,3,4,5] and [6,7,8], you have to merge the list into a single dimension. How will you achieve this?
Ans. In order to merge the two lists into a single list, we will concatenate the two lists as follows – list1 + list2 We will obtain the output as – [1, 2, 3, 4, 5, 6, 7, 8]
-
Q.6 What function of numpy will you use to find maximum value from each row in a 2D numpy array?
Ans. In order to find the maximum value from each row in a 2D numpy array, we will use the amax() function as follows – np.amax(input, axis=1) Where numpy is imported as np and input is the input array.
-
Q.5 How do you create a 1-D array in numpy?
Ans. You can create a 1-D array in numpy as follows: x = np.array([1,2,3,4]) Where numpy is imported as np
-
Q.4 You had mentioned Python as one of the tools for solving data science problems, can you tell me the various libraries of Python that are used in Data Science?
Ans. Some of the important libraries of Python that are used in Data Science are –
-
Q.3 How will you create an identity matrix using numpy?
Ans. In order to create the identity matrix with numpy, we will use the identity() function. Numpy is imported as npnp.identity(3) We will obtain the output as – array([[1., 0., 0.],[0., 1., 0.],[0., 0., 1.]])
Got any book recommendations?