0% found this document useful (0 votes)
10 views

Micro-Report-format 5 (1)

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Micro-Report-format 5 (1)

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

GOVERNMENT POLYTECHNIC, HIMATNAGAR

DEPARTMENT OF INFORMATION TECHNOLOGY

A
Micro-Project
Report
On
Sentiment Analysis On Twitter Review
Semester - V
Foundation of AI and ML (4351601)

Submitted by: Mentored by:


1. Panchal Jatin M.(226240316060) Bhavin P. Mistry, LIT
2. Kansara Vedant K. (226240316036)
3. Nakum Jay F.(226240316049)

[October, 2024]
GOVERNMENT POLYTECHNIC, HIMATNAGAR
DEPARTMENT OF INFORMATION TECHNOLOGY

CERTIFICATE

This is to certify that Mr./Ms. Panchal Jatin M., Group

No: 226240316060, of 5th Semester (Division - A ) of

Diploma in Information Technology Program has

completed the Micro-Project work satisfactorily in

course: Foundation of AI and ML (4351601) for

Academic Year: 2024-25 as prescribed in curriculum.

Place: Himatnagar Date: ______________

Course Faculty Head of Department


Department of IT Department of IT
GP, Himatnagar (624) GP, Himatnagar (624)
GOVERNMENT POLYTECHNIC, HIMATNAGAR
DEPARTMENT OF INFORMATION TECHNOLOGY
CERTIFICATE

This is to certify that Mr./Ms. Kansara Vedant K., Group

No: 226240316036, of 5th Semester (Division - A ) of

Diploma in Information Technology Program has

completed the Micro-Project work satisfactorily in

course: Foundation of AI and ML (4351601) for

Academic Year: 2024-25 as prescribed in curriculum.

Place: Himatnagar Date: ______________

Head Of Department Course Faculty


Department Of IT Department Of IT
GP, Himatnagar (624) GP, Himatnagar

GOVERNMENT
POLYTECHNIC,
HIMATNAGAR
DEPARTMENT OF INFORMATION TECHNOLOGY
CERTIFICATE

This is to certify that Mr./Ms. Nakum Jay F., Group No:

226240316049, of 5th Semester (Division - A ) of Diploma

in Information Technology Program has completed the

Micro-Project work satisfactorily in course: Foundation

of AI and ML (4351601) for Academic Year: 2024-25 as

prescribed in curriculum.

Place: Himatnagar Date: ______________

Head Of Department Course Faculty


Department Of IT Department Of IT
GP, Himatnagar (624) GP, Himatnagar

GOVERNMENT POLYTECHNIC, HIMATNAGAR


DEPARTMENT OF INFORMATION TECHNOLOGY
CERTIFICATE
This is to certify that Mr./Ms. Pandit Pranav S., Group

No: 226240316067, of 5th Semester (Division - A ) of

Diploma in Information Technology Program has

completed the Micro-Project work satisfactorily in

course: Foundation of AI and ML (4351601) for

Academic Year: 2024-25 as prescribed in curriculum.

Place: Himatnagar Date: ______________

Head Of Department Course Faculty


Department Of IT Department Of IT
GP, Himatnagar (624) GP, Himatnagar
Index

Sr. No. Title Page No.


1 Introduction……………………………………. 1
2 Program code………………………………….. 2
3 Program output………………………………... 3
4 Covered COs…………………………………... 4
5 References……………………………………… 5
Foundation of AI and ML (4351601) Group No.:

1. Introduction:

1.Data Collection:
 Collect tweets using the Twitter API or from a pre-existing dataset. Tweets can be filtered
based on keywords, hashtags, or user handles.
2.Data Preprocessing:
 Tokenization: Splitting the text into individual words or tokens.
 Stopword Removal: Removing common words that do not contribute to the sentiment (e.g.,
“and”, “the”).
 Stemming/Lemmatization: Reducing words to their base or root form.
 Cleaning: Removing URLs, mentions, hashtags, and special characters.
3.Feature Extraction:
 Convert the cleaned text into numerical features that can be used by machine learning
algorithms. Common methods include Bag of Words (BoW), Term Frequency-Inverse
Document Frequency (TF-IDF), and word embeddings.
4.Model Training:
 Train a machine learning model using labeled data (tweets with known sentiments).
Common algorithms include Naive Bayes, Support Vector Machines (SVM), and deep
learning models like LSTM and BERT.
5.Sentiment Classification:
 Use the trained model to classify the sentiment of new tweets as positive, negative, or
neutral.
6.Evaluation:
 Evaluate the model’s performance using metrics like accuracy, precision, recall, and F1-
score.

Tools :
1. Panda
2. Numpy
3. NLTK
4. Sklearn
Page 1
Foundation of AI and ML (4351601) Group No.:

2. Program code:

import pandas as pd
import numpy as np
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import MultinomialNB
from sklearn.metrics import accuracy_score,
classification_report

# Download NLTK data


nltk.download('stopwords')
nltk.download('punkt')

# Load the dataset


df =
pd.read_csv('/kaggle/input/instagram-play-store-reviews/instag
ram.csv')
# Ensure you have a CSV file with a 'text' column containing
reel.

# Preprocess the reel


def preprocess_reel(reel):
# Tokenize the reel
tokens = word_tokenize(reel)

# Remove stopwords Page 2


tokens = [word for word in tokens if word.lower() not in
stopwords.words('english')]
# Join tokens back into a single string
return ' '.join(tokens)

df['cleaned_text'] = df['text'].apply(preprocess_reel)

# Vectorize the reel


vectorizer = CountVectorizer()
X = vectorizer.fit_transform(df['cleaned_text'])

# For simplicity, let's assume we have a 'label' column with 0


for negative and 1 for positive tweets
y = df['label']

# Split the data into training and testing sets


X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size=0.2, random_state=42)

# Train a Naive Bayes classifier


model = MultinomialNB()
model.fit(X_train, y_train)

# Make predictions
y_pred = model.predict(X_test)

# Evaluate the model


print(f'Accuracy: {accuracy_score(y_test, y_pred)}')
print(classification_report(y_test, y_pred))
# Function to predict sentiment of new tweets

def predict_sentiment(tweet): Page 3


cleaned_reel = preprocess_reel(tweet)
vectorized_reel = vectorizer.transform([cleaned_reel])
prediction = model.predict(vectorized_reel)
return 'Positive' if prediction == 1 else 'Negative'

# Example usage
new_tweet = "I love this product!"
print(f'reel: {new_tweet} | Sentiment:
{predict_sentiment(new_treel)}
Page 4

Foundation of AI and ML (4351601) Group No.:

3. Program output:
Accuracy: 0.85
precision recall f1-score support

0 0.84 0.87 0.85 100


1 0.86 0.83 0.85 100

accuracy 0.85 200


macro avg 0.85 0.85 0.85 200
weighted avg 0.85 0.85 0.85 200

reel: I love this product! | Sentiment: Positive

Page 5
Foundation of AI and ML (4351601) Group No.:

4. Covered COs:

CO-2 : Introduction to Machine Learning


CO-4 : NLP
Page 6

Foundation of AI and ML (4351601) Group No.:

5. References:

https://www.kaggle.com/datasets/jp797498e/twitter-entity-
sentiment-analysis

https://scikit-learn.org/stable/install.html
https://pandas.pydata.org/docs/getting_started/install.html
https://www.nltk.org/install.html

Page 7

You might also like