- Developers
- Hiring Interview Tips
- 20 Data Scientist Interview Questions and Answers for 2024

profile

By **Aran Davies**

**Verified Expert**

8 years of experience

Aran Davies is a full-stack software development engineer and tech writer with experience in Web and Mobile technologies. He is a tech nomad and has seen it all.

You are here on this page showing data scientist interview questions, which indicates that you plan to hire data scientists. That doesn’t surprise us. The global data science platform market itself will likely grow from $95.3 billion in 2021 to $322.9 billion in 2026, according to a MarketsandMarkets report.

That indicates that the volume of data science projects will grow significantly. You have landed on the right page too! DevTeam.Space is a trusted data science software development partner. Here, you can get data science interview questions for data scientists with varying levels of experience. You need to understand the hiring process first though.

Post an eye-catching and effective data science job advertisement

You can clearly see that hiring data scientists can be hard. The large and growing volume of data science projects makes data scientists some of the most sought-after in the software development industry. Your job ad must catch the attention of data scientists. Include the following in the job ad:

## Company descriptions

You know very well that professionals in demand want to work for organizations that stand out. Your job ad must position your organization as the place where top talents should work. Make the company description factual, however, make it exciting.

Stress upon the all-round professional growth opportunities you offer. Show how your organization grew and succeeded, subsequently, explain how this success opens up exciting career opportunities for in-demand talent.

Describe your organizational culture and explain how it is conducive to the growth of team members. Talk about the work environment. Show how your compensation and benefits policies reward talent and performance.

## Job descriptions for data scientists

Needless to say, you will write the standard job descriptions of data scientists, e.g.:

- Gathering data from varied sources;
- Performing data analysis;
- Using statistical tools, data analytics solutions, machine learning algorithms, etc. to gather insights from data;
- Interpreting data to find hidden patterns and relationships;
- Building application systems and processes for making sense of data;
- Presenting insights from data meaningfully using data visualization tools and other relevant solutions.

We also recommend that you use this opportunity to explain how data scientists will make a difference to your organization. Describe how their contribution will help your organization to grow and serve stakeholders better. By doing this, you enable data scientists to better understand their prospects in your organization.

## Data scientist roles and responsibilities

While writing the roles and responsibilities of data scientists, do stress upon the skills-intensive responsibilities. You can demonstrate to data scientists that you prioritize skills and competencies by doing that.

Cover the following when writing up the roles and responsibilities:

- Data scientists need to create and enhance data collection processes from various data sources.
- Data scientists should extract usable data from important data sources by using data mining.
- They need to select features in data using the right machine learning tools.
- Using ML tools, they should also create and optimize classifiers.
- Data scientists need to preprocess raw data, which might include both structured and unstructured data.
- They need to validate the quality of data values, distribution, etc. Data science experts carry out data-cleaning processes to create usable data sets.
- Data scientists must analyze input data sets to identify patterns and trends.
- They need to create prediction systems using machine learning algorithms.
- After extracting insights from entire data sets, data scientists should clearly present their findings.
- They should help the organization find answers to business questions by collaborating with business and IT teams.

## Data scientist skills

You should look for data scientists with a bachelor’s degree in computer science, information technology, or related disciplines. The data scientist skill requirements are as follows:

- Data scientists need thorough knowledge of one of the important programming languages like Python, C++, Java, R, and Scala.
- The knowledge of relational database management systems (RDBMSs) and SQL is important for a data science career.
- Data science experts need good knowledge of big data technologies like Hadoop, Hive, and Pig.
- You need data scientists with sound knowledge of mathematics. Especially, data scientists need excellent knowledge of multivariable calculus and linear algebra.
- They need a deep knowledge of statistics. Data science projects need extensive statistical analysis extensively. Data scientists should understand different statistical models and statistical techniques.
- Data scientists need a thorough knowledge of different machine learning algorithms like logistic regression, linear regression, artificial neural networks, etc. They should understand different machine learning models like linear regression models, random forest models, etc. A data scientist should know how to fine-tune a machine learning model. Data scientists should know well about supervised and unsupervised learning.
- Data scientists should have a good understanding of other artificial intelligence (AI) branches like natural language processing (NLP).
- They should know how to cleanse data sets so that input data doesn’t have issues like missing values, unnecessary data, etc.
- Data scientists should know about popular data visualization tools like Matplotlib, Tableau, etc.
- You need data scientists with an understanding of software engineering processes.
- Data scientists need soft skills like communication skills, commitment, problem-solving, etc.

## Data science interview questions and answers for junior professionals

If you plan to hire data scientists with fewer years under their belt, then use the following interview questions:

1. How will you handle a situation where a training data set has 40 percent missing values?

Data scientists can do the following to tackle a situation with such a large percentage of missing values in training or test data sets:

If the data set is large, then data science project teams can remove the rows with missing values. This does reduce the volume of data. However, the vast size of the data set means that there’s still a lot of data to process. Removing rows with missing values should take less time.

**
Get a complimentary discovery call and a free ballpark estimate for
your project
**

Trusted by 100x of startups and companies like

If data science professionals deal with small datasets, then they can substitute the missing data elements. Data scientists can take the mean or average of the other data for this. They might use the Pandas DataFrame data structure for this. For example, data scientists can use the “DataFrame mean()” function in Python to find the mean.

2. How will you use a Python set as a key in a dictionary?

We can’t use a Python set as a key in a dictionary. For that matter, we can’t use a Python set even as an element of another Python set.

The reason for that is that a Python set is mutable. We can add an element into a set or remove an element from it, using the “add” and “remove” methods, respectively. Now, we can’t a mutable object as a key to a dictionary or an element of another set.

The only workaround comes with a very important limitation. A frozen set is an immutable version of a set. We can use a frozen set as a key in a dictionary.

3. A company wants to display recommendations that say “Users who read this book also read…” for its online book shop. Which technique will you use for this?

We can use collaborative filtering to display such recommendations. Collaborative filtering is an important part of recommender systems. This filtering allows an application system to identify users who use the same product, a book in the current example. These users might consume other products. Collaborative filtering allows you to recommend displaying these other products.

4. How will you calculate the error rate and accuracy when using a binary classifier?

We can use a confusion matrix to calculate the error rate when we use a binary classifier. The confusion matrix provides the following results:

- True positive (TP);
- False positive (FP);
- True negative (TN);
- False negative (FN).

The calculation of the error rate is as follows:

Error rate = (FP+FN)/(P+N).

The calculation of accuracy is the following:

Accuracy = (TP+TN)/(P+N).

5. Using Python, calculate the Euclidean distance between points (4,7) and (7,11).

The solution to this question is as follows:

- The first point is “plot 1 = [4,7]”.
- The second point is “plot 2 = [7,11]”.
- We should use the formula to calculate the Euclidean distance, i.e., “euclidean_distance = sqrt((plot1[0]-plot2[0])**2 + (plot1[1]-plot2[1])**2)”.
- Therefore, the distance between these 2 data points is 5.

6. I have a large and even number of values with outliers. Explain how you will calculate the median of them. Also, explain the effect of the outliers on the median.

We need to perform the following steps:

- First, we should arrange the values in ascending order.
- Second, we need to identify the two middle values.
- Next, we need to calculate the mean of these two middle values.

This mean is the median that we need.

The presence of outliers doesn’t impact the calculation. An outlier will just take its place after we arrange the values in ascending order. Since it’s an outlier, this particular data point will not be any of the two middle values.

7. There are 3 hypothesis tests conducted with P-values of 0.07, 0.03, and 0.002, respectively. Which result is the most significant statistically and why?

The hypothesis test with the p-value of 0.002 is the most significant statistically. This test shows the strongest case against the null hypothesis. The test with p-value of 0.03 is statistically less significant than the p-value of 0.002. However, p-value of 0.03 is more statistically significant than the p-value of 0.07.

That’s because the lower the p-value, the higher the chances of rejecting the null hypothesis. If you have a better chance of rejecting the null hypothesis, then that hypothesis test shows a more statistically significant result.

## Interview questions and answers for hiring mid-level data scientists

When you hire mid-level data scientists, look for more experience. Evaluate the experience of candidates using the following interview questions:

1. In my data sets containing survey results, I have many respondents who responded multiple times with bits and pieces of information. Also, many respondents responded only once and answered all questions. Tell me which tools should I use for each of these categories and why.

You should use R for analyzing the data containing repeated responses with bits and pieces of information. This category of data is known as long-format data. R is very suitable for analyzing this type of data.

On the other hand, you should use XLSTAT for analyzing the data containing responses with all information provided first up. Such data is called wide format data. Repeated measures ANOVA is good for analyzing such data, and XLSTAT is a good tool for that.

2. I have a vast dataset, and I had to divide it into many equal parts. Tell me how I can ensure that all the parts of the dataset are used both for testing and training purposes.

You should use the K-fold cross-validation for this. Let us assume that you had divided your vast dataset into k equal parts. Now, you should process the entire dataset in a loop for k times.

- During one iteration, you use 1 of the k parts for testing.
- Then, you use the remaining (k-1) parts for training.
- During the next iteration, you use another part for testing.
- Once again, you use the other (k-1) parts for training.
- Continue these iterations k times. Now you have all of the parts used both as test data and training data.

3. In a financial services company, there are predictions from a model and actual values. Tell me the Mean Squared Error (MSE) in this case with explanations.

*Data points with predictions and actual values*

Predicted value 1: 12

Actual 1: 10

Predicted value 2: 28

Hire expert developers for your next project

**1,200**top developers

us since 2016

Actual 2: 27

Predicted value 3: 45

Actual 3: 41

Predicted value 4: 19

Actual 4: 12

Predicted value 5: 34

Actual 5: 33

Predicted value 6: 29

Actual 6: 26

*Answer:*

The following is the calculation of MSE:

- In this case, the number of observations is 6.
- The square of the differences between actual and predicted values in the 1st observation = square of (-2) = 4.
- The square of the differences between actual and predicted values in the 2nd observation = square of (-1) = 1.
- The square of the differences between actual and predicted values in the 3rd observation = square of (-4) = 16.
- The square of the differences between actual and predicted values in the 4th observation = square of (-7) = 49.
- The square of the differences between actual and predicted values in the 5th observation = square of (-1) = 1.
- The square of the differences between actual and predicted values in the 6th observation = square of (-3) = 3.
- The sum of the differences of squares = 74.
- Therefore, the MSE = 74/6 = 12.33.

Reference: The MSE formula:-

MSE = Σ(*y**i* − *p**i*)2/*n*

4. I want to use the metrics “error” to evaluate algorithm and model performance. What do you think of this decision and why?

You should use the “residual error” metrics instead of “error” to evaluate algorithm and model performance. The “error” metrics represent the difference between observed values and true values. On the other hand, the “residual error” metrics show the difference between observed values and predicted values.

Now, you can certainly know the predicted values. However, you will never surely know the true values. You might think that the value of a data point in your data set is the true value. However, you will never fully know how the origin and accuracy of that value. Since residual error deals with predicted values instead of true values, they give more a authentic picture.

5. Explain how you will identify independent variables and dependent variables in a data set.

We need to carefully analyze input and output variables in a data set to pinpoint independent and dependent variables.

To identify independent variables, we need to analyze the following:

- Did the observer modify the values of the variable in question?
- Does the observer control the value of the variable?
- Did the observer use the variable for subject grouping?
- Does the variable occur before the other variables?
- If the observer changes the value of the variable, then does the value of another variable change?

If the answer to any of the above questions is “yes”, then you are looking at independent variables.

On the other hand, the following questions help you identify dependent variables:

- Does the observer measure the value of the variable as the result of an experiment or activity?
- Do the observers measure the value of this variable only after changing the values of other variables?
- Does the value of the variable change when you change another variable?

If you answer “yes” to any of the above questions, then you are reviewing a dependent variable.

6. Describe how I can execute horizontal and vertical flipping of images.

You need to use data augmentation techniques used in deep learning. Since you have image data, you can use OpenCV, the well-known open-source computer vision library. OpenCV offers capabilities like random horizontal flip and random vertical flip.

You can execute a “mirror reflection” for your image data with the help of OpenCV. Horizontal flipping involves rotating the image around a vertical line passing through the center of the image. Vertical flipping requires rotating the image around a horizontal line passing through the center.

7. An eCommerce company wants to analyze different sales trends with visual aids. They want to know about the best-selling product categories, buyer demographics, spending patterns of buyers, and seasonal sales volume. At a high level, suggest the right course of action for this company.

The company should undertake an exploratory data analysis (EDA). They can use Python or R for this.

Data scientists on this project can use relevant BI tools like IBM Cognos, Tableau, or Qlik Sense. They should also use libraries and packages like Plotly, Seaborn, or Matplotlib.

The data science team in this company should focus on the following:

- They should frame the right questions suitable for this EDA.
- The team must acquire deep knowledge about the problem domain.
- They need to set clear objectives.
- Since the company wants to visualize several pieces of information, the data scientists working on this project should use the multivariate graphical EDA technique.

## Senior data scientist interview questions and answers

Do you need to hire senior data scientists? Evaluate their expertise using the following questions:

1. In a bank, there’s a list of 200,000 customers. 100,000 of them invest in stocks and the other 100,000 don’t do that. Find the entropy using frequency tables so that the bank can build a decision tree. Explain the steps.

We can find the entropy using the frequency table of one attribute in this case. The formula for that is the following:

“E = -(p1log2p1+p2log2p2+p3log2p3+….)”

Hire expert developers for your next project

Note that E is the entropy. Also note that p1, p2, p3, etc. are the probabilities.

The calculation steps are as follows:

- First, we need to calculate the probability distribution of the possible outcomes. In this case, customers might invest in stocks or they might not. There are 2 outcomes then. From the given information, p1 and p2, i.e., probabilities for both outcomes are 0.5 (100,000/200,000).
- Subsequently, we need to supply the values into the entropy formula. It will now read as “E = -{(0.5log2(0.5)+0.5log2(0.5)}.
- Since log2(0.5) is (-1), we now get E = -[{0.5x(-1)}+ {0.5x(-1)}].
- Therefore, the value of entropy E is –(-0.5-0.5), which is 1.

The value of entropy as 1 indicates that there is an even split of data samples.

2. On the data science project in our organization, there’s a need to create a new SQL database with tables that will store high volumes of data. As a senior data scientist, what are the 2 most important topics will you discuss with the DBA about this new database, and why?

I will prioritize the following 2 topics during my discussion with the DBA:

* 1. Database normalization*

Database normalization should ensure minimal data redundancy and dependency. DBA will have important inputs to provide for normalization so that data integrity is maintained.

Since the new RDBMS tables will hold large volumes of data, I will also discuss possible scopes for denormalization with the DBA. Denormalization, when used smartly, can improve the performance of SQL queries.

* 2. Database index*

Creating indexes smartly can greatly improve SQL query performance, therefore, I will exchange inputs with the DBA on this. I will discuss the possibilities of creating clustered indexes.

I will also request the DBA to create indexes so that database overheads are under control. That’s important for efficient database write operations.

Finally, I will request the DBA to carefully manage maintenance tasks like index rebuilding. That keeps the SQL database running efficiently.

3. I am using the Support Vector Machine (SVM) algorithm. Initially, my model showed too many errors during training and testing. After I made changes, the model performed well during training but showed too many errors during testing. Provide a high-level diagnosis and solution to the problem.

Initially, your model had many errors during the training and testing. Therefore, it had a high bias at that time.

Since you made changes, the data science model has done well during training. However, it can’t understand new data well. Consequently, it shows many errors during testing. The model now had a high variance.

You need to implement a bias-variance trade-off. Since you are using SVM, one trade-off could be adjusting the C parameter to increase the bias. This reduces the variance.

4. Earlier, a company analyzed only the exercising frequency of the clients. After that, the company started analyzing the exercise frequency versus blood pressure data. However, they now analyze data containing exercise frequency, the number of hours slept, diet adherence, BMI, blood pressure, and blood sugar. Explain what the company is doing, and suggest some techniques for their work.

The company started with univariate analysis. At that time, they analyzed only one variable. Subsequently, the company started analyzing two variables. That’s bivariate analysis.

Finally, they started analyzing more than two variables. The variables you are analyzing have interdependence. For example, exercise frequency, the number of hours slept, and diet adherence together impact the BMI, blood pressure, and blood sugar. At the same time, too little sleep alone can impact diet adherence, exercise frequency, and blood pressure. This analysis is multivariate analysis.

They can use any of the following multivariate analysis techniques:

- Multiple logistic regression;
- Factor analysis;
- Multivariate analysis of variance (MANOVA);
- Multiple linear regression;
- Cluster analysis.

5. After some data processing, I now have two validation data sets, one of which has values dependent on the scale and units of the variables. The other data set has values are divided by the standard deviation of the associated variables. Which matrix should I use?

You should use a covariance matrix for the data set with values that depend on the scale and units of the variables. The values in this data set are not standardized. The covariance matrix is more suitable for it. That’s because the covariance values will be sensitive to the normal distribution of the data.

The choice of correlation or covariance matrix depends on whether the data is standardized or not. Your second data set has standardized values. The correlation matrix will work better for it.

6. I have large data sets with data without labels, and I haven’t grouped the data by the behavior of the data elements. Should I use the Naïve Bayes Classifier or the K Means Clustering algorithm for creating a machine learning model?

You should use the K Means Clustering algorithm in this case.

First, your data doesn’t have labels. Therefore, you need to use an unsupervised learning algorithm. The Naïve Bayes Classifier algorithm is a supervised algorithm. You need labeled data to use this algorithm. On the other hand, the K Means Clustering algorithm is an unsupervised one. That makes it more suitable for your requirements.

Second, you have yet to group your data by data behavior. You need to execute a clustering process to group your data by the behavior of the data elements. The K Means Clustering algorithm can do that grouping, which is why you should use it and not the Naïve Bayes Classifier algorithm

## Hiring Data Scientists?

You can use the above data science interview questions to conduct effective interviews. However, if you can hire vetted data scientists with a successful track record, that’s even better, isn’t it?

What if you can hire such top-quality data scientists who work full-time for you? That’s just what we offer. Fill out the DevTeam.Space product specification form and an experienced account manager will soon reach out to you.