This project showcases an end-to-end MLOps pipeline for sentiment analysis using the Amazon Review dataset.
Source: Amazon Review Dataset
Version: 3 (Updated 09/09/2015)
The dataset contains Amazon reviews spanning 18 years, including ~35 million reviews up to March 2013. Each review includes product information, user details, ratings, and plaintext review content.
For more details, refer to:
- J. McAuley and J. Leskovec, RecSys 2013: Hidden factors and hidden topics: understanding rating dimensions with review text.
The polarity dataset for this project is constructed by Xiang Zhang as a benchmark for text classification. For more details, refer to:
- Xiang Zhang, Junbo Zhao, Yann LeCun, NIPS 2015: Character-level Convolutional Networks for Text Classification.
- Reviews are classified as positive (scores 4 & 5) or negative (scores 1 & 2). Neutral reviews (score 3) are excluded.
- Each class contains:
- 1,800,000 training samples
- 200,000 testing samples
Files:
train.csv
andtest.csv
(comma-separated values with the following columns):- Class index (1 = Negative, 2 = Positive)
- Review title
- Review text
Special Formatting:
- Review title and text are enclosed in double quotes (
"
), and internal double quotes are escaped (""
). - Newlines are represented as
\n
.
- Docker Image:
aswaths/sentimentanalysis
- Streamlit App: Streamlit Sentiment Analysis App
-
Prepare the Dataset
- Download the dataset and place it in the
data
folder.
- Download the dataset and place it in the
-
Run the FastAPI Server
- Execute
serve.py
to launch the FastAPI server. - Access API documentation at
http://localhost:8000/docs
.
- Execute
-
Make Predictions
- Use the following
curl
command to fetch predictions:curl -X POST "http://localhost:8000/predict" -H "Content-Type: application/json" -d '{"query": "This is a great product!"}'
- Use the following
-
Build and Run Docker Image
- To build the Docker image:
docker build -t <image_name> . docker run <image_name>
- Modify the
Dockerfile
as needed.
- To build the Docker image:
-
Push to DockerHub
- Create a DockerHub repository, then upload your image:
docker login docker tag <image_name> <username>/<repo>:<tag> docker push <username>/<repo>:<tag>
- Create a DockerHub repository, then upload your image:
-
Monitor Models with MLflow
- Access the MLflow UI to track and monitor model performance.