The AI-Based Review Classifier is a Python-based machine learning application that classifies customer reviews as Positive or Negative. It uses a Logistic Regression model trained on TF-IDF features, and exposes a RESTful API for real-time predictions using Flask (with an example FastAPI implementation also included).
- ✅ Logistic Regression Model for Sentiment Analysis
- ✅ TF-IDF Text Vectorization
- ✅ RESTful API for Real-Time Classification (Flask)
- ✅ Preprocessing, Training, and Evaluation Scripts
- ✅ Jupyter Notebooks for Data Exploration and Testing
- ✅ Docker Support for Easy Deployment
- ✅ Automated Model Testing and Evaluation
AI-Based-Review-Classifier/
│ ai_service.py # Python client for API
│ check_data_balance.py # Data balance checker
│ Dockerfile # Docker deployment
│ evaluate.py # Model evaluation script
│ main.py # FastAPI example (optional)
│ model.pkl # Trained model
│ ModelTesting.py # Model testing script
│ profile_training.py # Profiling training time
│ sample.py # Sample model training
│ vectorizer.pkl # Saved TF-IDF vectorizer
│ readme.md # Project documentation
│
├── api/
│ ├── app.py # Flask API for predictions
│ ├── model_loader.py # Model/vectorizer loader
│ └── requirements.txt # Python dependencies
│
├── notebooks/
│ ├── DataExploration.ipynb # Data exploration
│ └── ModelTesting.ipynb # Model evaluation
│
├── tests/
│ ├── test_predictions.py # API prediction tests
│ └── test_preprocessing.py # Preprocessing tests
│
└── training/
├── preprocess.py # Data preprocessing
├── train_model.py # Model training
└── evaluate.py # Model evaluation
- Python 3.10+
- Flask (REST API)
- Scikit-Learn (Logistic Regression, TF-IDF)
- Pandas, NumPy
- Jupyter Notebooks (Experiments)
- Docker (Deployment)
- Algorithm: Logistic Regression (from scikit-learn)
- Feature Extraction: TF-IDF (Term Frequency-Inverse Document Frequency)
- Input: Raw review text
- Output: Sentiment label (
positiveornegative) and confidence score - Model Artifacts:
model.pkl(Logistic Regression),vectorizer.pkl(TF-IDF)
| Method | Endpoint | Description |
|---|---|---|
| POST | /predict |
Classifies review text |
Sample Request:
POST http://localhost:5000/predict
Content-Type: application/json
{
"text": "This product is amazing!"
}
Sample Response:
{
"prediction": "positive",
"confidence": "98.00%"
}
git clone https://github.com/yourusername/AI-Based-Review-Classifier.git
cd AI-Based-Review-Classifier
pip install -r api/requirements.txt
cd api
python app.py
The API will be available at http://localhost:5000/predict.
To build and run the app with Docker:
docker build -t review-classifier .
docker run -p 8001:8001 review-classifier
- Run
tests/test_predictions.pyto test API predictions. - Run
tests/test_preprocessing.pyto test preprocessing. - Use Jupyter notebooks in
notebooks/for exploration and evaluation.
We welcome contributions! Please fork the repo, create a branch, and submit a pull request.
This project is licensed under the MIT License.
🚀 Happy Coding! 🎉