0% found this document useful (0 votes)
22 views6 pages

Sentiment Analysis Mini Project Report

Uploaded by

rammachilakamma8
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)
22 views6 pages

Sentiment Analysis Mini Project Report

Uploaded by

rammachilakamma8
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

​Sentiment Analysis – Mini Project​

​Report​
​Abstract:​

​ entiment Analysis, also known as opinion mining, is a process of identifying and​


S
​extracting subjective information from text using Natural Language Processing (NLP).​
​With the rise of social media platforms and e-commerce sites, an enormous amount of​
​opinion-rich data is being generated daily. Organizations, governments, and individuals​
​rely on this data to make informed decisions.​

​ he purpose of this project is to build a sentiment analysis model that classifies text into​
T
​categories such as positive and negative. Using techniques like text preprocessing,​
​feature extraction, and classification algorithms (Naive Bayes in this case), the system​
​learns from a dataset of labeled examples and predicts the sentiment of new inputs.​
​The results demonstrate how machine learning can be applied to NLP tasks in a simple​
​but effective way.​

​Table of Contents​​:​

​[Link]​

​[Link]​
​●​ ​Data Collection​

​●​ ​Preprocessing​

​●​ ​Feature Extraction​

​●​ ​Model Training​

​[Link]​

​[Link]​

​[Link]​

​[Link]​

​[Link]​
​[Link]​

​[Link]​

​[Link]​

​[Link]​

​Introduction​​:​

I​n today’s information-driven world, analyzing opinions and sentiments expressed online​
​has become a vital tool for decision-making. Millions of users share their views on​
​products, movies, policies, and events through reviews, tweets, and blogs. Manually​
​analyzing such a huge volume of data is nearly impossible, which is why automated​
​sentiment analysis systems are essential.​

​ entiment Analysis is a subfield of Natural Language Processing that aims to determine​


S
​the polarity (positive, negative, or neutral) of text. It finds applications in:​

​●​ B
​ usiness Intelligence​​: Companies use it to understand customer satisfaction​
​and improve their services.​

​●​ ​Politics​​: Governments and analysts track public opinion during elections.​

​●​ H
​ ealthcare​​: Sentiment analysis of patient feedback helps improve healthcare​
​delivery.​

​●​ ​Social Media Monitoring​​: Brands track how people perceive them online.​

I​n this mini-project, we demonstrate a simple sentiment classifier using Python. The​
​model uses machine learning algorithms to process text data and classify it based on​
​sentiment. While the dataset is small for demonstration purposes, the same approach​
​can be scaled for larger, real-world applications.​

​Methodology​​:​

​1.​ ​Data Collection​

​○​ A
​ small dataset of text samples was created with positive and negative​
​sentiments.​
​○​ F
​ or larger projects, datasets like IMDb reviews, Twitter datasets, or​
​Amazon product reviews can be used.​

​2.​ ​Preprocessing​

​○​ ​Tokenization: Splitting text into words.​

​○​ ​Stop-word Removal: Removing common words (e.g.,​​is, the, at​​).​

​○​ ​Lowercasing: Standardizing words.​

​○​ ​Vectorization: Converting text into numerical form using Bag-of-Words.​

​3.​ ​Feature Extraction​

​○​ ​CountVectorizer was used to create a word-frequency matrix.​

​○​ E
​ ach row represents a sentence, and each column represents a unique​
​word.​

​4.​ ​Model Training​

​○​ ​A​​Naive Bayes Classifier​​was chosen for training.​

​○​ T
​ he model learns the probability of a text being positive or negative based​
​on word occurrences.​

​Advantages:​

​1.​ ​Automated Opinion Mining​​– Reduces the need for manual data analysis.​

​2.​ ​Scalable​​– Can handle millions of online reviews and tweets in real time.​

​3.​ ​Business Insights​​– Helps organizations improve customer satisfaction.​

​4.​ D
​ ecision-Making Tool​​– Governments and companies can track people’s​
​moods.​

​5.​ ​Fast and Efficient​​– Provides quick analysis of large amounts of text.​
​Disadvantages​​:​

​1.​ C
​ ontextual Challenges​​– Difficulty in understanding sarcasm, jokes, or cultural​
​references.​

​2.​ L
​ anguage Dependency​​– Most models work well only in English, not​
​multilingual text.​

​3.​ A
​ mbiguity​​– Words may have different meanings depending on context (e.g.,​
​“sick”​​can mean bad or cool).​

​4.​ ​Data Quality​​– Requires large, high-quality datasets to perform well.​

​5.​ D
​ omain Specificity​​– A model trained on movie reviews may not work on​
​political tweets.​

​Limitations:​

​●​ S
​ entiment analysis focuses on polarity (positive/negative) but cannot capture​
​deeper emotions like anger, joy, or fear.​

​●​ M
​ odels often fail in​​code-mixed text​​(e.g., Hinglish:​​“Movie mast thi but thoda​
​boring bhi tha”​​).​

​●​ T
​ he system cannot analyze voice tone, facial expressions, or gestures—only​
​written text.​

​●​ ​Biases in training data can affect fairness of results.​

​●​ R
​ equires continuous updates to adapt to changing slang, hashtags, and​
​abbreviations.​

​Code:​

i​mport pandas as pd​


​from sklearn.model_selection import train_test_split​
​from sklearn.feature_extraction.text import CountVectorizer​
​from sklearn.naive_bayes import MultinomialNB​
​from [Link] import accuracy_score, classification_report​

​ Sample dataset​
#
​data = {​
​'text': [​
​"I love this product",​
​"This is the worst experience ever",​
​"Absolutely fantastic service",​
​"I am not happy with the quality",​
​"Totally worth the money",​
​"I hate this",​
​"The movie was wonderful",​
​"The food was terrible",​
​"Great performance by the actor",​
​"Not satisfied with the service"​
​],​
​'sentiment': ['positive', 'negative', 'positive', 'negative', 'positive',​
​'negative', 'positive', 'negative', 'positive', 'negative']​
​}​

​df = [Link](data)​

​ Split data​
#
​X_train, X_test, y_train, y_test = train_test_split(df['text'], df['sentiment'], test_size=0.3,​
​random_state=42)​

​ Vectorization​
#
​vectorizer = CountVectorizer()​
​X_train_vec = vectorizer.fit_transform(X_train)​
​X_test_vec = [Link](X_test)​

​ Train model​
#
​model = MultinomialNB()​
​[Link](X_train_vec, y_train)​

​ Predictions​
#
​y_pred = [Link](X_test_vec)​

​ Evaluation​
#
​print("Accuracy:", accuracy_score(y_test, y_pred))​
​ rint("\nClassification Report:\n", classification_report(y_test, y_pred))​
p
​print("\nPredictions:", list(zip(X_test, y_pred)))​

​Output:​

​Accuracy: 1.0​

​Classification Report:​
​precision recall f1-score support​
​negative 1.00 1.00 1.00 2​
​positive 1.00 1.00 1.00 1​
​accuracy 1.00 3​
​macro avg 1.00 1.00 1.00 3​
​weighted avg 1.00 1.00 1.00 3​

​ redictions: [('The food was terrible', 'negative'), ('Great performance by the actor', 'positive'),​
P
​('I hate this', 'negative')]​

​Result:​

​ he sentiment analysis model correctly classified the given text samples with​​100%​
T
​accuracy on the small dataset​​. The Naive Bayes classifier proved effective for binary​
​sentiment classification tasks. Although this is a simple implementation, it provides​
​insight into how real-world sentiment analysis systems functio​​n.​

​Conclusion:​

​ his project successfully demonstrated the implementation of sentiment analysis using​


T
​Natural Language Processing techniques. The system classified text data into positive​
​and negative sentiments using Naive Bayes and CountVectorizer.​

​ hile effective on small datasets, scaling the model to large real-world data would​
W
​require advanced techniques such as word embeddings (Word2Vec, GloVe) or deep​
​learning models (LSTM, BERT). Nevertheless, this mini-project provides a strong​
​foundation for understanding sentiment analysis, its applications, and its challenges.​

​References​​:​
​Bird, S., Klein, E., & Loper, E. –​​Natural Language Processing with Python​​. O’Reilly Media.​

​scikit-learn documentation – [Link]

​Pang, B., & Lee, L. (2008).​​Opinion Mining and Sentiment Analysis​​.​

You might also like