Skip to content

Data science interview questions and answers

The complete deck with answers. Play it as flashcards instead.

Machine Learning70 questions

Name three supervised learning algorithms.
Support Vector Machines, Regression, Naive Bayes, Decision Trees, Neural Networks, etc.
Name three unsupervised learning algorithms.
Clustering, Anomaly Detection, Latent variable models, Autoencoders, etc.
Name three types of kernels in SVM.
Linear, polynomial, radical, sigmoid
What is pruning in a decision tree?
When we remove the sub-nodes of the decision tree.
What is ensemble learning?
Combining individual models together with the purpose of improving the predictive power of the model.
Would you use k-fold cross validation on time series data? Explain.
No, you should be aware to the fact that a time series is not randomly distributed data.
What is count encoding?
Count encoding replaces each categorical value with the number of times it appears in the dataset.
What is one hot encoding?
A sparse vector in which: One element is set to 1 and all other elements are set to 0.
What is target encoding?
Target encoding replaces a categorical value with the average value of the target for that value of the feature.
What is data leakage?
When information from outside the training dataset is used to create the model. For example, including any information from the validation or test sets into the model.
What is the difference between L1 (Lasso) and L2 (Ridge) regularization?
L1 penalizes the absolute magnitude of the coefficients while L2 penalizes the square of the coefficients.
What is a confusion matrix?
A confusion matrix lets you see for a given model how your predictions compare with the actual results. It’s a 2x2 grid that has four parts: the number of true positives, false positives, true negatives, and false negatives.
What is boosting when referring to machine learning algorithms?
Boosting refers to a whole class of machine learning algorithms that are built on taking a weak model and reusing it enough times so that it becomes a strong one.
Explain what is bucketing.
Converting a (usually continuous) feature into multiple binary features called buckets or bins, typically based on value range.
What is the difference between a dense and a sparse feature?
A dense feature is one in which most values are non-zero in contrast with a sparse one where most values are zeros or empty.
What is downsampling in the context of class-imbalanced dataset?
Training on a disproportionately low percentage of over-represented class examples in order to improve model training on under-represented classes.
What is early stopping?
A method for regularization that involves ending model training before training loss finishes decreasing. In early stopping, you end model training when the loss on a validation dataset starts to increase.
Explain the basic concept of random forest.
An ensemble approach to finding the decision tree that best fits the training data by creating many decision trees and then determining the "average" one.
What does random means in the random forest term?
The "random" part of the term refers to building each of the decision trees from a random selection of features.
What is precision?
Precision is the number of the correct predictions of the positive class divided by the all the predicted positive class. TP/(TP + FP)
What is recall?
Recall is the number of the correct predictions of the positive class divided by the number of predictions that should have been classified in the positive class. TP/(TP + FN)
What is F1-score?
Is a measure of a test's accuracy. F1-score is the harmonic mean of the precision and recall.
What is better to have a F1-score equals to 1 or to 0?
F1-score reaches its best value at 1 (perfect precision and recall).
What is Elastic net regularization?
It is regularization technique that linearly combines L1 and L2 penalties.
What is unsupervised learning?
Unsupervised learning aims to detect patterns in data where no labels are given.
Does feature selection tends to increase overfitting?
No. It actually could help to reduce overfitting.
Why is naive Bayes 'naive'?
Because it assumes that all of the features in a data set are equally important and independent.
Is KNN a clustering algorithm?
No. It is and supervised learning method that could be used for classification and regression problems.
How is random forest different from gradient boosting algorithm?
The fundamental difference is, random forest uses bagging technique to make predictions. GBM uses boosting techniques to make predictions.
Which regularization would you use if your model is underfitting?
None, because regularization is used in case of overfitting.
What is the difference between online and batch Learning?
Online: you would use the "most recent" sample at each iteration. Batch: Learning over groups of patterns.
Bagging stands for?
Bootstrap Aggregation.
What is the difference between boosting and bagging?
In bagging we take boostrap samples of the data (with replacement) and each sample trains a weak learner. And boosting uses all data to train each learner and then average the result using a weighted average approach.
What is variance in the context of Machine Learning?
Is a type of error that occurs due to a model's sensitivity to small fluctuations in the training set. High variance can cause an algorithm to model the random noise in the training data.
Explain what is Bias-Variance tradeoff?
Usually models with low bias have high variance and vice versa.
What happens to our linear regression if we have columns x, y, z. And z is a sum of x and y?
We would not be able to perform the resgression. Beacuse z is linear dependent of x and y.
Is logistic regression a linear model? Why?
Logistic regression is considered a generalized linear model because the outcome always depends on the sum of the inputs and parameters.
What is TF-IDF?
Term Frequency (TF) is a scoring of the frequency of the word in the current document. Inverse Document Frequency(IDF) is a scoring of how rare the word is across documents.
What is overfitting?
When your model perform very well on your training set but can’t generalize the test set, because it adjusted a lot to the training set.
What is the precision-recall curve?
A precision-recall curve (or PR Curve) is a plot of the precision (y-axis) and the recall (x-axis) for different probability thresholds.
Can we use L1 regularization for feature selection?
Yes, because the nature of L1 regularization will lead to sparse coefficients of features. Feature selection can be done by keeping only features with non-zero coefficients.
What is bag of words?
Bag of Words is a representation of text that describes the occurrence of words within a document.
What is clustering?
Clustering algorithms group objects such that similar feature points are put into the same groups (clusters).
What is a time series?
A time series is a set of observations ordered in time usually collected at regular intervals.
What is the main data structure used in causal modelling?
Graphs! More specifically, directed acyclic graphs.

Deep Learning54 questions

Name three different deep learning frameworks.
TensorFlow, PyTorch, Keras, Caffe, etc.
What is AdaGrad?
A sophisticated gradient descent algorithm that rescales the gradients of each parameter, effectively giving each parameter an independent learning rate.
Which ones are two actors in a convolutional operation?
Convolutional filter and a slice of an input matrix.
How does dropout regularization works in deep learning?
Dropout regularization works by removing a random selection of a fixed number of the units in a network layer for a single gradient step.
What is an epoch?
A full training pass over the entire dataset such that each example has been seen once.
What is a batch?
Number of training samples in 1 Forward/1 Backward pass.
What is the function of the discriminator in a GAN?
Determine whether examples are real or fake.
Explain what a softmax function does?
Provides probabilities for each possible class in a multi-class classification model. The probabilities add up to exactly 1.0
What is learning rate?
Is a tuning parameter in an optimization algorithm that determines the step size at each iteration while moving toward a minimum of a loss function.
What does LSTM means?
Long Short-Term Memory.
What does GRU means?
Gated Recurrent Unit.
What if we set all the weights of a neural network to 0?
The equations of the learning algorithm would fail to make any changes to the network weights, and the model will be stuck.
What happens when the learning rate is too large?
Can accelerate the training. However, it is possible that we “shoot” too far and miss the minimum of the function that we want to optimize.
What happens when the learning rate is too small?
Takes more time to train but it is possible to find a more precise minimum. The downside can be that the solution is stuck in a local minimum.
Why do we need activation functions?
The main idea of using neural networks is to learn complex nonlinear functions. The Nonlinearity comes only with the activation function without them we are just stacking up multiple linear layers.
What are the problems with sigmoid as an activation function?
The output of the sigmoid function for large positive or negative numbers is almost zero. From this comes the problem of vanishing gradient.
What is ReLU? How is it better than sigmoid?
ReLU is an activation function and it solves the problem of vanishing gradient since it doesn't saturates on higher values.
What’s pooling in CNN? Why do we need it?
Pooling is a technique to downsample the feature map. It allows layers which receive relatively undistorted versions of the input to learn low level features such as lines.

Statistics38 questions

What is the difference between "long" and "wide" format data?
Wide: categorical data is grouped in a single row, long: each row is an observation belonging to a particular category.
What is a Type I and a Type II error?
Basically Type I errors are the False Positive and Type II error are the False Negative.
What two parameters defined a normal distribution?
Its mean and its standard deviation.
What is the difference of and nominal and ordinal feature?
Nominal data assigns names to each data point without placing it in some sort of order, ex: pass, fail. And ordinal data groups data according to some sort of ranking system: it orders the data, ex: grades A, B, C, D, E and F.
What does high and low cardinality mean?
High cardinality refers to columns with values that are very uncommon or unique, example: email addresses, or user names. And low cardinality: refers to columns with few unique values, example: status flags, boolean values.
What is R-squared?
R-squared is a statistical measure of how close the data are to the fitted regression line. It is also known as the coefficient of determination.
What is a residual?
Is the difference between the observed value and the estimated value of the quantity of interest.
What is dimensionality reduction?
It is the process of reducing the number of variables under consideration by obtaining a set of principal variables.
What is a false negative?
An example in which the model mistakenly predicted the negative class.
What is a false positive?
An example in which the model mistakenly predicted the positive class.
Precision is the rate between?
True Positives / (True Positives + False Positives)
What does stationarity in a dataset means?
A property of data in a dataset, in which the data distribution stays constant across one or more dimensions. Most commonly, that dimension is time.
What does MSE mean?
Mean Square Error.
What does RMSE mean?
Root Mean Square Error.
Name three techniques of dimensionality reduction.
Singular Value Decomposition (SVD), Principal Component Analysis (PCA), Linear Discriminant Analysis (LDA), Autoencoders, Fourier and Wavelet Transforms.
What values could you infer from a boxplot?
Min, 1 quantile, mean, 3 quantile, max and outliers.
Is rotation necessary in PCA?
Yes, rotation is necessary because it maximizes the difference between variance captured by the component.
What is the difference between covariance and correlation?
Correlation is the standardized form of covariance.
Is it possible capture the correlation between continuous and categorical variable?
Yes, we can use ANCOVA (analysis of covariance) technique to capture association between continuous and categorical variables.
If pearson correlation is 0 between two variables can we assume that there isn't any relation between them?
No. Pearson correlation coefficient between 2 variables might be zero even when they have a relationship between them. Example: x and x^2
Give 3 techniques for handling missing values.
Delete rows with missing data, Imputation, Predicting the missing values.
What is the Law of Large Numbers?
Is a theory that states that as the number of trials increases, the average of the result will become closer to the expected value.
What is Survivorship bias?
Is the logical error of concentrating on the people or things that made it past some selection process and overlooking those that did not.
What is a confounding variable?
Is a variable that influences both the dependent variable and the independent variable, causing a spurious association.
What is autocorrelation?
Is the correlation of a signal with a delayed copy of itself as a function of delay.
What is MSE?
MSE stands for Mean Squared Error. And is a measure of how close a fitted line is to data points by measuring the average squared of the errors.
What is RMSE?
RMSE stands for Root Mean Squared Error. Is the squared root of MSE.
How can we select K for K-means?
Domain knowledge, Elbow method or Average silhouette method.
What is precision and recall at k?
Precision at k and recall at k are evaluation metrics for ranking algorithms.

History35 questions

Who invented the perceptron?
Frank Rosenblatt. Bonus. The invention of the perceptron generated a great deal of excitement and was widely covered in the media.
Who invented the LSTM architecture in deep learning?
Sepp Hochreiter and Jürgen Schmidhuber in 1997.
Who are credited by the creation of R?
Ross Ihaka and Robert Gentleman.
Who are known as the "Good Parents of AI"?
Geoffrey Hinton, Yann LeCun, and Yoshua Bengio.
Was Bayes's Theorem published after his death?
Yes. The underpinnings of Bayes' Theorem was published 2 years after his death (1763) and was until 1812 that Laplace published it as we know it today. 49 years later!

Created by santiviquez

To suggest new questions or report an error send me a dm.