Category Archives for "Interview Corner"

Mar 16

How to Solve Analytics Interview Puzzles

By ganpati | Interview Corner

Analytics jobs require a lot of problem solving and out of the box thinking. Hence, puzzles, logical reasoning problems and questions to test lateral thinking are important part of most analytics job interviews. But not all puzzles are alike. Some are more technical, some are straight forward (if you know the answer you can solve it) and some are just unsolvable- interviwer is probably trying to test your approach or patience. But to succeed, you must be prepared for all such scenarios. You may also be asked to create algorithms for each of these cases. Here’s how to crack them:

1. Focus on the data provided– usually interview puzzles involve just one or two steps of calculations.
2. Develop a structured appraoch to answer difficult puzzles
3. Be able to explain your appraoch to the interviewer

I’ll explain with some examples how to master puzzle solving for interviews with one technical, one straight forward and one doubtful puzzle.

Puzzles with an Approach:

1. A race track has 5 lanes. There are 25 horses and one would like to find out the 3 fastest horses. What is the minimum number of races one would need to conduct to determine the 3 fastest horses?

This is a common puzzle asked by many interviewers. The steps are:

Create 5 groups of 5 horses each and conduct five races (1 for each group) and pick up the fastest horse from each group.
The sixth race will be among the 5 winners to find out the 3 fastest horses (mark them A1, B1 and C1)
Seventh race will be among the horses B1, C1, second and third horse from the horse A1’s group (A2, A3), second horse from horse B1’s group (B2).

The 1st and 2nd position holders in the 7th race are the 2nd and the 3rd fastest horses among all horses.

The logic is simple. By conducting the race among 5 winning horses we can find out the fastest horse but we don’t know for sure whether the second fastest horse in that race is faster than the second horse in the fastest horse’s group. So, in the final race we have to include all probable candidates and conduct the race.

Similar puzzles can be asked for finding out the heaviest coin in among N number of coins. And the trick is to single out the one in lowest number of steps. The approach to such problems are to:

  • Divide all the members into X groups and maximize number of members in each group. In this case we could have just 5 horses in each group as there were 5 lanes.
  • Shortlist the members from each group and make them compete among themselves (if required form the groups again) and iterate the first step until the problem is solved.
  • Develop a structured appraoch to answer difficult puzzles

The Straightforward Puzzle

In many cases interviewer expect you to know the answer but in case you don’t you should apply simple logic and explain your approach. I’ll site 3 examples here (mostly related to data science and analytics):
1. You have 3 jars that are all mislabeled. One jar contains Apple, another contains Oranges and the third jar contains a mixture of both Apple and Oranges.
You are allowed to pick as many fruits as you want from each jar to fix the labels on the jars. What is the minimum number of fruits that you have to pick and from which jars to correctly label them?
An interesting point in these kind of puzzles is there is a circular misplacement. Which means if Apple is wrongly labelled as Apple, Apple can’t be labelled as Orange- it has to be labelled as A+O.
Now, to answer this question in minimum steps, try to reverse engineer the problem. You know everything is wrongly placed. Which means the A+O jar contains either Apple or Orange (but not both). So, just pick one fruit from A+O and let’s say you get an Apple. Name it Apple. As discussed above, jar labelled Apple can’t have A+O. So it can be labelled Orange. The third jar left should be labelled as A+O.
So you can answer the question by just picking one fruit.
2. You have a flashlight that takes 2 working batteries. You have 8 batteries but only 4 of them work.
What is the fewest number of pairs you need to test to guarantee you can get the flashlight on?
Let’s say the batteries are A, B, C, D, E, F, G and H
This is somewhat similar to the horse problem discussed in beginning. Except for the fact that we can’t compare 2 items directly. If a combination of two batteries can’t light the torch either or both can be not working. So we have to try out in a circular way first.
Try AB, BC and AC. If none of the pairs work at most one out of ABC is working.
Which means at least three batteries among DEFGH must be working.
Try DE. If they do not work then at least two out of FGH should work.
Try FG, GH and FH and you’ll find out two working batteries.
3. You are blindfolded and 10 coins are place in front of you on table. You are allowed to touch the coins, but can’t tell which way up they are by feel. You are told that there are 5 coins head up, and 5 coins tails up but not which ones are which. How do you make two piles of coins each with the same number of heads up? You can flip the coins any number of times.
Randomly select 5 coins and make a pile. Make another pile with 5 other coins.
First pile would look like, say H, H, H, H, T
The other pile should be: T, T, T, T, H
So, now, if you just flip all coins in the second pile and both will have same number of heads.
The Complicated Puzzle<>
The third type of puzzles are the doubtful ones and interviewer might ask you such question only to check your ability to support your answers with reasons.
A famous problem of this type is Monty Hall problem (Here’s a link to the answer for Monty Hall.). Just keep your calm while answering such problems and be reasonable.

Monty Hall Problem

Commonly asked puzzles in analytics interviews

Mar 16

Analytics Interview Questions General Topics

By ganpati | Interview Corner

We have already covered the interview questions on specific topics like machine learning, puzzles, statistics etc. in other posts. This post is for general questions on background, analytics process, business and product related questions, basic software engineering etc.

We have posted the links for the indicative answers for most of the questions. We keep updating these answers from time to time. If you know a better answer or you want to write an answer and send us the link we’ll be happy to post it.

Product Related Questions

  • Which part of our product you dislike most?
  • Can you think of the reasons why we decided to make it that way?
  • How would you quantify its badness (goodness)?
  • How would you fix it?
  • What challenges you might face in fixing it?
  • How do you test a website feature i.e. given a set of webpages and few changes, how will you find out that the change works positively?
  • Real life business problems

  • How many bars of soap does Kroger sell in a year/ Estimate daily number of fries sold at Wendy’s?
  • Suggested reading

  • What types of data are important for a particular set of business needs? How you would go about collecting that data?
  • The business wants to take advantage of all its data and build a super predictive model. What should they know about using a large feature space?
  • Suggested reading

  • The business wants to build a classifier. They do something really easy and find that they correctly predict the labels 99% of the time. What might be wrong here?
  • Background Related Questions Based on Resume

    Usually, interviews start with resume based questions that focus on your background like your education previous work experience, interests, past projects etc. In this post we’ll primarily focus on such topics.

  • What are the companies that you worked for in the past? What was your role in XYZ company?
  • Have you undertook any internship? What was your learning from it?
  • Summarize your experience in XYZ company
  • Why did you leave XYZ company?
  • What projects you implemented there? Discuss some of them in details
  • What were the biggest challenges you faced in XYZ company?
  • I see there’s some gap in your work history. Why?
  • Is there anything that you do not like about your last or current job?
  • These questions can be tricky. Never blame your boss or colleagues for any of the hurdles you faced. Not even if they were truly responsible. Try to narrate the circumstances and what you did to handle the situation.

  • A follow up question on your project can be: If you were to undertake such a project again what would you do differently?
  • For graduating students: Tell me about your master thesis. What were the challenges you faced?
  • What was your primary learning from this thesis?
  • Instead of speaking about theoretical learnings discuss about the insights you were able to draw from the project.

  • For aspiring data scientists: Why do you want to switch to a career in data science?
  • It’s always better if you can site examples of your analytical skills gained from your previous job(s) to demonstrate how your experience will be valuable in this kind of a job.

  • What are your career goals?
  • Be clear about your goals and be able to illustrate with facts from your experience etc. how you have worked towards that goal.

    Questions on your thoughts and opinion

    There also be some questions not directly related to the projects you did, but rather to yourself like the decisions you made, your strengths and weaknesses etc. For example:

    • Describe to me a Data Science project that you led/participated?
    • Tell us about an instance you had to make a difficult decision.
    • Tell us about an instance you worked on a dysfunctional team.
    • Tell us about an instance when you tried to convince someone of an idea you come up with.
    • Tell us about an instance you had to convince people you were right for a leadership position
    • Tell us in detail about your former experiences that can be relevant to this job.
    • Are you specifically interested in the product/company/space you’d be working in?
    • What’s a project you expect to work on at our company?
    • Are you willing to get your hands dirty (with messy data and stuffs)?
    • Don’t you think, you are overqualified for this position?
    • How will you approach a problem at hand?
    • What data do you need to find a solution to the problem?
    • What unique skills do you think you’d bring to the table?
    • How would you improve upon our product/ company?
    • How I would create/design/implement a certain algorithm from start to end?
    • Talk about a product that you want to build in this company.
    • How would you like to use data to change the world.
    • Why have you decided to take up data or analytics as your field?
    • What have you done to improve your data analysis knowledge in the past year?
    • Have you attended any conference/seminar on big data or data science?
    • What is the latest paper or book you read? What was your take away from that book?
    • What data science blogs do you follow?
    • Have you taken any data-science-related online courses? If yes, how many did you complete with a certificate?

    Questions on Group Dynamics

    • What teams are you interested in at this company?
    • This should come from your research on the company

    • Are you someone the team will be happy to have around on a personal level?
    • You may give some examples from past that goes to prove that you are a team player.

    • Have you ever had a problem with your peer? Can you give us an example?
    • Prepare a scenario where you had a difference of opinion with a colleague on implementing an idea and how you resolved it. Also add what lessons you draw from that incident.

    • Can you tell us something about your previous boss?
    • All my bosses possessed certain skills worth learning. I have always tried to learn something new from all my bosses including my previous boss.

    • Have there been instances, when your decision was challenged by your colleague or manager?
    • You may state an example where you were too ahead of the time with an idea or you had came up with a solution that was farsighted but the company was not ready to promise the resources required.

    Other Generic Questions

  • What do you think a data scientist’s job comprises of?
  • Read the post on analytics job description

  • What do you think are the most important skills a data scientist should have?
  • Read the post on qualities of a data scientist

  • What is the biggest data set that you have processed and how did you process it?
  • references:
    the questions have been collected from many different sources like actual interview experiences of data scientists, discussion on quora, facebook and other forums, collection of questions at itshared etc. to contribute to this page please feel free to post your questions in the comments section of this blog.

    Mar 02

    Collection of Machine Learning Interview Questions

    By ganpati | Interview Corner

    Get weekly updates about popular articles on these topics by email

    The Machine Learning part of the interview is usually the most elaborate one. That’s the reason we have dedicated a complete post to the interview questions from ML. We’ve also provided, wherever possible, the link to Suggested Reading material that will be helpful in answering these questions.

    We update these links from time to time and if you have any solution you can suggest please feel free to post it. You should explore these questions thoroughly, especially the ones that may relate to your previous experience and projects.

    General ML Questions

    Here is a nice post covering various aspects of machine learning that’ll be a good starting point.

    Take this analytics Quiz Now to Assess Your Skills


      • How will you differentiate a machine learning algorithm from other algorithms?

    Suggested reading

      • What’s the difference between data mining and machine learning?
      • What are the advantages of machine learning?

    Often much more accurate than human-crafted rules (since data driven) • humans often incapable of expressing what they know (e.g., rules of English, or how to recognize letters), but can easily classify examples • don’t need a human expert or programmer • cheap and flexible — can apply to any learning task

      • Describe some popular machine learning methods.

    Suggested Reading

      • How will you differentiate between supervised and unsupervised learning? Give few examples of algorithms for supervised learning?

    Suggested reading

    • What is your favorite ML algorithm? How will you explain it to a layman? Why is it your favourite?

    Suggested reading: Simplified understanding of Naive Bayes


    Suggested reading: Regression Analysis: An Essential Guide

    • Is regression some type of supervised learning? Why?
    • Explain the tradeoff between bias and variance in a regression problem.
    • A learning algorithm with low bias and high variance may be suitable under what circumstances?
    • What is regression analysis?
    • What do coefficient estimates mean?
    • How do you measure fit of the model? What do R and D mean?
    • What are some possible problems with regression models? How do you avoid or compensate for them?
    • Name a few types of regression you are familiar with? What are the differences?
    • What are the downfalls of using too many or too few variables for performing regression?

    Linear Regression

    Suggested reading on difference between linear and non-linear regression

    • What is linear regression? Why is it called linear?
    • What are the constraints you need to keep in mind when using a linear regression?
    • How does the variance of the error term change with the number of predictors, in OLS?
    • In linear regression, under what condition R^2 always equals a perfect 1?
    • Do you consider the models Y~X1+X2+X1X2 and Y~X1+X2+X1X2 to be linear? Why?

    Suggested reading

    • Do we always need the intercept term? When do we need it and when do we not?

    Suggested reading

    • What is collinearity and what to do with it?

    Suggested reading

    • How to remove multicollinearity?

    Suggested reading

    • What is overfitting a regression model? What are ways to avoid it?

    Suggested reading

    • What is Ridge Regression? How is it different from OLS Regression? Why do we need it?
    • What is Lasso regression? How is it different from OLS and Ridge?
    • What are the assumptions that standard linear regression models with standard estimation techniques make?
    • How can some of these assumptions be relaxed?
    • You fit a multiple regression to examine the effect of a particular feature. The feature comes back insignificant, but you believe it is significant. How will you explain it?
    • Your model considers the feature X significant, and Z is not, but you expected the opposite result. How will you explain it?
    • How to check if the regression model fits the data well?
    • When to use k-Nearest Neighbors for regression?
    • Could you explain some of the extension of linear models like Splines or LOESS/LOWESS?


    Basic Questions

    • State some real life problems where classification algorithms can be used?

    Text categorization (e.g., spam filtering) • fraud detection • optical character recognition • machine vision (e.g., face detection) • natural-language processing (e.g., spoken language understanding) • market segmentation (e.g.: predict if customer will respond to promotion) • bioinformatics (e.g., classify proteins according to their function) etc.

    • What is the simplest classification algorithm?

    Many consider Logistic Regression as a simple approach to begin with in order to to set a baseline and only make it more complicated if need be.

    • What is your favourite ML algorithm? Why is it your favourite? How will you describe it to a non-technical person.

    Decision Trees

    To answer questions on decision trees here are some useful links:
    Youtube video tutorial
    This article covers decision tree in depth
    Other suggested reading

    • What is a decision tree?
    • What are some business reasons you might want to use a decision tree model?
    • How do you build a decision tree model?
    • What impurity measures do you know?
    • Describe some of the different splitting rules used by different decision tree algorithms.
    • Is a big brushy tree always good?
    • How will you compare a decision tree to a logistic regression? Which is more suitable under different circumstances?
    • What is pruning and why is it important?

    Ensemble models:
    To answer questions on ensemble models here is a useful link:

    • Why do we combine multiple trees?
    • What is Random Forest? Why would you prefer it to SVM?

    Logistic regression:
    Link to understand basics of Logistic regression
    Here’s a nice tutorial from Khan Academy

    • What is logistic regression?
    • How do we train a logistic regression model?
    • How do we interpret its coefficients?

    Support Vector Machines
    A tutorial on SVM can be found here and here

    • What is the maximal margin classifier? How this margin can be achieved and why is it beneficial?
    • How do we train SVM? What about hard SVM and soft SVM?
    • What is a kernel? Explain the Kernel trick
    • Which kernels do you know? How to choose a kernel?

    Neural Networks
    Here’s a link to Neural Network course from Hinton on Coursera

    • What is an Artificial Neural Network?
    • How to train an ANN? What is back propagation?
    • How does a neural network with three layers (one input layer, one inner layer and one output layer) compare to a logistic regression?
    • What is deep learning? What is CNN (Convolution Neural Network) or RNN (Recurrent Neural Network)?

    Other models:

    • What other models do you know?
    • How can we use Naive Bayes classifier for categorical features? What if some features are numerical?
    • Tradeoffs between different types of classification models. How to choose the best one?
    • Compare logistic regression with decision trees and neural networks.


    Suggested Reading: wikipedia and Quora answers

    • What is Regularization?
    • Which problem does Regularization try to solve?

    Ans. used to address the overfitting problem, it penalizes your loss function by adding a multiple of an L1 (LASSO) or an L2 (Ridge) norm of your weights vector w (it is the vector of the learned parameters in your linear regression).

    • What does it mean (practically) for a design matrix to be “ill-conditioned”?
    • When might you want to use ridge regression instead of traditional linear regression?
    • What is the difference between the L1 and L2 regularization?
    • Why (geometrically) does LASSO produce solutions with zero-valued coefficients (as opposed to ridge)?

    Dimensionality Reduction

    Suggested Reading: Scikit and Kdnuggets

    • What is the purpose of dimensionality reduction and why do we need it?
    • Are dimensionality reduction techniques supervised or not? Are all of them are (un)supervised?
    • What ways of reducing dimensionality do you know?
    • Is feature selection a dimensionality reduction technique?
    • What is the difference between feature selection and feature extraction?
    • Is it beneficial to perform dimensionality reduction before fitting an SVM? Why or why not?

    Principal Component Analysis

    • What is Principal Component Analysis (PCA)? Under what conditions is PCA effective? How is it related to eigenvalue decomposition (EVD)?
    • What are the differences between Factor Analysis and Principal Component Analysis?
    • How will you use SVD to perform PCA? When SVD is better than EVD for PCA?
    • Why do we need to center data for PCA and what can happen if we don’t do it?
    • Do we need to normalize data for PCA? Why?
    • Is PCA a linear model or not? Why?

    Other Dimensionality Reduction techniques:

    • Do you know other Dimensionality Reduction techniques?
    • What is Independent Component Analysis (ICA)? What’s the difference between ICA and PCA?
    • Suppose you have a very sparse matrix where rows are highly dimensional. You project these rows on a random vector of relatively small dimensionality. Is it a valid dimensionality reduction technique or not?
    • Have you heard of Kernel PCA or other non-linear dimensionality reduction techniques? What about LLE (Locally Linear Embedding) or tt-SNE (tt-distributed Stochastic Neighbor Embedding)
    • What is Fisher Discriminant Analysis? How it is different from PCA? Is it supervised or not?

    Cluster Analysis

    Suggested reading: tutorialspoint and Lecture notes

    • Why do you need to use cluster analysis?
    • Give examples of some cluster analysis methods?
    • Differentiate between partitioning method and hierarchical methods.
    • Explain K-Means and its objective?
    • How do you select K for K-Means?
    • How would you assess the quality of clustering?


    Here is a good video to learn about optimization.

    Some basic questions about optimization

    • Give examples of some convex and non-convex algorithms.

    Examples of convex optimisation problems in machine learning

    linear regression/ Ridge regression, with Tikhonov regularisation, etc; sparse linear regression with L1 regularisation, such as lasso; Support vector machines; Parameter estimation in linear-Gaussian time series (Kalman filter and friends)

    Typical examples of non-convex optimization in ML are

    Neural networks; maximum likelihood mixtures of Gaussians

    • What is Gradient Descent Method?
    • Tell us the difference between Batch Gradient Descent and Stochastic gradient descent.
    • Give examples of some convex optimization problems in machine learning
    • Give examples of the algorithms using Gradient based methods of second order information.
    • Does Gradient Descent methods always converge to the same point?
    • Is it necessary that the Gradient Descent Method will always find the global minima?
    • What is a local optimum is and why is it important in a specific context, such as k-means clustering. What are specific ways for determining if you have a local optimum problem? What can be done to avoid local optima? Read possible answer

    Suggested Reading

    • Explain the Newton’s method?

    Suggested Reading

    • What kind of problems are well suited for Newton’s method? BFGS? SGD?
    • What are “slack variables”?
    • Describe a constrained optimization problem and how you would tackle it.


    some good examples of recommender models can be found here

    • What is a recommendation engine? How does it work?
    • How to do customer recommendation?
    • What is Collaborative Filtering?
    • How would you generate related searches for a search engine?
    • How would you suggest followers on Twitter?
    • Do you know about the Netflix Prize problem? How would you approach it?

    Here is a nice post on the Netflix challenge

    Feature Engineering

    Here is a good article on feature engineering

    • What is Feature Engineering?

    How predictors are encoded in a model can have a signi?cant impact on model performance and we achieve such encoding through feature engineering. Sometimes using combinations of predictors can be more e?ective than using the individual values: the product of two predictors may be more e?ective than using two independent predictors. Often the most e?ective encoding of the data is captured by the modeler’s understanding of the problem and thus is not derived from any mathematical technique.
    These features can be extracted in two ways: 1. By a human expert (known as hand-crafted) or 2. By using automated feature extraction methods such as PCA, or Deep Learning tools such as DBN. Both 1 and 2 can be used on top of each other.

    • Give an example where feature example can be very useful in predicting results from data and explain with reason why it is so effective in some cases?
    • What are some good ways for performing feature selection that do not involve exhaustive search?
    • How to convert categorical variables to numerical for extracting features?

    Feature Selection

    Here is a nice post on feature selection,
    also known as variable selection, attribute selection or variable subset selection

    • Explain feature selection and its importance with examples.
    • What is variance threshold approach?
    • How Univariate feature selection works?
    • Is there any negative impact of using too many or too few variables?
    • Is there any thumb rule for the number of features that should be used? How do you select the best features?
    • What will be your approach to recursive feature elimination?
    • Describe some feature selection methods.
    • Does the model affect the choice of feature selection method?

    Natural Language Processing (NLP)

    For basic introduction visit the wiki page.
    Here is the link to coursera course for NLP
    Pick the software from the The Stanford NLP (Natural Language Processing) Group and input some text to view its parse tree, named entities, part of speech tags, etc.
    If the company deals with text data, you can expect some questions on NLP and Information Retrieval:

    • Explain NLP to a non-technical person.
    • What’s the use of NLP in Machine Learning?

    Some interesting usages are in areas like sentiment analysis, spam detecting, POS, Text summarization, Language translation etc.

    • How unstructured text data can be converted into structured data for the purpose of ML models?
    • Explain Vector Space Model and its use?
    • Explain the distances and similarity measures that can be used to compare documents?
    • Explain cosine similarity in a simple way?

    Suggested Reading

    • Why and when stop words are removed? In which situation we do not remove them?

    Image processing and Text mining

    • What tool would you prefer for image processing?

    Some popular tools are: MATLAB, OpenCV or Octave

    • What parameters would you consider while selecting a tool for image processing?

    Ease of use, speed and resources needed are some of the common parameters

    • How to apply Machine Learning to images?
    • What are the text mining tools you are familiar with?

    Some example are:
    Commercial: Autonomy, Lexalytics , SAS/SPSS, SQLServer 2008+
    OpenSource: RapidMiner , NClassifier, OpenTextSumarizer, WordNet, OpenNLP/SharpNLP, Lucene/Lucene.NET, LingPipe, Weka

    • What techniques do you apply for processing texts? Explain with an example.
    • How to apply Machine Learning to audio data?

    Meta Learning

    Wiki link on meta learning

    • How will you differentiate between boosting and inductive transfer?

    Model selection

    • What criteria would you use while selecting the best model from many different models?
    • You have one model and want to find the best set of parameters for this model. How would you do that?
    • How would you use model tuning for arriving at the best parameters?

    Suggested Reading

    • Explain grid search and how you would use it?
    • What is Cross-Validation?
    • What is 10-Fold CV?
    • What is the difference between holding out a validation set and doing 10-Fold CV?

    Evaluating Machine Learning

    • How do you know if your model overfits?
    • How do you assess the results of a logistic regression?
    • Which evaluation metrics you know? Something apart from accuracy?
    • Which is better: Too many false positives or too many false negatives?
    • What precision and recall are?
    • What is a ROC curve? Write pseudo-code to generate the data for such a curve.
    • What is AU ROC (AUC)?
    • Do you know about Concordance or Lift?

    Discussion Questions

    • You have a marketing campaign and you want to send emails to users. You developed a model for predicting if a user will reply or not. How can you evaluate this model? Is there a chart you can use?


    Curse of Dimensionality

    • What is Curse of Dimensionality? What is the difference between density-sparse data and dimensionally-sparse data?

    Suggested Reading

    • Dealing with correlated features in your data set, how to reduce the dimensionality of data.
    • What are the problems of large feature space? How does it affect different models, e.g. OLS? What about computational complexity?
    • What dimensionality reductions can be used for preprocessing the data?
    • What is the difference between density-sparse data and dimensionally-sparse data?


    • You are training an image classifier with limited data. What are some ways you can augment your dataset?

    The questions have been collected from many different sources like actual interview experiences of data scientists, discussions on quora, facebook, various job sites and other forums, collection of questions at itshared etc. To contribute to this page please feel free to post your questions in the comments section of this blog.