This project implements a complete MLOps pipeline for sentiment analysis on Amazon product reviews using Azure Machine Learning. The workflow includes data preprocessing, model training, hyperparameter tuning, evaluation, deployment, and inference via a REST API endpoint.
The model used is Logistic Regression (scikit-learn).
- Efficient and fast to train on large datasets
- Suitable for binary classification tasks
- Provides a strong baseline for text-based features
- Simple to deploy and interpret
The model uses engineered numerical features derived from the dataset.
-
Expanded list-based features into separate columns
-
Removed non-numeric and irrelevant columns such as:
- reviewText, title, summary, asin, reviewerID
-
Converted all features to numeric format
-
Filled missing values with 0
-
Ensured consistent feature columns across train, validation, test, and deployment datasets
- sbert_tfidf
- all (selected for final model)
Hyperparameter tuning was performed using an Azure ML sweep job.
- Regularization strength (C)
- Solver type
- Maximum iterations
- Minimal variation across runs
- Performance remained consistent
- Final configuration selected based on stability
- Accuracy: ~0.802
- Precision: ~0.802
- Recall: 1.0
- F1 Score: ~0.890
- AUC: ~0.50
- High recall indicates the model predicts most positive cases correctly
- AUC near 0.5 suggests limited discrimination capability
- Model tends to favor the majority class
The trained model was deployed using Azure ML Managed Online Endpoints.
- Registered model: amazon-review-sentiment-model
- Scoring script: score.py
- Environment: custom conda environment with required dependencies
- Compute: Standard_F2s_v2
- Exposes a REST API for real-time predictions
- Secured using API key authentication
A custom script (invoke_endpoint.py) was used to:
- Load the deployment dataset
- Apply the same feature engineering pipeline used during training
- Send HTTP POST requests to the endpoint
- Receive predictions
- Compute evaluation metrics
Results on unseen deployment data:
- Accuracy: 0.802
- Precision: 0.802
- Recall: 1.0
- F1 Score: 0.890
- Performance is consistent with the test dataset
- No significant degradation observed, indicating minimal data drift
This project includes:
- Data preprocessing and feature engineering
- Model training using Azure ML compute
- Hyperparameter tuning with sweep jobs
- Model evaluation (train, validation, test)
- Model registration
- Deployment via managed online endpoint
- Real-time inference using REST API
- Post-deployment evaluation
-
The model shows bias toward the majority class
-
AUC indicates limited predictive separation
-
Potential improvements:
- Enhanced feature engineering
- More advanced models (e.g., transformer-based approaches)
- Techniques to address class imbalance
This project demonstrates a complete end-to-end MLOps pipeline using Azure Machine Learning. The model is successfully trained, deployed, and used for real-time inference, fulfilling all assignment requirements.