Data Science project 14
Customer Feedback Analysis Project in Python
Build a complete customer feedback analysis workflow with reproducible Python code, traceable calculations, validation checks, and honest limitations.
Explore Data Science training in VizagView all project ideas
Analysis question
Which transparent keyword themes occur in feedback, and how do their average ratings differ?
Dataset
Ten synthetic comments with one-to-five ratings and no real customer identifiers.
Requirements
- Python 3.10 or later
- A terminal or command prompt
python -m pip install pandas- About 45-60 minutes to build and review
Method and data checks
Tokenise comments, map visible keyword sets to support, usability, performance, or content, allow multiple themes per comment, and aggregate mentions and ratings.
- Theme dictionaries are inspectable
- Comments can contribute to more than one theme
- Unmatched comments are retained as other
- Low-rating rate uses ratings of two or below
Complete Python code
Save the program as ds_customer_feedback_analysis.py. The dataset generator or loader, analysis functions, output, and reproducibility controls are included.
"""Theme and rating analysis for a small synthetic feedback table."""
from __future__ import annotations
import re
import pandas as pd
THEMES = {"support": {"support", "agent", "reply"}, "usability": {"easy", "confusing", "screen", "navigation"}, "performance": {"fast", "slow", "loading"}, "content": {"lesson", "example", "course", "explanation"}}
def demo_feedback() -> pd.DataFrame:
return pd.DataFrame({"rating": [5, 2, 4, 1, 5, 3, 4, 2, 5, 3], "comment": ["Support agent gave a fast reply", "The screen is confusing", "Clear lesson and helpful example", "Loading is very slow", "The course explanation is excellent", "Navigation is okay", "Support solved my issue", "Examples need more detail", "Easy lessons and fast pages", "Agent reply arrived later"]})
def detect_themes(text: str) -> list[str]:
tokens = set(re.findall(r"[a-z]+", text.lower()))
return [theme for theme, words in THEMES.items() if tokens & words] or ["other"]
def analyse_feedback(data: pd.DataFrame) -> tuple[dict[str, float], pd.DataFrame]:
feedback = data.copy()
feedback["theme"] = feedback["comment"].map(detect_themes)
exploded = feedback.explode("theme")
theme_summary = exploded.groupby("theme", as_index=False).agg(mentions=("comment", "size"), average_rating=("rating", "mean")).sort_values(["mentions", "average_rating"], ascending=[False, True])
kpis = {"responses": float(len(feedback)), "average_rating": float(feedback["rating"].mean()), "low_rating_rate": float((feedback["rating"] <= 2).mean())}
return kpis, theme_summary
def main() -> None:
kpis, themes = analyse_feedback(demo_feedback())
print({k: round(v, 3) for k, v in kpis.items()})
print(themes.round(2).to_string(index=False))
print("Keyword themes are transparent but miss context; review comments manually.")
if __name__ == "__main__":
main()
Run the project
- Create and activate a virtual environment.
- Install dependencies with
python -m pip install pandas. - Run
python ds_customer_feedback_analysis.py. - Reconcile row counts and totals before interpreting patterns.
- Read the limitations before substituting any real dataset.
Expected analytical output
Response count, average rating, low-rating rate, and a theme table with mentions and mean rating.
Interpretation and responsible-use limits
Keyword tagging misses context, irony, negation, emerging topics, and language variation. Read source comments, protect privacy, and sample-check every automated theme before action.
Ways to extend the project
Create annotation guidelines, measure inter-rater agreement, add phrase rules, multilingual handling, trend views, representative examples, and privacy-preserving redaction.
Continue learning Data Science
Try the next project, return to the Softenant project library, or explore the Data Science course in Vizag for guided data cleaning, analysis, visualisation, and portfolio feedback.