NCA-GENM Question 141
Select 2You are tasked with building a text classification model to categorize product reviews as positive, negative, or neutral. Which combination of Python packages would be most appropriate to preprocess the text data, convert it into numerical representations, and train a machine learning model?
- A
spaCy for text preprocessing, NumPy for numerical computations, and Keras for building the classification model
- B
NumPy for text tokenization, spaCy for sentiment analysis, and Keras for building the classification model
- C
spaCy for tokenization and lemmatization, NumPy for creating numerical arrays, and scikit-learn for training a classification model
- D
Pandas for data manipulation, spaCy for named entity recognition, and TensorFlow for building the classification model
- E
NLPy for preprocessing, PyTorch for model training, and Matplotlib for visualizing the results
Show answer and explanation
Correct answers: A, C
Explanation
For a text classification task, preprocessing the text (e.g., tokenization, lemmatization) is crucial. spaCy is a robust library for such operations. Numerical representations can be handled using NumPy, while scikit-learn or Keras can be used to train classification models. The first and third options correctly identify these components, making them the optimal choices for the given scenario.
- A. Correct.
Correct: spaCy is widely used for text preprocessing (e.g., tokenization, lemmatization). NumPy is useful for handling numerical data, and Keras is suitable for building machine learning models, including classification tasks.
- B. Incorrect.
Incorrect: NumPy is not used for text tokenization, and spaCy is not designed explicitly for sentiment analysis. While Keras is appropriate for building classification models, the other components make this option unsuitable for the task.
- C. Correct.
Correct: This is an effective combination. spaCy can preprocess text (e.g., tokenization, lemmatization), NumPy can handle numerical computations, and scikit-learn offers robust tools for traditional machine learning tasks, including classification.
- D. Incorrect.
Incorrect: While Pandas is excellent for data manipulation, spaCy's named entity recognition is not directly relevant to the task of text classification. TensorFlow could be used for the model, but this combination is not optimal for the given task.
- E. Incorrect.
Incorrect: NLPy is not a widely recognized library for preprocessing, and while PyTorch and Matplotlib are powerful tools, they are not the most efficient or appropriate choices for this specific workflow.