WGU D604 Task 2: Sentiment Analysis with Neural
Networks
Part I: Research Question
A1. Research Question
Research Question: How can a neural network model using natural language processing
techniques accurately classify customer sentiment in online reviews to help businesses
improve their customer experience and product offerings?
This question is relevant to real-world organizational needs as businesses across
industries (retail, entertainment, hospitality) rely on customer feedback to make strategic
decisions about product development, marketing strategies, and customer service
improvements.
A2. Objectives and Goals
Primary Objective: Develop a neural network model that can automatically classify text
reviews as positive or negative sentiment with high accuracy.
Specific Goals: 1. Achieve a classification accuracy of at least 75% on unseen test data 2.
Create a model that can process variable-length text sequences effectively 3. Implement
proper text preprocessing techniques to handle noisy real-world data 4. Develop a model
that can generalize across different domains (movies, products, restaurants)
A3. Neural Network Type
Selected Network: Bidirectional Long Short-Term Memory (Bi-LSTM) network
Justification: Bi-LSTM networks are industry-standard for text classification tasks because
they: - Can capture long-term dependencies in text sequences - Process text
bidirectionally to understand context from both directions - Are specifically designed for
sequential data like natural language - Have proven effectiveness in sentiment analysis
applications
Part II: Data Preparation
B1. Exploratory Data Analysis
Dataset Overview: The UCI Sentiment Labeled Sentences Dataset contains 3,000
sentences (1,000 each from IMDb, Amazon, and Yelp) with binary sentiment labels.
, Unusual Characters Analysis: - Found 13 unusual characters including ‘–’, ‘é’, ‘Â…’,
‘Ã¥’, ‘—’ - These appear to be encoding artifacts from text extraction - All unusual
characters were removed during preprocessing
Vocabulary Size: 3,052 unique words after preprocessing
Word Embedding Length: 100 dimensions chosen for the embedding layer
Statistical Justification for Maximum Sequence Length: - Analysis of sentence lengths
revealed: Mean = 7.5 words, Max = 41 words, Min = 1 word - 95th percentile of sentence
lengths is approximately 18 words - Chose 50 words as maximum sequence length to
accommodate 99% of sentences while maintaining efficiency - This provides sufficient
padding for longer reviews without excessive computational overhead
B2. Tokenization Process
Goals of Tokenization: 1. Convert text into numerical format that neural networks can
process 2. Create a consistent vocabulary mapping 3. Handle out-of-vocabulary words
appropriately 4. Maintain semantic meaning while reducing dimensionality
Code and Packages Used: - Used TensorFlow’s Keras Tokenizer class - Applied text
cleaning including lowercase conversion, punctuation removal, and stopword removal -
Created sequences of integer tokens representing words
B3. Padding Process
Padding Strategy: Post-padding (padding after the sequence) - Sequences shorter than
max_length are padded with zeros at the end - This preserves the natural order of words in
sentences - Allows the model to focus on actual content rather than padding tokens
Padded Sequence Example:
Networks
Part I: Research Question
A1. Research Question
Research Question: How can a neural network model using natural language processing
techniques accurately classify customer sentiment in online reviews to help businesses
improve their customer experience and product offerings?
This question is relevant to real-world organizational needs as businesses across
industries (retail, entertainment, hospitality) rely on customer feedback to make strategic
decisions about product development, marketing strategies, and customer service
improvements.
A2. Objectives and Goals
Primary Objective: Develop a neural network model that can automatically classify text
reviews as positive or negative sentiment with high accuracy.
Specific Goals: 1. Achieve a classification accuracy of at least 75% on unseen test data 2.
Create a model that can process variable-length text sequences effectively 3. Implement
proper text preprocessing techniques to handle noisy real-world data 4. Develop a model
that can generalize across different domains (movies, products, restaurants)
A3. Neural Network Type
Selected Network: Bidirectional Long Short-Term Memory (Bi-LSTM) network
Justification: Bi-LSTM networks are industry-standard for text classification tasks because
they: - Can capture long-term dependencies in text sequences - Process text
bidirectionally to understand context from both directions - Are specifically designed for
sequential data like natural language - Have proven effectiveness in sentiment analysis
applications
Part II: Data Preparation
B1. Exploratory Data Analysis
Dataset Overview: The UCI Sentiment Labeled Sentences Dataset contains 3,000
sentences (1,000 each from IMDb, Amazon, and Yelp) with binary sentiment labels.
, Unusual Characters Analysis: - Found 13 unusual characters including ‘–’, ‘é’, ‘Â…’,
‘Ã¥’, ‘—’ - These appear to be encoding artifacts from text extraction - All unusual
characters were removed during preprocessing
Vocabulary Size: 3,052 unique words after preprocessing
Word Embedding Length: 100 dimensions chosen for the embedding layer
Statistical Justification for Maximum Sequence Length: - Analysis of sentence lengths
revealed: Mean = 7.5 words, Max = 41 words, Min = 1 word - 95th percentile of sentence
lengths is approximately 18 words - Chose 50 words as maximum sequence length to
accommodate 99% of sentences while maintaining efficiency - This provides sufficient
padding for longer reviews without excessive computational overhead
B2. Tokenization Process
Goals of Tokenization: 1. Convert text into numerical format that neural networks can
process 2. Create a consistent vocabulary mapping 3. Handle out-of-vocabulary words
appropriately 4. Maintain semantic meaning while reducing dimensionality
Code and Packages Used: - Used TensorFlow’s Keras Tokenizer class - Applied text
cleaning including lowercase conversion, punctuation removal, and stopword removal -
Created sequences of integer tokens representing words
B3. Padding Process
Padding Strategy: Post-padding (padding after the sequence) - Sequences shorter than
max_length are padded with zeros at the end - This preserves the natural order of words in
sentences - Allows the model to focus on actual content rather than padding tokens
Padded Sequence Example: