NCA-GENM Question 142
Select 3You are tasked with developing a machine learning pipeline to classify customer reviews as either positive or negative. You decide to preprocess the text data using spaCy for tokenization, NumPy for numerical operations, and Keras for building the classification model. Which steps should you include in your pipeline to correctly implement this task?
- A
Use spaCy to tokenize the text and remove stop words.
- B
Transform the tokenized text into numerical vectors using NumPy.
- C
Train a convolutional neural network (CNN) in Keras with tokenized text as input.
- D
Convert the numerical vectors into embeddings using Keras's Embedding layer.
- E
Use spaCy to directly classify the text using a pre-trained spaCy model.
Show answer and explanation
Correct answers: A, B, D
Explanation
To implement a machine learning pipeline for text classification, you need to preprocess the text data (e.g., tokenize and remove stop words using spaCy), convert the tokenized text into numerical vectors (e.g., using NumPy), and prepare embeddings (e.g., using Keras's Embedding layer) to feed into a deep learning model. Direct classification using spaCy or feeding raw text into a CNN does not align with the described pipeline.
- A. Correct.
Correct: Tokenization and stop word removal are essential preprocessing steps to prepare text data for machine learning models.
- B. Correct.
Correct: NumPy can be used to transform tokenized text into numerical vectors, making the data suitable for deep learning models.
- C. Incorrect.
Incorrect: CNNs cannot directly accept raw tokenized text as input. The text must first be converted into numerical representations, such as embeddings.
- D. Correct.
Correct: The Keras Embedding layer can convert numerical vectors into dense embeddings for better input representations in the model.
- E. Incorrect.
Incorrect: While spaCy has pre-trained models for classification, this option bypasses the use of Keras, which is required in this scenario.