Vietnamese Review Intelligence Platform - Hệ thống phân tích và dự đoán sentiment cho review thương mại điện tử Shopee/e-commerce tiếng Việt.
Trong thương mại điện tử, review sản phẩm là nguồn thông tin quan trọng giúp người mua và người bán hiểu rõ hơn về chất lượng sản phẩm/dịch vụ. Tuy nhiên, với hàng nghìn review mỗi ngày, việc phân tích thủ công là không khả thi.
Bài toán này xây dựng một hệ thống tự động:
- Phân loại sentiment: Positive (tích cực) vs Negative (tiêu cực)
- Nhận diện aspect: Giao hàng, đóng gói, chất lượng, giá cả,...
- API dự đoán: Cung cấp REST API cho ứng dụng khác sử dụng
- Dashboard trực quan: Trình bày kết quả phân tích
- Làm sạch dữ liệu review tiếng Việt (preprocessing pipeline)
- Khám phá dữ liệu (EDA)
- Train baseline sentiment classification model (TF-IDF + ML)
- Nhận diện aspect trong review (keyword-based)
- Xây dựng FastAPI để dự đoán sentiment
- Tạo Streamlit dashboard để demo
- Lưu model, viết docs, chuẩn bị đưa lên GitHub/CV
| File | Mô tả | Dòng |
|---|---|---|
data/raw/reviews_accent.csv |
Review gốc (có dấu tiếng Việt) | ~9,591 |
data/raw/reviews_no_accent.csv |
Review không dấu | ~1,340 |
data/processed/cleaned_reviews.csv |
Review đã làm sạch | ~9,599 |
data/processed/final_reviews.csv |
Review + aspect | ~9,599 |
Các cột chính:
| Cột | Mô tả |
|---|---|
id |
ID duy nhất của review |
review |
Văn bản review gốc |
rating |
Điểm đánh giá (1-5 sao) |
label |
Nhãn sentiment: positive hoặc negative |
clean_review |
Review đã được làm sạch |
aspect |
Danh sách aspect (trong final_reviews.csv) |
Lưu ý: Dataset không có nhãn neutral. Rating 3 được gán theo heuristic.
data/raw/ ← Raw data
↓ [01_data_understanding]
data/raw/ ← Exploratory analysis
↓ [02_data_cleaning]
data/processed/cleaned_reviews.csv
↓ [04_baseline_model]
models/sentiment_model.pkl ← Linear SVM model
models/tfidf_vectorizer.pkl ← TF-IDF vectorizer
↓ [03_eda]
reports/figures/ ← EDA charts
↓ [05_model_evaluation]
reports/error_analysis.csv
↓ [06_aspect_detection]
data/processed/final_reviews.csv
↓ [src/predict.py]
API + Dashboard
vietnamese-review-intelligence/
├── api/
│ ├── main.py # FastAPI app
│ └── schemas.py # Request/Response schemas
├── dashboard/
│ └── app.py # Streamlit dashboard
├── data/
│ ├── external/ # Tài nguyên bên ngoài
│ │ ├── aspect_keywords.csv # Từ khóa aspect
│ │ ├── slang_dictionary.csv # Từ điển slang
│ │ └── vietnamese_stopwords.txt
│ ├── processed/ # Dữ liệu đã xử lý
│ │ ├── cleaned_reviews.csv
│ │ └── final_reviews.csv # + aspect
│ └── raw/ # Dữ liệu gốc
├── docs/ # Tài liệu dự án
│ ├── api.md
│ ├── aspect_detection.md
│ ├── baseline_model.md
│ ├── dashboard.md
│ ├── data_cleaning.md
│ ├── data_understanding.md
│ ├── eda_report.md
│ ├── model_evaluation.md
│ └── prediction_module.md
├── models/ # Model artifacts
│ ├── sentiment_model.pkl
│ └── tfidf_vectorizer.pkl
├── notebooks/ # Jupyter notebooks
│ ├── 01_data_understanding.ipynb
│ ├── 02_data_cleaning.ipynb
│ ├── 03_eda.ipynb
│ ├── 04_baseline_model.ipynb
│ ├── 05_model_evaluation.ipynb
│ └── 06_aspect_detection.ipynb
├── reports/
│ ├── figures/ # Biểu đồ
│ │ ├── aspect_distribution.png
│ │ ├── confusion_matrix.png
│ │ ├── label_distribution.png
│ │ ├── rating_distribution.png
│ │ ├── review_length_by_label.png
│ │ ├── top_words_overall.png
│ │ └── word_count_by_label.png
│ ├── error_analysis.csv
│ └── model_comparison.csv
├── src/
│ ├── aspect_detection.py # Aspect detection module
│ ├── convert_json_to_csv.py # JSON → CSV converter
│ ├── data_preprocessing.py # Preprocessing functions
│ ├── evaluate_model.py # Model evaluation script
│ ├── predict.py # Prediction module
│ └── train_baseline.py # Baseline training script
├── .gitignore
├── README.md
└── requirements.txt
- Khám phá schema dữ liệu, kiểu dữ liệu từng cột.
- Chọn dataset có dấu (
reviews_accent.csv) làm dữ liệu chính.
- Loại bỏ dòng trùng lặp, dòng thiếu.
- Chuẩn hóa text: lowercase, bỏ ký tự đặc biệt (giữ tiếng Việt).
- Chuẩn hóa từ viết tắt (slang) bằng từ điển.
- Chuẩn hóa ký tự lặp (okkkk → ok).
- Lưu
cleaned_reviews.csv.
- Phân tích phân bố label, rating.
- Word count analysis theo sentiment.
- Top words visualization.
- Nhận xét: class imbalance (negative nhiều hơn positive).
- TF-IDF vectorization (5000 features, ngram 1-2).
- Train 3 model: Logistic Regression, Naive Bayes, Linear SVM.
- So sánh bằng accuracy, macro F1, weighted F1.
- Chọn Linear SVM làm model tốt nhất.
- Accuracy: 94.06%
- Macro F1: 93.66%
- Confusion matrix visualization.
- Error analysis (114 lỗi / 1920 test samples).
- 8 nhóm aspect: giao_hang, dong_goi, chat_luong, gia_ca, shop_service, bao_hanh, sai_mo_ta, hang_gia.
- Keyword rule-based detection.
- Tạo
final_reviews.csvvới cột aspect.
- Endpoint
POST /predict: Dự đoán sentiment + aspect. - Endpoint
GET /: Thông tin project. - Endpoint
GET /health: Health check. - Swagger UI tại
/docs.
- KPI cards: tổng số review, rating TB, positive count, số aspect.
- Biểu đồ: Sentiment pie, Rating bar, Aspect distribution, Top words.
- Bộ lọc: theo sentiment, rating, aspect.
- Phần prediction: nhập review mới để dự đoán.
| Kỹ thuật | Mô tả |
|---|---|
| Vietnamese NLP Preprocessing | Làm sạch text tiếng Việt, giữ dấu, chuẩn hóa slang |
| TF-IDF | Chuyển text thành vector số (5000 features, unigrams + bigrams) |
| Logistic Regression | Baseline classifier (accuracy: 93.18%) |
| Naive Bayes | Baseline classifier (accuracy: 92.40%) |
| Linear SVM | Best baseline classifier (accuracy: 94.06%) |
| Sentiment Classification | Phân loại positive/negative |
| Aspect Detection | Keyword rule-based, 8 nhóm aspect |
| FastAPI | REST API endpoint |
| Streamlit | Interactive dashboard |
| Plotly Express | Biểu đồ trực quan |
cd vietnamese-review-intelligence
pip install -r requirements.txtpython src/train_baseline.pypython src/evaluate_model.pypython src/aspect_detection.pypython src/predict.pycd vietnamese-review-intelligence
uvicorn api.main:app --reloadAPI chạy tại: http://localhost:8000
Swagger UI: http://localhost:8000/docs
cd vietnamese-review-intelligence
streamlit run dashboard/app.pyDashboard chạy tại: http://localhost:8501
| Model | Accuracy | Macro F1 | Weighted F1 |
|---|---|---|---|
| Linear SVM | 94.06% | 93.66% | 94.05% |
| Logistic Regression | 93.18% | 92.69% | 93.15% |
| Naive Bayes | 92.40% | 91.95% | 92.41% |
Best Model: Linear SVM với accuracy 94.06% và macro F1 93.66%.
| Label | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| negative | 0.95 | 0.96 | 0.95 | 1193 |
| positive | 0.93 | 0.91 | 0.92 | 727 |
| Pred Negative | Pred Positive | |
|---|---|---|
| Actual Negative | 1144 | 49 |
| Actual Positive | 65 | 662 |
| Aspect | Số lượng | Tỷ lệ |
|---|---|---|
| giao_hang | 4,263 | 44.4% |
| chat_luong | 4,073 | 42.4% |
| dong_goi | 4,008 | 41.8% |
| shop_service | 2,797 | 29.1% |
| gia_ca | 1,836 | 19.1% |
| khac | 1,492 | 15.5% |
| sai_mo_ta | 897 | 9.3% |
| bao_hanh | 161 | 1.7% |
| hang_gia | 144 | 1.5% |
Một số biểu đồ đã được tạo trong reports/figures/:
confusion_matrix.png- Ma trận nhầm lẫnaspect_distribution.png- Phân bố aspectlabel_distribution.png- Phân bố sentimentrating_distribution.png- Phân bố ratingtop_words_overall.png- Top từ phổ biếnword_count_by_label.png- Số từ theo sentiment
- PhoBERT: Fine-tune PhoBERT cho sentiment classification (thường đạt 95%+ accuracy trên tiếng Việt)
- Aspect-Level Sentiment: Xác định sentiment riêng cho từng aspect trong review
- Neutral Label: Thêm nhãn trung lập cho rating 3 hoặc sử dụng 3-class classification
- Stopword Removal: Thêm bước loại bỏ stopwords trong preprocessing
- RAG Chatbot: Xây dựng chatbot hỏi đáp về sản phẩm dựa trên reviews (Retrieval Augmented Generation)
- Model Monitoring: Theo dõi độ chính xác model theo thời gian, phát hiện data drift
- Aspect Summary: Tự động tổng hợp ý kiến theo từng aspect (positive/negative %)
- Deploy lên Cloud: Heroku, Render, AWS, hoặc Google Cloud Platform
- API Documentation: Thêm rate limiting, authentication (JWT)
- Multi-language Support: Mở rộng sang tiếng Anh, tiếng Trung
- Real-time Dashboard: Kết nối API với data stream từ Shopee
data/- Dữ liệu lớnmodels/*.pkl- Model artifacts (nặng)reports/figures/- Biểu đồ có thể regenerate__pycache__/
Nếu muốn push model lên GitHub, có thể dùng Git LFS:
git lfs install
git lfs track "*.pkl"Hoặc lưu model trên Google Drive / Hugging Face Hub và chia sẻ link trong README.
MIT License
Vietnamese Review Intelligence Platform - Data Science + AI Engineering + Vietnamese NLP Project