Skip to content

Repository files navigation

Amazon Review Sentiment Analysis – MLOps Pipeline

Overview

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.


Model Choice

The model used is Logistic Regression (scikit-learn).

Rationale

  • 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

Feature Engineering

The model uses engineered numerical features derived from the dataset.

Key steps

  • 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

Feature Sets Tested

  • sbert_tfidf
  • all (selected for final model)

Hyperparameter Tuning

Hyperparameter tuning was performed using an Azure ML sweep job.

Parameters tuned

  • Regularization strength (C)
  • Solver type
  • Maximum iterations

Outcome

  • Minimal variation across runs
  • Performance remained consistent
  • Final configuration selected based on stability

Model Performance

Training, Validation, and Test Results

  • Accuracy: ~0.802
  • Precision: ~0.802
  • Recall: 1.0
  • F1 Score: ~0.890
  • AUC: ~0.50

Observations

  • 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

Model Deployment

The trained model was deployed using Azure ML Managed Online Endpoints.

Deployment Components

  • Registered model: amazon-review-sentiment-model
  • Scoring script: score.py
  • Environment: custom conda environment with required dependencies
  • Compute: Standard_F2s_v2

Endpoint

  • Exposes a REST API for real-time predictions
  • Secured using API key authentication

Inference and Endpoint Invocation

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

Deployment Performance

Results on unseen deployment data:

  • Accuracy: 0.802
  • Precision: 0.802
  • Recall: 1.0
  • F1 Score: 0.890

Interpretation

  • Performance is consistent with the test dataset
  • No significant degradation observed, indicating minimal data drift

MLOps Workflow Summary

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

Limitations and Future Work

  • 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

Conclusion

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages