Ah the dreaded machine learning interview. You feel like you know everything⊠until youâre tested on it! But it doesnât have to be this wayâŠ
Over the past few months Iâve interviewed with many companies for entry-level roles involving data science and machine learning. To give you a bit of perspective, I was in graduate school in the last few months of my masters in machine learning and computer vision with most of my previous experience being research/academic, but with eight months at an early stage startup (unrelated to ML). The roles included work in data science, general machine learning, and specializations in natural language processing or computer vision. I interviewed with big companies like Amazon, Tesla, Samsung, Uber, Huawei, but also with many startups ranging from early-stage to well established and funded.
Today Iâm going to share with you all of the interview questions I was asked and how to approach them. Many of the questions were quite common and expected theory, but many others were quite creative and curious. Iâm going to simply list the most common ones since thereâs many resources about them online and go more in depth into some of the less common and trickier ones. I hope in reading this post that you can get great at machine learning interviews and land your dream job!
Many of the questions were quite common and expected theory, but many others were quite creative and curious.
**1. WHAT IS DATA NORMALIZATION AND WHY DO WE NEED IT? **
I felt this one would be important to highlight. Data normalization is a very important preprocessing step, used to rescale values to fit in a specific range to assure better convergence during backpropagation. In general, it boils down to subtracting the mean of each data point and dividing by its standard deviation. If we donât do this then some of the features (those with high magnitude) will be weighted more in the cost function (if a higher-magnitude feature changes by 1%, then that change is pretty big, but for smaller features itâs quite insignificant). The data normalization makes all features weighted equally.
2. EXPLAIN DIMENSIONALITY REDUCTION, WHERE ITâS USED, AND ITS BENEFITS?
Dimensionality reduction is the process of reducing the number of feature variables under consideration by obtaining a set of principal variables which are basically the important features. Importance of a feature depends on how much the feature variable contributes to the information representation of the data and depends on which technique you decide to use. Deciding which technique to use comes down to trial-and-error and preference. Itâs common to start with a linear technique and move to non-linear techniques when results suggest inadequate fit. Benefits of dimensionality reduction for a data set may be:
**3. HOW DO YOU HANDLE MISSING OR CORRUPTED DATA IN A DATASET? **
You could find missing/corrupted data in a dataset and either drop those rows or columns, or decide to replace them with another value. In Pandas, there are two very useful methods: isnull() and dropna() that will help you find columns of data with missing or corrupted data and drop those values. If you want to fill the invalid values with a placeholder value (for example, 0), you could use the fillna() method.
**4. EXPLAIN THIS CLUSTERING ALGORITHM? **
I wrote a popular article on the The 5 Clustering Algorithms Data Scientists Need to Know explaining all of them in detail with some great visualizations.
5. HOW WOULD YOU GO ABOUT DOING AN EXPLORATORY DATA ANALYSIS (EDA)?
The goal of an EDA is to gather some insights from the data before applying your predictive model i.e gain some information. Basically, you want to do your EDA in a coarse to fine manner. We start by gaining some high-level global insights. Check out some imbalanced classes. Look at mean and variance of each class. Check out the first few rows to see what itâs all about. Run a pandas df.info()
to see which features are continuous, categorical, their type (int, float, string). Next, drop unnecessary columns that wonât be useful in analysis and prediction. These can simply be columns that look useless, oneâs where many rows have the same value (i.e it doesnât give us much information), or itâs missing a lot of values. We can also fill in missing values with the most common value in that column, or the median. Now we can start making some basic visualizations. Start with high-level stuff. Do some bar plots for features that are categorical and have a small number of groups. Bar plots of the final classes. Look at the most âgeneral featuresâ. Create some visualizations about these individual features to try and gain some basic insights. Now we can start to get more specific. Create visualizations between features, two or three at a time. How are features related to each other? You can also do a PCA to see which features contain the most information. Group some features together as well to see their relationships. For example, what happens to the classes when A = 0 and B = 0? How about A = 1 and B = 0? Compare different features. For example, if feature A can be either âfemaleâ or âmaleâ then we can plot feature A against which cabin they stayed in to see if males and females stay in different cabins. Beyond bar, scatter, and other basic plots, we can do a PDF/CDF, overlaid plots, etc. Look at some statistics like distribution, p-value, etc. Finally itâs time to build the ML model. Start with easier stuff like Naive Bayes and linear regression. If you see that those suck or the data is highly non-linear, go with polynomial regression, decision trees, or SVMs. The features can be selected based on their importance from the EDA. If you have lots of data you can use a neural network. Check ROC curve. Precision, Recall.
6. HOW DO YOU KNOW WHICH MACHINE LEARNING MODEL YOU SHOULD USE?
While one should always keep the âno free lunch theoremâ in mind, there are some general guidelines. I wrote an article on how to select the proper regression model here. This cheatsheet is also fantastic!
7. WHY DO WE USE CONVOLUTIONS FOR IMAGES RATHER THAN JUST FC LAYERS?
This one was pretty interesting since itâs not something companies usually ask. As you would expect, I got this question from a company focused on computer vision. This answer has two parts to it. Firstly, convolutions preserve, encode, and actually use the spatial information from the image. If we used only FC layers we would have no relative spatial information. Secondly, Convolutional Neural Networks (CNNs) have a partially built-in translation in-variance, since each convolution kernel acts as itâs own filter/feature detector.
8. WHAT MAKES CNNS TRANSLATION INVARIANT?
As explained above, each convolution kernel acts as its own filter/feature detector. So letâs say youâre doing object detection, it doesnât matter where in the image the object is since weâre going to apply the convolution in a sliding window fashion across the entire image anyways.
9. WHY DO WE HAVE MAX-POOLING IN CLASSIFICATION CNNS?
Again as you would expect this is for a role in computer vision. Max-pooling in a CNN allows you to reduce computation since your feature maps are smaller after the pooling. You donât lose too much semantic information since youâre taking the maximum activation. Thereâs also a theory that max-pooling contributes a bit to giving CNNs more translation in-variance. Check out this great video from Andrew Ng on the benefits of max-pooling.
10. WHY DO SEGMENTATION CNNS TYPICALLY HAVE AN ENCODER-DECODER STYLE / STRUCTURE?
The encoder CNN can basically be thought of as a feature extraction network, while the decoder uses that information to predict the image segments by âdecodingâ the features and upscaling to the original image size.
11. WHAT IS THE SIGNIFICANCE OF RESIDUAL NETWORKS?
The main thing that residual connections did was allow for direct feature access from previous layers. This makes information propagation throughout the network much easier. One very interesting paper about this shows how using local skip connections gives the network a type of ensemble multi-path structure, giving features multiple paths to propagate throughout the network.
12. WHAT IS BATCH NORMALIZATION AND WHY DOES IT WORK?
Training Deep Neural Networks is complicated by the fact that the distribution of each layerâs inputs changes during training, as the parameters of the previous layers change. The idea is then to normalize the inputs of each layer in such a way that they have a mean output activation of zero and standard deviation of one. This is done for each individual mini-batch at each layer i.e compute the mean and variance of that mini-batch alone, then normalize. This is analogous to how the inputs to networks are standardized. How does this help? We know that normalizing the inputs to a network helps it learn. But a network is just a series of layers, where the output of one layer becomes the input to the next. That means we can think of any layer in a neural network as the first layer of a smaller subsequent network. Thought of as a series of neural networks feeding into each other, we normalize the output of one layer before applying the activation function, and then feed it into the following layer (sub-network).
13. HOW WOULD YOU HANDLE AN IMBALANCED DATASET?
I have an article about this! Check out #3 :)
14. WHY WOULD YOU USE MANY SMALL CONVOLUTIONAL KERNELS SUCH AS 3X3 RATHER THAN A FEW LARGE ONES?
This is very well explained in the VGGNet paper. There are two reasons: First, you can use several smaller kernels rather than few large ones to get the same receptive field and capture more spatial context, but with the smaller kernels you are using less parameters and computations. Secondly, because with smaller kernels you will be using more filters, youâll be able to use more activation functions and thus have a more discriminative mapping function being learned by your CNN.
15. DO YOU HAVE ANY OTHER PROJECTS THAT WOULD BE RELATED HERE?
Here youâll really draw connections between your research and their business. Is there anything you did or any skills you learned that could possibly connect back to their business or the role you are applying for? It doesnât have to be 100% exact, just somehow related such that you can show that you will be able to directly add lots of value.
16. EXPLAIN YOUR CURRENT MASTERS RESEARCH? WHAT WORKED? WHAT DIDNâT? FUTURE DIRECTIONS?
Same as the last question!
**ADDITIONAL DATA SCIENCE INTERVIEW QUESTIONS: **
There you have it! All of the interview questions I got when apply for roles in data science and machine learning. I hope you enjoyed this post and learned something new and useful!
#machine-learning