Notes:
-
Problem Solved: Performs sentiment analysis on customer reviews or NPS responses.
-
Customization Benefits: Tailor sentiment thresholds or keywords per product.
-
Further Adoption: Feed results into product improvement or alerting systems.
Python Code:
from textblob import TextBlob
import pandas as pd
def analyze_sentiment(text):
return TextBlob(text).sentiment.polarity
feedback_df = pd.read_csv("customer_feedback.csv") # Column: 'feedback'
feedback_df['sentiment_score'] = feedback_df['feedback'].apply(analyze_sentiment)
# Categorize feedback
feedback_df['sentiment_label'] = feedback_df['sentiment_score'].apply(
lambda x: 'Positive' if x > 0.1 else ('Negative' if x < -0.1 else 'Neutral')
)
print(feedback_df[['feedback', 'sentiment_label']])
No comments:
Post a Comment