Artificial Intelligence Scenario Based Interview Question

Q1. Show the working of the Minimax algorithm using Tic-Tac-Toe Game.

There are two players involved in a game:

  • MAX: This player tries to get the highest possible score
  • MIN: MIN tries to get the lowest possible score

The following approach is taken for a Tic-Tac-Toe game using the Minimax algorithm:

Step 1: First, generate the entire game tree starting with the current position of the game all the way up to the terminal states.

Step 2: Apply the utility function to get the utility values for all the terminal states.

Step 3: Determine the utilities of the higher nodes with the help of the utilities of the terminal nodes. For instance, in the diagram below, we have the utilities for the terminal states written in the squares.

Let us calculate the utility for the left node(red) of the layer above the terminal:

MIN{3, 5, 10}, i.e. 3.
Therefore, the utility for the red node is 3.

Similarly, for the green node in the same layer:
MIN{2,2}, i.e. 2.

Step 4: Calculate the utility values.

Step 5: Eventually, all the backed-up values reach to the root of the tree. At that point, MAX has to choose the highest value:
i.e. MAX{3,2} which is 3.

Therefore, the best opening move for MAX is the left node(or the red one).
To summarize,

Minimax Decision = MAX{MIN{3,5,10},MIN{2,2}}
= MAX{3,2}
= 3

Q2. Which method is used for optimizing a Minimax based game?

Alpha-beta Pruning
If we apply alpha-beta pruning to a standard minimax algorithm, it returns the same move as the standard one, but it removes all the nodes that are possibly not affecting the final decision.

In this case,
Minimax Decision = MAX{MIN{3,5,10}, MIN{2,a,b}, MIN{2,7,3}}
= MAX{3,c,2}
= 3

Hint: (MIN{2,a,b} would certainly be less than or equal to 2, i.e., c<=2 and hence MAX{3,c,2} has to be 3.)

Q3. Which algorithm does Facebook use for face verification and how does it work?

Facebook uses DeepFace for face verification. It works on the face verification algorithm, structured by Artificial Intelligence (AI) techniques using neural network models.

Here’s how face verification is done:

Input: Scan a wild form of photos with large complex data. This involves blurry images, images with high intensity and contrast.

Process: In modern face recognition, the process completes in 4 raw steps:

  • Detect facial features
  • Align and compare the features
  • Represent the key patterns by using 3D graphs
  • Classify the images based on similarity

Output: Final result is a face representation, which is derived from a 9-layer deep neural net

Training Data: More than 4 million facial images of more than 4000 people

Result: Facebook can detect whether the two images represent the same person or not

Q4. Explain the logic behind targeted marketing. How can Machine Learning help with this?

Target Marketing involves breaking a market into segments & concentrating it on a few key segments consisting of the customers whose needs and desires most closely match your product.

It is the key to attracting new business, increasing your sales, and growing the company.

The beauty of target marketing is that by aiming your marketing efforts at specific groups of consumers it makes the promotion, pricing, and distribution of your products and/or services easier and more cost-effective.

Machine Learning in targeted marketing:

  • Text Analytics Systems: The applications for text analytics ranges from search applications, text classification, named entity recognition, to pattern search and replace applications.
  • Clustering: With applications including customer segmentation, fast search, and visualization.
  • Classification: Like decision trees and neural network classifiers, which can be used for text classification in marketing.
  • Recommender Systems: And association rules which can be used to analyze your marketing data
  • Market Basket Analysis: Market basket analysis explains the combinations of products that frequently
    co-occur in transactions.

Q5. How can AI be used in detecting fraud?

Artificial Intelligence is used in Fraud detection problems by implementing Machine Learning algorithms for detecting anomalies and studying hidden patterns in data.

The following approach is followed for detecting fraudulent activities:

Data Extraction: At this stage data is either collected through a survey or web scraping is performed. If you’re trying to detect credit card fraud, then information about the customer is collected. This includes transactional, shopping, personal details, etc.

Data Cleaning: At this stage, the redundant data must be removed. Any inconsistencies or missing values may lead to wrongful predictions, therefore such inconsistencies must be dealt with at this step.

Data Exploration & Analysis: This is the most important step in AI. Here you study the relationship between various predictor variables. For example, if a person has spent an unusual sum of money on a particular day, the chances of a fraudulent occurrence are very high. Such patterns must be detected and understood at this stage.

Building a Machine Learning model: There are many machine learning algorithms that can be used for detecting fraud. One such example is Logistic Regression, which is a classification algorithm. It can be used to classify events into 2 classes, namely, fraudulent and non-fraudulent.

Model Evaluation: Here, you basically test the efficiency of the machine learning model. If there is any room for improvement, then parameter tuning is performed. This improves the accuracy of the model.

Q6. A bank manager is given a data set containing records of 1000s of applicants who have applied for a loan. How can AI help the manager understand which loans he can approve? Explain.

This problem statement can be solved using the KNN algorithm, that will classify the applicant’s loan request into two classes:

  1. Approved
  2. Disapproved

K Nearest Neighbour is a Supervised Learning algorithm that classifies a new data point into the target class, depending on the features of its neighboring data points.

The following steps can be carried out to predict whether a loan must be approved or not:

Data Extraction: At this stage data is either collected through a survey or web scraping is performed. Data about the customers must be collected. This includes their account balance, credit amount, age, occupation, loan records, etc. By using this data, we can predict whether or not to approve the loan of an applicant.

Data Cleaning: At this stage, the redundant variables must be removed. Some of these variables are not essential in predicting the loan of an applicant, for example, variables such as Telephone, Concurrent credits, etc. Such variables must be removed because they will only increase the complexity of the Machine Learning model.

Data Exploration & Analysis: This is the most important step in AI. Here you study the relationship between various predictor variables. For example, if a person has a history of unpaid loans, then the chances are that he might not get approval on his loan applicant. Such patterns must be detected and understood at this stage.

Building a Machine Learning model: There are n number of machine learning algorithms that can be used for predicting whether an applicant loan request is approved or not. One such example is the K-Nearest Neighbor, which is a classification and a regression algorithm. It will classify the applicant’s loan request into two classes, namely, Approved and Disapproved.

Model Evaluation: Here, you basically test the efficiency of the machine learning model. If there is any room for improvement, then parameter tuning is performed. This improves the accuracy of the model.

Q7. You’ve won a 2-million-dollar worth lottery’ we all get such spam messages. How can AI be used to detect and filter out such spam messages?

To understand spam detection, let’s take the example of Gmail. Gmail makes use of machine learning to filter out such spam messages from our inbox. These spam filters are used to classify emails into two classes, namely spam and non-spam emails.

Let’s understand how spam detection is done using machine learning:

A machine learning process always begins with data collection. We all know the data Google has, is not obviously in paper files. They have data centers which maintain the customer’s data. Data such as email content, header, sender, etc are stored.

  • This is followed by data cleaning. It is essential to get rid of unnecessary stop words and punctuations so that only the relevant data is used for creating a precise machine learning model. Therefore, in this stage stop words such as ‘the’, ‘and’, ‘a’ are removed. The text is formatted in such a way that it can be analyzed.
  • After data cleaning comes data exploration and analysis. Many a time, certain words or phrases are frequently used in spam emails. Words like “lottery”, “earn”, “full-refund” indicate that the email is more likely to be a spam one. Such words and co-relations must be understood in this stage.
  • After retrieving useful insights from data, a machine learning model is built. For classifying emails as either spam or non-spam you can use machine learning algorithms like Logistic Regression, Naïve Bayes, etc. The machine learning model is built using the training dataset. This data is used to train the model and make it learn by using past user email data.
  • This stage is followed by model evaluation. In this phase, the model is tested using the testing data set, which is nothing but a new set of emails. After which the machine learning model is graded based on the accuracy with which it was able to classify the emails correctly.
  • Once the evaluation is over, any further improvement in the model can be achieved by tuning a few variables/parameters. This stage is also known as parameter tuning. Here, you basically try to improve the efficiency of the machine learning model by tweaking a few parameters that you used to build the model.
  • The last stage is deployment. Here the model is deployed to the end users, where it processes emails in real time and predicts whether the email is spam or non-spam.

Q8. Let’s say that you started an online shopping business and to grow your business, you want to forecast the sales for the upcoming months. How would you do this? Explain.

This can be done by studying the past data and building a model that shows how the sales have varied over a period of time. Sales Forecasting is one of the most common applications of AI. Linear Regression is one of the best Machine Learning algorithms used for forecasting sales.

When both sales and time have a linear relationship, it is best to use a simple linear regression model.

Linear Regression is a method to predict dependent variable (Y) based on values of independent variables (X). It can be used for the cases where we want to predict some continuous quantity.

  • Dependent variable (Y):
    The response variable whose value needs to be predicted.
  • Independent variable (X):
    The predictor variable used to predict the response variable.

In this example, the dependent variable ‘Y’ represents the sales and the independent variable ‘X’ represents the time period. Since the sales vary over a period of time, sales is the dependent variable.

The following equation is used to represent a linear regression model:

Y=𝒃𝟎+𝒃𝟏 𝒙+ⅇ

Here,

  • Y = Dependent variable
  • 𝒃𝟎 = Y-Intercept
  • 𝒃𝟏 = Slope of the line
  • x = Independent variable
  • e = Error

Therefore, by using the Linear Regression model, wherein Y-axis represents the sales and X-axis denotes the time period, we can easily predict the sales for the upcoming months.

Q9. ‘Customers who bought this also bought this…’ we often see this when we shop on Amazon. What is the logic behind recommendation engines?

E-commerce websites like Amazon make use of Machine Learning to recommend products to their customers. The basic idea of this kind of recommendation comes from collaborative filtering. Collaborative filtering is the process of comparing users with similar shopping behaviors in order to recommend products to a new user with similar shopping behavior.

To better understand this, let’s look at an example. Let’s say a user A who is a sports enthusiast bought, pizza, pasta, and a coke. Now a couple of weeks later, another user B who rides a bicycle buys pizza and pasta. He does not buy the coke, but Amazon recommends a bottle of coke to user B since his shopping behaviors and his lifestyle is quite similar to user A. This is how collaborative filtering works.

Q10. What is market basket analysis and how can Artificial Intelligence be used to perform this?

Market basket analysis explains the combinations of products that frequently co-occur in transactions.

For example, if a person buys bread, there is a 40% chance that he might also buy butter. By understanding such correlations between items, companies can grow their businesses by giving relevant offers and discount codes on such items.

Market Basket Analysis is a well-known practice that is followed by almost every huge retailer in the market. The logic behind this is Machine Learning algorithms such as Association Rule Mining and Apriori algorithm:

  • Association rule mining is a technique that shows how items are associated with each other.
  • Apriori algorithm uses frequent itemsets to generate association rules. It is based on the concept that a subset of a frequent itemset must also be a frequent itemset.

For example, the above rule suggests that, if a person buys item A then he will also buy item B. In this manner the retailer can give a discount offer which states that on purchasing Item A and B, there will be a 30% off on item C. Such rules are generated using Machine Learning. These are then applied on items in order to increase sales and grow a business.

Q11. Place an agent in any one of the rooms (0,1,2,3,4) and the goal is to reach outside the building (room 5). Can this be achieved through AI? If yes, explain how it can be done.

In the above figure:

  • 5 rooms in a building connected by doors
  • Each room is numbered 0 through 4
  • The outside of the building can be thought of as one big room (5)
  • Doors 1 and 4 directly lead into the building from room 5 (outside)

This problem can be solved by using the Q-Learning algorithm, which is a reinforcement learning algorithm used to solve reward based problems.

Let’s represent the rooms on a graph, each room as a node, and each door as a link, like so:

Next step is to associate a reward value to each door:

doors that lead directly to the goal have a reward of 100

  • Doors not directly connected to the target room have zero reward
  • Because doors are two-way, two arrows are assigned to each room
  • Each arrow contains an instant reward value

Now let’s try to understand how Q-Learning can be used to solve this problem. The terminology in Q-Learning includes the terms state and action:

  • The room (including room 5) represents a state
  • Agent’s movement from one room to another represents an action

In the figure, a state is depicted as a node, while “action” is represented by the arrows. Suppose, the Agent traverses from room 2 to room5, then the following path is taken:

  1. Initial state = state 2
  2. State 2 -> state 3
  3. State 3 -> state (2, 1, 4)
  4. State 4 -> state 5

Next, we can put the state diagram and the instant reward values into a reward table or a matrix R, like so:

Reinforcement Learning

The next step is to add another matrix Q, representing the memory of what the agent has learned through experience.

  • The rows of matrix Q represent the current state of the agent
  • columns represent the possible actions leading to the next state

The formula to calculate the Q matrix:

Q(state, action) = R(state, action) + Gamma * Max [Q(next state, all actions)]

Here, Q(state, action) and R(state, action) represent the state and action in the Reward matrix R and the Memory matrix Q.

Note: The Gamma parameter has a range of 0 to 1 (0 <= Gamma > 1).

  • If Gamma is closer to zero, the agent will tend to consider only immediate rewards.
  • If Gamma is closer to one, the agent will consider future rewards with greater weight

Finally, by following the below steps, the agent will reach room 5 by taking the most optimal path:

Q12. The crop yield in India is degrading because farmers are unable to detect diseases in crops during the early stages. Can AI be used for disease detection in crops? If yes, explain.

AI can be used to implement image processing and classification techniques for extraction and classification of leaf diseases.

This sounds complex, let me break it down into steps:

Image Acquisition: The sample images are collected and stored as an input database.

Image Pre-processing: Image pre-processing includes the following:

  • Improve image data that suppresses unwanted distortion
  • Enhance image features
  • Image clipping, enhancement, color space conversion
  • Perform Histogram equalization to adjust the contrast of an image

Image Segmentation: It is the process of partitioning a digital image into multiple segments so that image analysis becomes easier. Segmentation is based on image features such as color, texture. A popular Machine Learning method used for segmentation is the K-means clustering algorithm.

Feature Extraction: This is done to extract information that can be used to find the significance of a given sample. The Haar Wavelet transform can be used for texture analysis and the computations can be done by using Gray-Level Co-Occurrence Matrix.

Classification: Finally, Linear Support Vector Machine is used for classification of leaf disease. SVM is a binary classifier which uses a hyperplane called the decision boundary between two classes. This results in the formation of two classes:

  1. Diseased leaves
  2. Healthy leaves

Therefore, AI can be used in Computer Vision to classify and detect disease by studying and processing images. This is one of the most profound applications of AI.

Artificial Intelligence Basic Level Interview Questions — https://soorajsknair.medium.com/artificial-intelligence-basic-level-interview-questions-246dd383681b

Artificial Intelligence Intermediate Level Interview Questions — https://soorajsknair.medium.com/artificial-intelligence-intermediate-level-interview-questions-422b7054469f

--

--

--

Aspiring on Computer vision, Data science , NLP , IoT https://www.linkedin.com/in/soorajece1993/ https://mobile.twitter.com/Soorajsknair

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AI and Education

Artificial Intelligence and Climate Crisis.

Artificial Intelligence in Marketing

Artificial Intelligence potential

Scope of Artificial Intelligence in Military Operations.

It Never Forgets a Face

A woman in a crowd of anonymous people

MANIA AI-Assisted NFT Trading — Part 2

AI Bias in Medicine 🩺

Meta Open-Sources Multi-Modal AI Algorithm Data2vec

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sooraj S

Sooraj S

Aspiring on Computer vision, Data science , NLP , IoT https://www.linkedin.com/in/soorajece1993/ https://mobile.twitter.com/Soorajsknair

More from Medium

Starting a new machine learning project? User this 3-tier system to gau

TensorFlow and DJL Machine Learning Pipeline

Recognising Handwritten Digits

Building an Indian Chaat classifier