Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
19 views11 pages

Sentiment Analysis

The document presents a sentiment analysis of Nokia products based on customer reviews, utilizing a dataset to calculate sentiment scores and categorize products by price. Key findings indicate that mid-range products have the highest sentiment scores, while low-end products receive the lowest. Additionally, it identifies overpriced and underpriced products based on their sentiment scores and prices, highlighting customer perceptions of value and quality.

Uploaded by

rishavraghavcoc
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)
19 views11 pages

Sentiment Analysis

The document presents a sentiment analysis of Nokia products based on customer reviews, utilizing a dataset to calculate sentiment scores and categorize products by price. Key findings indicate that mid-range products have the highest sentiment scores, while low-end products receive the lowest. Additionally, it identifies overpriced and underpriced products based on their sentiment scores and prices, highlighting customer perceptions of value and quality.

Uploaded by

rishavraghavcoc
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
You are on page 1/ 11

sentiment-analysis

March 13, 2025

1 Sentiment Score Analaysis


[66]: import pandas as pd

# Load dataset
df = pd.read_excel("Nokia_Sentiment_3.xlsx")

# Check for missing values


print(df.isnull().sum())

# Display first few rows


df.head()

Unique_ID 0
Product Description 0
Brand Name 0
Price 63
Rating 0
Reviews 0
Review Votes 616
Cleaned_Reviews 0
Sentiment_Score 0
Sentiment_Category 0
dtype: int64

[66]: Unique_ID Product Description Brand Name \


0 27963490 "Nokia Asha 302 Unlocked GSM Phone with 3.2MP … Nokia
1 62566502 "Nokia Asha 302 Unlocked GSM Phone with 3.2MP … Nokia
2 99266675 "Nokia Asha 302 Unlocked GSM Phone with 3.2MP … Nokia
3 84586613 "Nokia Asha 302 Unlocked GSM Phone with 3.2MP … Nokia
4 27963514 "Nokia Asha 302 Unlocked GSM Phone with 3.2MP … Nokia

Price Rating Reviews \


0 299.0 5 Phone is working on, I was planning to use it …
1 299.0 5 excellent product in perfect condition
2 299.0 2 I like these phone I bought it for my mom and …
3 299.0 2 It came with arabian keyboard :(

1
4 299.0 3 I love the phone, but one problem and one prob…

Review Votes Cleaned_Reviews \


0 0.0 phone work plan use whatsapp anyway oh problem…
1 0.0 excellent product perfect condition
2 0.0 like phone buy mom love
3 0.0 come arabian keyboard
4 0.0 love phone one problem one problem onlyonce mi…

Sentiment_Score Sentiment_Category
0 -0.4019 Negative
1 0.8126 Positive
2 0.7717 Positive
3 0.0000 Neutral
4 -0.4939 Negative

[67]: df

[67]: Unique_ID Product Description \


0 27963490 "Nokia Asha 302 Unlocked GSM Phone with 3.2MP …
1 62566502 "Nokia Asha 302 Unlocked GSM Phone with 3.2MP …
2 99266675 "Nokia Asha 302 Unlocked GSM Phone with 3.2MP …
3 84586613 "Nokia Asha 302 Unlocked GSM Phone with 3.2MP …
4 27963514 "Nokia Asha 302 Unlocked GSM Phone with 3.2MP …
… … …
16494 97227407 Unlocked Nokia LUMIA 1520 20 million pixel Cam…
16495 94081680 Unlocked Nokia LUMIA 1520 20 million pixel Cam…
16496 95130256 Unlocked Nokia LUMIA 1520 20 million pixel Cam…
16497 35361424 Unlocked Nokia LUMIA 1520 20 million pixel Cam…
16498 99324565 Unlocked Nokia LUMIA 1520 20 million pixel Cam…

Brand Name Price Rating \


0 Nokia 299.00 5
1 Nokia 299.00 5
2 Nokia 299.00 2
3 Nokia 299.00 2
4 Nokia 299.00 3
… … … …
16494 Nokia 229.99 4
16495 Nokia 229.99 3
16496 Nokia 229.99 5
16497 Nokia 229.99 1
16498 Nokia 229.99 1

Reviews Review Votes \


0 Phone is working on, I was planning to use it … 0.0
1 excellent product in perfect condition 0.0

2
2 I like these phone I bought it for my mom and … 0.0
3 It came with arabian keyboard :( 0.0
4 I love the phone, but one problem and one prob… 0.0
… … …
16494 Works well but with a few bugs here and there… 0.0
16495 Phone works great but battery is on its last leg 0.0
16496 Yes I will like that.if u can send me a red on… 0.0
16497 I bought this phone to replace my old Lumia 92… 5.0
16498 Screen barley attached. No vibrate. NaN

Cleaned_Reviews Sentiment_Score \
0 phone work plan use whatsapp anyway oh problem… -0.4019
1 excellent product perfect condition 0.8126
2 like phone buy mom love 0.7717
3 come arabian keyboard 0.0000
4 love phone one problem one problem onlyonce mi… -0.4939
… … …
16494 work well bug first problem screen rotation pr… -0.5106
16495 phone work great battery last leg 0.6249
16496 yes like thatif u send red one cooland possibl… 0.6369
16497 buy phone replace old lumia 925 seller say new… -0.1045
16498 screen barley attach vibrate 0.0000

Sentiment_Category
0 Negative
1 Positive
2 Positive
3 Neutral
4 Negative
… …
16494 Negative
16495 Positive
16496 Positive
16497 Negative
16498 Neutral

[16499 rows x 10 columns]

2 Sentiment Score vs Rating


[70]: import seaborn as sns
import matplotlib.pyplot as plt

# Plot sentiment category vs. rating


plt.figure(figsize=(8, 5))
sns.boxplot(x=df['Rating'], y=df['Sentiment_Score'], palette='coolwarm')

3
plt.title("Sentiment Score vs. Rating")
plt.show()

C:\Users\HP\AppData\Local\Temp\ipykernel_6596\1856440810.py:6: FutureWarning:

Passing `palette` without assigning `hue` is deprecated and will be removed in


v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same
effect.

sns.boxplot(x=df['Rating'], y=df['Sentiment_Score'], palette='coolwarm')

Product with high Rating giving higher sentiment score validating the data
[74]: # Check correlation between numerical features
correlation_matrix = df[['Rating', 'Price', 'Review Votes', 'Sentiment_Score']].
↪corr()

# Visualize correlation heatmap


sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', fmt=".2f")
plt.title("Correlation Between Sentiment, Rating, Price, and Review Votes")
plt.show()

4
3 Average Sentiment Score by Price Groups

4 Dividing data into 3 groups based on price - High End, Medium


Range, and Low End Phones
[76]: # Define price categories
def categorize_price(price):
if price <= 300:
return "Low-End"
elif price <= 500:
return "Mid-Range"
else:
return "High-End"

df["Price_Category"] = df["Price"].apply(categorize_price)

5
# Calculate average sentiment score per price category
avg_sentiment = df.groupby("Price_Category")["Sentiment_Score"].mean().
↪reset_index()

# Display results
print(avg_sentiment)

# Visualize Sentiment Score across Price Categories


plt.figure(figsize=(8, 5))
sns.barplot(x="Price_Category", y="Sentiment_Score", data=avg_sentiment,␣
↪palette="coolwarm")

plt.title("Average Sentiment Score by Price Category")


plt.xlabel("Price Category")
plt.ylabel("Average Sentiment Score")
plt.show()

Price_Category Sentiment_Score
0 High-End 0.509980
1 Low-End 0.490299
2 Mid-Range 0.514464
C:\Users\HP\AppData\Local\Temp\ipykernel_6596\1626161144.py:20: FutureWarning:

Passing `palette` without assigning `hue` is deprecated and will be removed in


v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same
effect.

sns.barplot(x="Price_Category", y="Sentiment_Score", data=avg_sentiment,


palette="coolwarm")

6
Key Takeaways:
1� Mid-Range Products Have the Highest Sentiment (0.5144)
Customers perceive mid-range products as the best value for money.
They may have a good balance between quality and affordability.
2� High-End Products (0.5099) Have Lower Sentiment Than Mid-Range
Expensive products might not justify their high price for some users.
Customers may expect premium quality and service, and if expectations aren’t met, they leave
neutral or negative feedback.
3� Low-End Products Have the Lowest Sentiment (0.4903)
Cheaper products may have quality issues or performance limitations.
Users might have lower expectations, but still, dissatisfaction is noticeable in the sentiment.

5 Finding Best and Worst Product as Reviewed By Customer


[52]: # Define percentiles
price_75 = df["Price"].quantile(0.75) # Upper quartile (high price)
price_25 = df["Price"].quantile(0.25) # Lower quartile (low price)
sentiment_75 = df["Sentiment_Score"].quantile(0.75) # High sentiment

7
sentiment_25 = df["Sentiment_Score"].quantile(0.25) # Low sentiment

# Overpriced: High Price, Low Sentiment


overpriced = df[(df["Price"] > price_75) & (df["Sentiment_Score"] <␣
↪sentiment_25)]

top_overpriced = overpriced.sort_values(by="Price", ascending=False).head(3)

# Underpriced: Low Price, High Sentiment


underpriced = df[(df["Price"] < price_25) & (df["Sentiment_Score"] >␣
↪sentiment_75)]

top_underpriced = underpriced.sort_values(by="Sentiment_Score",␣
↪ascending=False).head(3)

# Display results
print("� Top 3 Overpriced Products (High Price, Low Sentiment):")
print(top_overpriced[["Product Description", "Brand Name", "Price",␣
↪"Sentiment_Score"]])

print("\n� Top 3 Underpriced (Hidden Gems) (Low Price, High Sentiment):")


print(top_underpriced[["Product Description", "Brand Name", "Price",␣
↪"Sentiment_Score"]])

� Top 3 Overpriced Products (High Price, Low Sentiment):


Product Description Brand Name Price \
2663 Nokia 8800 Arte Gold Nokia 1619.1
15602 Nokia Lumia 930 International Unlocked Version… Nokia 1300.0
2665 Nokia 8800 GOLD Nokia 1169.1

Sentiment_Score
2663 -0.6705
15602 -0.2173
2665 -0.7430

� Top 3 Underpriced (Hidden Gems) (Low Price, High Sentiment):


Product Description Brand Name Price \
2033 Nokia 5800 XpressMusic Unlocked Phone with U.S… Nokia 79.00
5552 Nokia E7-00 Unlocked GSM Phone with Touchscree… Nokia 49.99
4274 Nokia C6 Unlocked GSM Phone with Easy E-mail S… Nokia 59.95

Sentiment_Score
2033 0.9995
5552 0.9995
4274 0.9994

8
6 Overpriced vs. Underpriced Product Analysis (Python-
Friendly)
� Overpriced Products (High Price, Low Sentiment)
1� Nokia 8800 Arte Gold – Price: $1619.10, Sentiment: -0.6705
Issue: Extremely expensive, but customers feel it’s not worth the cost. Likely seen as outdated.
2� Nokia Lumia 930 (International) – Price: $1300.00, Sentiment: -0.2173
Issue: High cost for an international version, possibly compatibility concerns.
3� Nokia 8800 GOLD – Price: $1169.10, Sentiment: -0.7430
Issue: Similar to Arte Gold, too expensive for perceived value.
� Underpriced (Hidden Gems) (Low Price, High Sentiment)
1� Nokia 5800 XpressMusic – Price: $79.00, Sentiment: 0.9995
Insight: Customers love it despite low price. Likely durable, reliable, and functional.
2� Nokia E7-00 – Price: $49.99, Sentiment: 0.9995
Insight: High sentiment score means great customer satisfaction for price. Strategy: Highlight as
a feature-packed budget device in marketing.
3� Nokia C6 – Price: $59.95, Sentiment: 0.9994
Insight: Positive reception; likely offers good usability.
Strategy: Bundle accessories to increase profit margin without raising price.
[78]: import matplotlib.pyplot as plt

# Extract first 3 words of the Product Description for labeling


df["Short_Product_Name"] = df["Product Description"].apply(lambda x: ' '.join(x.
↪split()[:3]))

# Group by short product name and compute mean sentiment


product_sentiment = df.groupby("Short_Product_Name")["Sentiment_Score"].mean().
↪sort_values()

# Select top 5 and bottom 5 products


top_products = product_sentiment.tail(5) # Best sentiment
worst_products = product_sentiment.head(5) # Worst sentiment

# Plot Top 5 Products


plt.figure(figsize=(10, 5))
top_products.plot(kind="bar", color="green")
plt.title("Top 5 Products by Sentiment Score")
plt.ylabel("Avg Sentiment Score")
plt.xticks(rotation=45)

9
plt.show()

# Plot Bottom 5 Products


plt.figure(figsize=(10, 5))
worst_products.plot(kind="bar", color="red")
plt.title("Bottom 5 Products by Sentiment Score")
plt.ylabel("Avg Sentiment Score")
plt.xticks(rotation=45)
plt.show()

10
[ ]:

11

You might also like