0% found this document useful (0 votes)
30 views

AI UNIT 6 and UNIT 7 question and answers

The document covers key concepts in Natural Language Processing (NLP) and model evaluation, including techniques like tokenization, stemming, and the importance of metrics such as accuracy, precision, recall, and F1 score. It explains the use of confusion matrices for assessing model performance and highlights the role of NLP in recruitment processes. Additionally, it discusses the differences between Natural Language Understanding, Generation, and Dialog Management.

Uploaded by

sreddevank2010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

AI UNIT 6 and UNIT 7 question and answers

The document covers key concepts in Natural Language Processing (NLP) and model evaluation, including techniques like tokenization, stemming, and the importance of metrics such as accuracy, precision, recall, and F1 score. It explains the use of confusion matrices for assessing model performance and highlights the role of NLP in recruitment processes. Additionally, it discusses the differences between Natural Language Understanding, Generation, and Dialog Management.

Uploaded by

sreddevank2010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

CLASS 10

UNIT-6: Natural Language Processing

Natural Language Processing


6 SOLUTIONS

I. TRAIN YOUR BRAIN


A. Select the most appropriate answer from the options given below:
1. A bag of words model uses-
Ans: Both A and B
2. Stop words are-
Ans: Words that have no use in prediction
3. Stemming for the word cries is .................................
Ans: Cri
4. Which is not an example of a stopword?
Ans: Success
5. Which of the following techniques can be used for keyword normalization, the
process of converting a keyword into its base form?
Ans: Both A and B
6. This method is used for e-mail filtering and is a process NLP.
Ans: Text Classification
7. ELIZA robot was invented by
Ans: Weizenbaum
8. Which opinion is this according to Sentiment Analysis? “When the product has
multiple features that are suitable for users with different levels of experience.”
Ans: Positive

54 EP This is an attempt to help teachers with Answer key.


Y The teachers have the discretion to choose answers and their formation.
AI-X
9. ................................. is a technology that aids machines in comprehending spoken
or written human language.
Ans: NLU
10. ................................. bot regularly sends out prepared polls on a range of urgent
social issues, and users can respond with their input.
Ans: U-REPORT

B. Subjective Questions:
1. Explain tokenization in NLP.
Ans: The process of converting a text object into individual units is referred to as Tokenization.
Examples of tokens can be words, numbers, or punctuation symbols. The tokenized
form is used to:

⮞ Count the number of words in the text.


⮞ Count the frequency of the word.
2. What is Stemming? Explain with the help of an example.
Ans: Stemming is an elementary rule-based method to remove inflectional forms from a word,
leaving only the stem. Tokens must be stemmed to retrieve the base word, whichhelps
get the correct word frequency. Checking is in use for its simplicity and is a faster
method. For example, “update,” “updated,” and “updating” would all be stem to
“update.”
“update,” “updated,” “updating” >>>> “update.”
3. Explain stopwords with the help of examples.
Ans: Stopwords are any natural communicative language’s most frequently used words. The
grammar/stop words used in the human/natural language are for conveying the right
message. The grammatical terms/ stopwords do not add value to the meaning and must
not be transmitted while analyzing text data and building NLP models. After removing
stopwords from the text, the low-level information is excluded to give more focus
to the critical information. Removal of stopwords reduces the size of the dataset and
subsequently reduces the training time due to the fewer tokens involved in the training.
For example-

AI-X This is an attempt to help teachers with Answer key. YEP 55


The teachers have the discretion to choose answers and their formation.
The most common stopwords used in a text are “in,” “for,” “the,” “is,” “where,” “when,”
“to,” “at,” etc.
4. What is NLTK?
Ans: NLTK is a fantastic tool for learning and working in computational linguistics using
Python and is an incredible library to play with natural language.
5. List 2 limitations of the Bag of Words Model.
Ans: Limitations of the Bag of Words Model are-

⮞ The meaning or semantics of the chorus is lost, i.e. what it is saying.


⮞ The ordering of the words.
6. A document contains 100 words, wherein the word “discipline” appears 3 times.
Out of a corpus of 10 million documents, the word discipline appears in one
thousand of these. Calculate TF, IDF and TF-IDF.
Ans: TF (Term Frequency) is the ratio of the number of times a term (word) appears in a
document to the total number of times. In this case, the time “discipline” appears three
times in a document of 100 words: TF = (Number of times “discipline” appears in the
document) / (Total number of terms in the document) = 3 / 100 = 0.03 IDF (Inverse
Document Frequency) is a measure of how vital a time is in the corpus. It is calculated
as the logarithm of the ratio of the total number of documents in the canon to the number
of documents containing the term. In this case, the word “discipline” appears in 1,000 out
of a corpus of 10 million documents: IDF = log_e(Total number of documents in the
corpus / Number of documents containing the term) = log_e(10,000,000 / 1,000)
= log_e(10,000) = 9.210 TF-IDF (Term Frequency-Inverse Document Frequency) is
the product of TF and IDF, and it measures the relevance of a term to a document in the
corpus: TF-IDF = TF x IDF = 0.03 x 9.210 = 0.2763 (rounded to four decimal places)
Therefore, the TF, IDF, and TF-IDF values for the term “discipline” in the given
document and corpus are 0.03, 9.210, and 0.2763, respectively.
7. Explain the process of Sentiment Analysis.
Ans: The process for fundamental sentiment analysis of text documents is simple. Break each
text document down into its components (sentences, phrases, tokens, and parts of
speech)-

56 YEP This is an attempt to help teachers with Answer key. AI-X


The teachers have the discretion to choose answers and their formation.
⮞ Identify each sentiment-bearing phrase and component.
⮞ Give each phrase and component a sentiment score (from -1 to +1).
⮞ Optional: Combines scores for multi-layered sentiment analysis.
8. How is NLP useful for hiring and recruitments?
Ans: NLP (Natural Language Processing) can be useful for hiring and recruitment in several
ways. Here are some examples:
Resume Screening: NLP can automatically analyze resumes and job applications
to automatically identify critical skills, qualifications, and experience. This allows
recruiters to quickly screen extensive resumes and identify the most qualified candidates for
a job.
Job Posting Analysis: NLP can be used to analyze job postings to identify the essential
skills, qualifications, and experience required for a job. This helps create more accurate
and effective job postings that attract suitable candidates.
Candidate Matching: NLP can match candidate profiles with job requirements based
on skills, experience, and other qualifications. This helps recruiters identify the best job
candidates and reduce the hiring time.
Chatbots for Candidate Communication: NLP-powered chatbots can engage with
candidates, answer their questions, and provide personalized feedback on their
application status. This helps provide a positive candidate experience and improves the
overall recruitment process.
9. State the difference between Natural Language Understanding, Natural Language
Generation, and Dialog Management.
Ans: The differences between Natural Language Understanding (NLU), Natural Language
Generation (NLG), and Dialog Management:
Natural Language Understanding (NLU): It refers to the ability of machines to
understand and interpret human language. NLU analyzes text or speech data to identify
the language’s meaning, intent, and context. NLU systems analyze language structure
to extract relevant information and apply the appropriate actions. NLU is used in
applications like voice assistants, chatbots, and virtual assistants.

AI-X This is an attempt to help teachers with Answer key. YEP 57


The teachers have the discretion to choose answers and their formation.
Natural Language Generation (NLG): It refers to the ability of machines to generate
human-like language based on data inputs. NLG is used in automated content creation,
chatbots, and virtual assistants. NLG systems use algorithms and models to analyze data
and generate language outputs that are natural-sounding and relevant.
Dialog Management: refers to managing a conversation between a machine and a
human. Dialog management is used in applications like voice assistants, chatbots, and
virtual assistants. Dialog Management systems use NLU and NLG to understand user
input and generate appropriate responses. The design needs to keep track of the context
and history of the conversation to provide relevant answers.

58 YEP This is an attempt to help teachers with Answer key. AI-X


The teachers have the discretion to choose answers and their formation.
CLASS 10
UNIT-7: Evaluation

Evaluation
7 SOLUTIONS

I. TRAIN YOUR BRAIN


1. Consider the given scenario of Confusion Matrix:

What can we derive From This Matrix? Select the correct option:
Ans: Out of those 100 results, the model predicted “yes” 45 times and “no” 55 times. In
reality, 60 times the event in question occurred, and 40 times it didn’t.
2. Match the terms with correct formulae:
a. Accuracy - iii. (TP+TN)/Total
b True Positive Rate - iv. TP/predicted yes
c False Positive Rate - v. FP/actual no
d. Specificity - ii. TN/actual no
e. Precision - i. TP/ actual yes
3. Compute for the following Metrics using the values from the matrix given above
with the correctly identified formulae-
Ans: i) Accuracy- 85%
ii) True Positive Rate- 88%
iii) Specificity- 83%

EP
4. Observe the predicted and actual cases of the given Confusion Matrix:
Ans: Accuracy- 1.1
Recall- 0.952
Precision- 1.1
F1 Score- 3.918

A. Answer the following questions:


1. Why is Accuracy not appropriate for metric for measurement for an imbalanced
class?
Ans: Accuracy can be an inappropriate metric for measuring the performance of a binary
classification model in the case of imbalanced classes, where one type has a significantly
more significant number of observations than the other. This is because, in such
scenarios, a model that always predicts the majority class (the one with a higher number
of words) can still have a high accuracy rate. Still, it may not be helpful in practical
applications as it does not correctly identify the minority class. For example, consider
a binary classification problem where 90% of the observations belong to class A, and
only 10% belong to class B. If the model predicts all observations as class A, it will
achieve an accuracy of 90%, even if it cannot detect any comments from class B. This
can be problematic in scenarios like fraud detection, where the number of fraudulent
transactions is usually much smaller than legitimate ones. In such cases, we are more
interested in correctly identifying the minority class (fraudulent transactions) than
the majority class. Therefore, alternative metrics like precision, recall, and F1 score that
consider both the actual positive rate and false positive rate are more appropriate for
measuring the performance of binary classification models in imbalanced class
scenarios. These metrics help to evaluate the model’s ability to correctly identify the
minority class, which is of greater importance in such cases.
2. When and why should you look for evaluation metrics?
Ans: When should any model evaluation metrics-

⮞ After every model is trained as a test and validation set.


⮞ Regularly check the model for drift by evaluating new production data labeled with the
actual class.
⮞ After the new features are added, increase the scope of your model.

60 YEP This is an attempt to help teachers with Answer key. AI-X


The teachers have the discretion to choose answers and their formation.
⮞ Hyper-parameter tuning based on the evaluation metrics.
3. Describe the different approaches used for Model Evaluation.
Ans: Different approaches used for Model Evaluation are-

⮞ Hold-Out: In this method, the large dataset is divided into three subsets
⮞ Training set: It is used to build predictive models
⮞ Validation: It assesses the model’s performance made in the training phase. It providesa
test platform for finetuning the model’s parameters and thus selecting the model with
the best performance.
⮞ Test set:It’s a hidden subset of the dataset to predict a model’s expected future performance.
A model may be overfitting if it fits the training set substantially better than the test set.
⮞ Cross-Validation: With limited data available and to achieve an unbiased estimate of the
model performance, k-fold cross-validation is used. In k-fold cross-validation, w data
is divided into k subsets of equal size. We build models k times, each time leavingout
one of the subsets from training and using it as the test set. If k equals the sample size,
this is called «leave-one-out. »
4. Why is F1 score metrics better than accuracy?
Ans: The F1 score is often considered a better evaluation metric than accuracy because it takes
into account both precision and recall. Accuracy only feels the number of correct
predictions made by the model, while the F1 score balances the trade-off between
precision and recall. This is particularly important in cases with a class imbalance in the
data. For example, suppose the dataset has a majority class and a minority class. In that
case, accuracy can be misleading as it may result in the model incorrectly classifying
the minority class as the majority class. F1 score, on the other hand, provides a more
balanced measure of model performance, making it a better metric to evaluate models
in such scenarios.
5. What is Confusion Matrix? Why is it considered as the base for other metrics?
Ans: AConfusion Matrix is a desk used to assess the overall performance of a system, getting to
know the model. It is a matrix of predicted and actual values of a classification problem.
A confusion matrix is a base for other metrics because it provides a comprehensive
overview of a machine learning model’s performance.

AI-X EP

This is an attempt to help teachers with Answer key. Y 61


The teachers have the discretion to choose answers and their formation.
It helps determine the model’s accuracy, precision, recall, and f1-score. By analyzing
the confusion matrix, one identifies the areas where the model performs well and needs
improvement. Precision refers to the proportion of actual positive results among the
predicted positive results, while recall refers to the ratio of accurate positive results
among the actual positive results. F1-rating is the harmonic suggestion of precision and
recall.
6. What is the ROC plot? Name its X and Y axis.
Ans: A ROC (Receiver Operating Characteristics) plot is a graphical representation that
evaluates the performance of a binary classifier by plotting the True Positive Rate (TPR)
against the False Positive Rate (FPR). The X-axis of the ROC plot represents the False
Positive Rate (FPR), which is the proportion of negative instances predicted as positive
by the classifier. The Y-axis of the ROC plot represents the True Positive Rate (TPR),
which is the proportion of positive cases correctly predicted as positive by the classifier.
A ROC plot illustrates the trade-off between TPR and FPR for different classification
thresholds. The ideal ROC curve hugs the top left corner of the plot, indicating high
TPR and low FPR and better classification performance.
7. Is it always preferred to have F1 Score than precision or recall? Justify your answer.
Ans: No, it is not always preferred to have an F1 score than precision or recall. The choice of
metric depends on the problem statement and the business objectives. If the goal is to
identify all positive instances at the expense of some false positives, the recall could be
the preferred metric as it highlights the proportion of actual positive samples correctly
identified by the model. On the other hand, if the goal is to minimize the number of
false positives, precision could be the preferred metric as it highlights the proportion of
positive predicted positive instances. F1 score is a metric that balances both precision
and recall, which is useful when both metrics are essential for a particular problem.
However, in some cases, precision or recall alone may be more critical than the F1
score. For example, false negatives (missed diagnoses) could have severe consequences
in medical diagnosis. In such cases, recall becomes a crucial metric to assess the model’s
performance. Similarly, false positives (legitimate emails classified as spam) could
inconvenience the user in spam detection. Therefore, the choice of the metric should be
based on the problem statement, business objectives, and the consequences of false
positives and negatives. Thus, precision becomes a critical metric to consider.

You might also like