A comprehensive Natural Language Processing (NLP) project for sentiment analysis using both traditional machine learning and deep learning approaches.
- Dual model implementation:
- Traditional ML: TF-IDF + Logistic Regression
- Deep Learning: LSTM with word embeddings
- Interactive API endpoints using FastAPI
- Comprehensive visualization tools
- Extensive data preprocessing pipeline
- Model performance comparison utilities
- Clone the repository:
git clone https://github.com/gitarber/sentiment-analysis
cd sentiment-analysis- Install dependencies:
pip install -r requirements.txt- Download and prepare the dataset:
python src/data/download_data.py- Train the models:
python src/train_models.py- Start the API server:
python src/run_api.pysentiment-analysis/
├── data/ # Data directory
│ ├── raw/ # Raw data files
│ └── processed/ # Processed data files
├── models/ # Saved model files
├── notebooks/ # Jupyter notebooks
├── src/ # Source code
│ ├── api/ # API implementation
│ ├── data/ # Data processing scripts
│ ├── models/ # Model implementations
│ └── visualization/ # Visualization utilities
├── tests/ # Test files
├── .gitignore # Git ignore file
├── requirements.txt # Project dependencies
└── README.md # Project documentation
notebooks/1_Data_Exploration.ipynb: Dataset analysis and preprocessing stepsnotebooks/2_Model_Training.ipynb: Model training and evaluation processnotebooks/3_Model_Analysis.ipynb: Detailed model performance analysisnotebooks/4_API_Usage.ipynb: Examples of using the API endpoints
/: Welcome message/health: Health check/analyze/traditional: Analyze sentiment using traditional ML/analyze/lstm: Analyze sentiment using LSTM/analyze/batch/traditional: Batch analysis with traditional ML/analyze/batch/lstm: Batch analysis with LSTM/models/info: Get model information
- Confusion matrices
- Training history plots
- Model comparison charts
- Feature importance analysis
- Attention weights visualization (for LSTM)
Run the test suite:
pytest tests/This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request


