How karunya-475/product-review-sentiment-analysis works
Purpose and execution model
This is a notebook-centric Python NLP project for three-class product-review sentiment classification: POSITIVE, NEUTRAL, and NEGATIVE. The primary executable and end-to-end workflow is Product Review Analysis.ipynb; it is designed for Jupyter/Google Colab rather than as a packaged service or CLI.
Data boundary
Product_Reviews.csv is the sole local input dataset. It supplies product identifiers, free-text reviews, and labeled sentiment targets. The notebook loads and validates this tabular data, separating review text as model input from the Sentiment label used for supervised training and evaluation.
Semantic feature extraction
The central representation stage uses the external Sentence Transformers model all-MiniLM-L6-v2, executed through PyTorch, to convert review text into 384-dimensional dense embeddings. This forms the principal boundary between raw natural-language input and conventional numerical ML:
• Input: review strings from Product_Reviews.csv
• Output: embedding matrix consumed by scikit-learn classifiers
• Implementation workflow: Product Review Analysis.ipynb
Training and model comparison
The notebook splits labeled embeddings into training and test data, then trains four scikit-learn classifiers: Random Forest, Gradient Boosting, class-balanced Logistic Regression, and Linear SVM. Class-balanced weighting is specifically applied to address minority NEGATIVE and NEUTRAL labels. The comparative model-selection flow is implemented in Product Review Analysis.ipynb.
Evaluation and decision criteria
Models are evaluated using accuracy plus imbalance-aware F1 metrics, including macro and weighted/class-level reporting. This is an important quality boundary: accuracy captures overall fit, while macro F1 and per-class recall expose performance on underrepresented sentiment classes. The README identifies Linear SVM as the strongest candidate for high-dimensional embedding features, while balanced logistic regression favors negative-review recall.
Unseen-review inference
After training/evaluation, the selected embedding-plus-classifier path is applied to previously unseen review text. Inference must preserve the same Sentence Transformer encoder used for training before passing vectors to the selected classifier. This flow remains notebook-local in Product Review Analysis.ipynb; no serialized model artifact, API, or deployment application is present.
Runtime and external dependencies
Execution requires Python 3.8+ with Jupyter or Google Colab. Material dependencies are sentence-transformers, PyTorch, scikit-learn, pandas, NumPy, matplotlib, and seaborn. The embedding model is an external pretrained model dependency and may require model retrieval/caching at runtime. Repository documentation and usage context are in README.md.
Main entry points: Product Review Analysis.ipynb Train/Test Split · README.md Project Documentation · Product_Reviews.csv Product Reviews
Components 16
Notebook Runtime
Interactive Python 3.8+ execution in Jupyter or Colab.
- Analysis Notebook · Primary end-to-end training and inference workflow.
Product Review Analysis.ipynb - ML Dependencies · sentence-transformers, PyTorch, scikit-learn, pandas, NumPy, matplotlib, and seaborn.
Sentiment ML Pipeline
- Load & Validate Data · Separates review text from the Sentiment target.
Product Review Analysis.ipynb - MiniLM Encoder · all-MiniLM-L6-v2 converts reviews into 384-dimensional vectors.
Product Review Analysis.ipynb - Review Embeddings · Dense numerical representation consumed by classifiers.
Product Review Analysis.ipynb - Train/Test Split · Partitions labeled embeddings for fitting and evaluation.
Product Review Analysis.ipynb - Random Forest
Product Review Analysis.ipynb - Gradient Boosting
Product Review Analysis.ipynb - Balanced Logistic Regression · Class weighting improves minority sentiment handling.
Product Review Analysis.ipynb - Linear SVM · Documented strongest candidate for embedding features.
Product Review Analysis.ipynb - Model Evaluation · Accuracy, macro/weighted F1, per-class metrics, and recall guide selection.
Product Review Analysis.ipynb - Selected Classifier · Chosen from comparative evaluation; no serialized artifact exists.
Product Review Analysis.ipynb - Unseen Review Text
Product Review Analysis.ipynb - Sentiment Prediction
Product Review Analysis.ipynb
Other components
- Project Documentation · Describes usage, dependencies, and model tradeoffs.
README.md - Product Reviews · Review text, product identifiers, and sentiment labels.
Product_Reviews.csv
Connections 19
- Project Documentation → Analysis Notebook: documents
- ML Dependencies → Analysis Notebook: runtime dependencies
- Product Reviews → Load & Validate Data: CSV input
- Analysis Notebook → Load & Validate Data: executes
- Load & Validate Data → MiniLM Encoder: review strings
- MiniLM Encoder → Review Embeddings: 384-d vectors
- Review Embeddings → Train/Test Split: labeled features
- Train/Test Split → Random Forest: training data
- Train/Test Split → Gradient Boosting: training data
- Train/Test Split → Balanced Logistic Regression: training data
- Train/Test Split → Linear SVM: training data
- Random Forest → Model Evaluation: test predictions
- Gradient Boosting → Model Evaluation: test predictions
- Balanced Logistic Regression → Model Evaluation: test predictions
- Linear SVM → Model Evaluation: test predictions
- Model Evaluation → Selected Classifier: selects
- Unseen Review Text → MiniLM Encoder: same encoder
- MiniLM Encoder → Selected Classifier: inference vectors
- Selected Classifier → Sentiment Prediction: predicts