Quiz Space

Machine Learning Practice · Quiz 2 · 1 Dec 2024 · September 2024 term

Question 20: In the following code snippet, how many bigrams will be …

Question 20

+3 marksNumerical answer

In the following code snippet, how many bigrams will be generated when using CountVectorizer with ngram_range=(2, 2)?

python
from sklearn.feature_extraction.text import CountVectorizer
documents = [
"The quick brown fox",
"jumps over the lazy dog"
]
vectorizer = CountVectorizer(ngram_range=(2, 2))
X = vectorizer.fit_transform(documents)
bigrams = vectorizer.vocabulary_
print(f"Number of bigrams: {len(bigrams)}")

Enter your answer (number of bigrams):

Show answer

Correct answer: 7

Question 20 of 21 in the IIT Madras BS Machine Learning Practice (MLP) Quiz 2 paper sat on 1 Dec 2024, in the September 2024 term (IIT M DIPLOMA AN EXAM QDD2 01 Dec 2024). It carries 3 marks.

More questions from this paper

  1. Q1Consider the following code for Ridge Regression: What will be the output for the coefficients?
  2. Q2Consider the following code for Stochastic Gradient Descent (SGD) Classifier: What is the significance of l1_ratio = 0.…
  3. Q3Given the following code for Polynomial Regression: What will be the output of the code?
  4. Q4Consider the following code implementation that utilizes sklearn to set up a machine learning model with preprocessing:…
  5. Q5Figure question
  6. Q6Consider the following code: What will be the behavior of the code?
  7. Q7Figure question
  8. Q8Figure question
  9. Q9You are working on a classification project using the Wine dataset. After fitting a Gaussian Naive Bayes model, you wan…
  10. Q10Figure question
  11. Q11Figure question
  12. Q12Figure question
  13. Q13Figure question
  14. Q14Figure question
  15. Q15You are a data scientist working on a binary classification problem to predict whether customers will buy a product bas…
  16. Q16Consider the following RidgeClassifier implementation in Python: Which of the following statements are correct? (Select…
  17. Q17Figure question
  18. Q18Figure question
  19. Q19What will be the output of the following code?
  20. Q21Figure question